Command Line drive Tk window

A

annagel

I have been working to build a media toolkit that uses pygame to modify
image and sound data for the user. I have all of this working fine.
The one thing I am working on now is adding a pop-up view for the image
data as well as some pop-ups for file selection and color picking. I
am having problems with the first part of this which I think will carry
through to the file/color pickers but all of that is secondary anyway
so not too big a deal.

Basically the module is set up so after importing it must be
initialized. This initializes a bunch of pygame stuff and also starts
a thread to watch for user events on its windows. I just create a Pk
instance and withdraw it (this is ok because this thread is run as
daemon so the program won't be stalled from exiting by a window they
can't see to close). Then when the user wants to view one of their
images in a window they call a function in the object which converts
the image to a PIL image and imports it to a Toplevel Pk window. The
problem is that this window does not become visible. I did some
investigation and found that if I did not withdraw my root window I
could get the Toplevel to show by clicking the root window. What I
think what is actually going on here is that the Tk mainloop is only
looking for user events generated by the gui itself so when I try to do
something from the comand line the mainloop is not looking for the
event.

Does anyone know of a way I can overcome this problem. I have tried
creating a second loop that just keeps hitting the main window by
calling update, this does not work the update stalls until I click with
window just like creation of the toplevel window. Finally I have also
tried cyclicly adding an after_idle call to the window so it will keep
calling some function when it goes to idle figuing I could keep the
main loop alive perhaps in this way. This prevented the main window
from apearing at all and so this is not a good option.

Any thought would be apreciated,
Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top