Pmw activate method
Reggie Dugard
reggie at merfinllc.com
Wed Jul 7 20:08:10 EDT 1999
Please forgive me if this is a stupid question, because I'm pretty new to
Python and really new to Pmw.
I'm writing an GUI application using Pmw on NT 4.0 SP5 and, during
debugging, I call it repeatedly during a given python interactive session.
As part of the application, I use some dialogs which I display using the
activate method. My problem is, once I've activated a dialog during a
"run", any subsequent "runs" in the same python session will generate the
following background error if I attempt to activate a dialog:
Error: 1
TclError Exception in Tk callback
Function: <method test.dialog of test instance at 898fe0> (type: <type
'instance method'>)
Args: ()
Traceback (innermost last):
File "...\Python\Lib\Pmw\Pmw_0_8\lib\PmwBase.py", line 1349, in __call__
return apply(self.func, args)
File "test2.py", line 18, in dialog
dialog.activate()
File "...\Python\Lib\Pmw\Pmw_0_8\lib\PmwBase.py", line 846, in activate
showbusycursor()
File "...\Python\Lib\Pmw\Pmw_0_8\lib\PmwBase.py", line 1033, in
showbusycursor
if window.state() != 'withdrawn':
File "...\Python\Lib\lib-tk\Tkinter.py", line 861, in wm_state
return self.tk.call('wm', 'state', self._w)
TclError: can't invoke "wm" command: application has been destroyed
I have found that the root window does not seem to get cleared from the
Pmw._toplevelBusyInfo dictionary and if I manually delete it, the error goes
away, but I'm sure there is a better way of fixing this problem.
A typical run looks like:
H:\python>python
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import test2
>>> a=test2.test() <-- Deletion necessary if dialog was activated
Deleting root
>>> a=test2.test() <--- No deletion if I don't activate the dialog during
the run
>>>
Here is my test2 code to give you a better idea of what I'm doing. Any
advice would be appreciated.
import Tkinter, Pmw
class test:
def __init__(self):
root = Tkinter.Tk()
Pmw.initialise(root)
button = Tkinter.Button(text = 'Dialog', command = self.dialog)
button.pack(pady = 20)
exit = Tkinter.Button(text = 'Exit', command = root.destroy)
exit.pack(pady = 20)
root.mainloop()
if hasattr(Pmw,'_toplevelBusyInfo') and
Pmw._toplevelBusyInfo.has_key(root):
print 'Deleting root'
del Pmw._toplevelBusyInfo[root]
def dialog(self):
dialog = Pmw.MessageDialog(title = 'Warning', message_text =
'Testing')
dialog.activate()
--
Reggie Dugard
Merfin, LLC Voice: 925-937-4560
1460 Maria Lane, Suite 420 FAX: 925-937-4530
Walnut Creek, CA 94596 Mailto:reggie at merfinllc.com
More information about the Python-list
mailing list