insilichem / pychimera

Use UCSF Chimera Python API in a standard interpreter
http://pychimera.readthedocs.io
GNU Lesser General Public License v3.0
57 stars 10 forks source link

2Dlabels is not working correctly with pychimera #8

Closed josan82 closed 6 years ago

josan82 commented 6 years ago

When using the pychimera --gui, Chimera raises a RuntimeError when I try to launch the 2D Labels utility (Tools->Utilities->2D Labels), after opening a model in the window.

It seems to complain about there is not an opened root window, but in fact this is false, because before calling 2D Labels a chemical model was opened.

When doing the same with a normal Chimera, there is no problem at all, and the 2D Labels utility is opened without problem.

The complete traceback of the Reply Log is:

RuntimeError Exception in Tk callback
  Function: <function activate at 0x7f35a28f1a28> (type: <type 'function'>)
  Module: <module 'chimera.extension.base' from '/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/extension/base.pyc'> (line: 482)
  Args: ()
Traceback (innermost last):
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/lib/python2.7/site-packages/Pmw/Pmw_1_3_3/lib/PmwBase.py", line 1747, in __call__
    return apply(self.func, args)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/extension/base.py", line 483, in activate
    e.menuActivate(cat)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/extension/base.py", line 91, in menuActivate
    self.activate()
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/Ilabel/ChimeraExtension.py", line 23, in activate
    d = dialogs.display(self.module('gui').IlabelDialog.name)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/dialogs.py", line 76, in display
    dialog = find(name, create=1)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/dialogs.py", line 61, in find
    return d()
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/Ilabel/gui.py", line 52, in __init__
    ModelessDialog.__init__(self)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/baseDialog.py", line 668, in __init__
    BaseDialog.__init__(self, master, *args, **kw)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/chimera/baseDialog.py", line 255, in __init__
    self.fillInUI(self.__top)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/Ilabel/gui.py", line 102, in fillInUI
    self._fillLabelsPage(self.notebook.page(self.LABELS))
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/Ilabel/gui.py", line 116, in _fillLabelsPage
    anchor='w')
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/CGLtk/Table.py", line 605, in addColumn
    entryPadX, entryPadY, color, headerAnchor)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/CGLtk/Table.py", line 1371, in __init__
    self._computeStyles()
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/share/CGLtk/Table.py", line 1427, in _computeStyles
    padx=textPadX, pady=textPadY)
  File "/home/insilichem/.local/UCSF-Chimera64-1.12/lib/python2.7/lib-tk/Tix.py", line 482, in __init__
    elif not master: raise RuntimeError, "Too early to create display style: no root window"
RuntimeError: Too early to create display style: no root window

  File "/home/insilichem/.local/UCSF-Chimera64-1.12/lib/python2.7/lib-tk/Tix.py", line 482, in __init__
    elif not master: raise RuntimeError, "Too early to create display style: no root window"

See reply log for Python traceback.
jaimergp commented 6 years ago

This can be fixed by adding these lines on any Extension that is loaded within the GUI:

import Tkinter as tk
import Tix
Tix._default_root = tk._default_root

In fact, we are doing that right after the chimeraInit call, but apparently it's too early to make any effect. I will look into something scheduled for later execution or something like that.