multiple files under Python

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top