probelm with Tkinter module

Eric Brunel eric.brunel at pragmadev.com
Mon Aug 12 04:00:33 EDT 2002


David Cruz wrote:

> Hi everybody,
> 
> I'm using the Tkinter module to create an interface with python but I
> have some problems that I can 't resolve.
> I've created an interface with  a button; when I click on this buttons a
> new window must appear;this new window contains other buttons and a text
> field; but my problem is that when I launch the application,  appear the
> main interface(normal) and a second empty window( which is the window
> associated to the buttons) ; when I click on the button(execute a
> "grid" command), the buttons and the text field appear in the empty
> window;
> Somebody could tell me how can Ido to not have this empty window when
> Iaunch my application.
> 
> Thanks

In your program, every time you create a frame, you create it like that:

frm = Frame(root=Tk())

This creates a new Tk interpreter and a new main window each time it's 
executed. So the two lines:
>                 outputRollerWindow = OutputRollerFrame(root=Tk())
>                 paperMotorWindow = PaperMotorFrame(root=Tk())
in the __init__ of ListModule are certainly not what you want to do.

If you want to open a window when the user clicks a button, I'd advise you 
to begin with a far simpler example to get the mechanism right. A simple 
button opening a window containing only a label would be a good start. The 
code you included is too complicated to guess what you're trying to do 
exactly. It will be easier to explain what's wrong on a smaller example...

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list