title: Tkinter "out of stack space" error with Pymol on Windows
body: <p>I've been writing a plugin for Pymol (visualization software for macromolecular structures). For this I am using python and tkinter.</p>
  
  <p>My plugin works, and I can register it in the Pymol "Plugin" Menu.</p>
  
  <p>After installing the plugin.py file from the Pymol-own Plugin Manager, there are three options to start the plugin:</p>
  
  <p>1) Plugin Menu --> "Plugin Name"   |   Works on Linux and Windows</p>
  
  <p>2) Pymol Command Line --> Testplugin   |   Works only on Linux</p>
  
  <p>3) from the Pymol main window CTRL+F   |   Works only on Linux</p>
  
  <p>The error I get in cases 2 and 3 on windows machines is the following:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Program Files (x86)\PyMOL_1760\PyMOL/modules\pymol\parser.py", line 256, in parse
      self.result=apply(layer.kw[0],layer.args,layer.kw_args)
    File "C:\Program Files (x86)\PyMOL_1760\PyMOL/modules\pmg_tk\startup\tkintertest.py", line 43, in showWindow
      top = Toplevel(parent)
    File "C:\Program Files (x86)\PyMOL_1760\PyMOL\py27\lib\lib-tk\Tkinter.py", line 2017, in __init__
      BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra)
    File "C:\Program Files (x86)\PyMOL_1760\PyMOL\py27\lib\lib-tk\Tkinter.py", line 1974, in __init__
      (widgetName, self._w) + extra + self._options(cnf))
  TclError: out of stack space (infinite loop?)
  </code></pre>
  
  <p>I have provided a minimal "working" plugin code below. All this does is just open a new window and display a label "Testlabel". Again, you can start the plugin from Pymol on Linux with all three methods, whereas on Windows only the first method works and the other two give the out of stack error above. This has been tested with different Windows/Linux/Pymol versions.</p>
  
  <p>Minimal code example:</p>
  
  <pre><code>#! /usr/bin/env python
  
  from Tkinter import *
  from pymol import cmd, plugins
  
  
  class Testplugin(Frame):
  
      def __init__(self, parent):
          Frame.__init__(self, parent)
          self.parent = parent
          self.pack()      
          self.create_widgets()
  
      def create_widgets(self):
  
          self.labelTest = Label(self,
              text = "Testlabel"
          )
  
          self.labelTest.grid(
              in_ = self,
              column = 1,
              row = 1,
              columnspan = 1,
              ipadx = 0,
              ipady = 0,
              padx = 0,
              pady = 0,
              rowspan = 1,
              sticky = "n"
          )
  
          self.grid_rowconfigure(1, minsize = 30, pad = 3)
          self.grid_columnconfigure(1, minsize = 30, pad = 3)
  
  
  def __init__(self):
      self.menuBar.addmenuitem("Plugin", "command", label="Testplugin", command = showWindow)
  
  def showWindow():
      parent = plugins.get_tk_root()
      top = Toplevel(parent)
      frame = Testplugin(top)
  
  cmd.extend("Testplugin", showWindow)
  cmd.set_key("CTRL-F", showWindow)
  </code></pre>
  
  <p>Thank you in advance!</p>