1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

multiple files under Python

Discussion in 'Software Development' started by evilmrhenry, Jan 17, 2004.

Thread Status:
Not open for further replies.
  1. evilmrhenry

    evilmrhenry Thread Starter

    Joined:
    Dec 14, 2001
    Messages:
    105
    What I am trying to do is have a button on a window that will hide the window, open a new window, then, when the opened window is closed, open the previous window again. The code is large enough that I want to do each window in a separate source file. The problem is with the wait_window command, as it requires access to both the root window and the window_file2 window. Currently, in the code below, Python complains that root does not exist. If I place the code in file1, (just below file2.init_window) it complains that window_file2 does not exist.

    Edit: figured out the correct syntax. The code below is now the correct version, and will run without problems.

    Code:
    #file1.py
    
    from Tkinter import *
    import file2
    
    root = Tk()
    
    def open_file2():
    	root.withdraw()
    	file2.init_window()
    	root.deiconify()
    
    exmple_button = Button(root, text="open file2", command=open_file2)
    exmple_button.pack(side=LEFT)
    root.mainloop()
    
    
    
    #file2.py
    
    from Tkinter import *
    
    def init_window():
    	window_file2 = Toplevel()
    	window_file2.master.wait_window(window_file2)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/196317

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice