Alex Denham wrote:
Hi all,
I'm just wondering but when i try to access/update anything on my
Tkinter GUI from one particular function, my whole program
crashes/freezes with no error.
The function is part of a class which handles all the GUI
drawing/event handling etc.
The function in question gets called from a win32 DesignatedWrapPolicy
class. Sample code below:
[code]
# this function is part of an IDropTarget class, the TargetWidget
was definined in the __init__ method of this functoin and it points to
my class which handles the GUI.
def Drop(self, data_object, key_state, point, effect):
data = data_object.GetData((15, None, 1, -1, 1))
print data
n_files = shell.DragQueryFileW(data.data_handle, -1)
print n_files
filenames = [shell.DragQueryFileW(data.data_handle, n_file)
for n_file in range(n_files)]
print filenames
self.TargetWidget.filesDropped(filenames) # this calls the
filesDropped function of the TargetWidget class and passes the
filename list to it.
# this function is part of the GUI class (which inherits from
Tkinter.Toplevel) the print commands work however if i uncomment the
clearInput function (which just calls self.filepathInput.delete(0,
END) to clear the text)
# the program hangs, same for the second commented line, and
anything else that requires a call to tk it appears. Is there some
sort of conflict going on between win32 and Tk ??
def filesDropped(self, fileList):
print fileList
# self.clearInput()
# self.filepathInput.insert(Tkinter.END, fileList[0])
[/code]
I'm just wondering if there's something i need to do to 'release' the GUI?
I'm pretty sure it's got nothing to do with my code elsewhere because
it was all working smoothly before, and if i call the filesDropped
function from somewhere else (not from the IDropTarget class) i don't
have any issues.
Thanks in advance,
Alex
This is just a guess, but you usually cannot update a GUI from an
outside process directly. At least, this is true of wxPython. I think
your blocking the idle event in Tkinter, which causes it to hang and
then when you try to update it, Tkinter crashes because you're making a
call on it from what amounts to a separate thread.
Instead, you ought to write to a file or post an event when the win32
part is finished that the Tkinter GUI can check periodically and then
react. In other words, have the win32 portion of your code write
something to a file and have Tkinter check the file every few seconds
and then update itself when it finds something in there.
In wxPython there is a way to subscribe to special events using the
PubSub module. Tkinter probably has its own nomenclature. If you can't
figure it out, I'd recommend the Tkinter mailing list.
Mike
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32