Manuel Pérez wrote:
> I’been working on wxpython for the last 2 months or so for a final project at school, the problem I have is to make it work beside TkInter, the GUI by default on python. It almost work fine, but when a window of wx is open the part programmed on tkinter becomes weird, don’t do nothing until the wx window is closed, it don’t affect directly the usability of the program, but our teacher said it can’t happen so... there is a way to make the both interfaces work togueter?
You need both to work in a single application? There is very little
chance of that working, and the result you got is exactly what I would
expect. The issue is messages. All of the major GUI architectures
today are message driven; all the APIs you call eventually turn into
window messages that get sent to the window's thread. A GUI application
needs to have a "main loop", which receives, translates and dispatches
those messages. Both wx and tk expect to be in full control of their
message loops.
Now, having said that, you might be able to make this work by launching
your Tk windows from a separate thread. Many people don't realize that
each window is associated with a thread, and all messages for a window
are sent to the message loop in that thread. So, if you created all
your wx windows in one thread and run wxApp.MainLoop there, and create
your Tk windows in another thread and run tk.mainloop there, you could
make this work. You'd have to be a bit careful about communicating back
and forth, but it could be done.
Why do you need to do this? Why wouldn't you just translate the Tk
windows into wx?
And, by the way, saying "TkInter, the GUI by default on python" is a bit
misleading. TkInter happens to be included with the standard library,
but it's not the "preferred" GUI by any means. It's there because it
was first (way, WAY back -- 25 years ago).
--
Tim Roberts,
ti...@probo.com
Providenza & Boekelheide, Inc.