By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

opening new window in one window using Tkinter -- Help please

P: n/a
Hi,...
I meant to write an application where there is a button in a window and
when you click on the button, it will open a new window, but I want the
first window to close, replaced by the second window.
I open a login window and start the mainloop, when the user click on
the login button, the __call__ function of VerifyProcessor is executed
and it will call the new window which is the file manager window
The thing is,.. I don't know how to exit the first mainloop and then
display the second window...I even tried calling the mainloop again but
a weird thing happens. I really need help because otherwise I'm stuck
here and I can't complete my assignment. The following is my code:

from login import LoginMenu
app = LoginMenu()
app.master.title("Login Menu")
app.master.maxsize(300,200)
app.mainloop()
======================================
class LoginMenu(Frame):

def createWidgets(self):
self.loginButton = Button(self, text='Login', command =
VerifyProcessor(self.x, self.y, self.msg, self.messageLabel) )

def __init__(self, master=None):
Frame.__init__(self, master)
self.grid(column=6, row=4)
self.createWidgets()

class VerifyProcessor:

def __init__(self, thename, thepass, msg, msglabel):
self.username = thename
self.password = thepass
self.msgVar = msg
self.msgLabel = msglabel

def __call__(self):
import md5
import dictionaryloader
found = 0
theDict = dictionaryloader.loadFrom("Dicttxt")
entries = theDict.items()
for theuser, thepass in entries:
if self.username.get() == theuser and
md5.new(self.password.get()).hexdigest() == thepass:
found=1
from mainmenu import FileManager
app2 = FileManager(self.username.get())
app2.master.title("File Manager")
app2.master.maxsize("400,1500")
app2.mainloop()
================================================== ===================
class FileManager(Frame):

def createWidgets(self, username):
...
def __init__(self, username, master=None):
Frame.__init__(self, master)
self.grid(column=6, row=6)
self.createWidgets(username)
================================================== ====================

Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Clara" wrote:
I meant to write an application where there is a button in a window and
when you click on the button, it will open a new window, but I want the
first window to close, replaced by the second window.
I open a login window and start the mainloop, when the user click on
the login button, the __call__ function of VerifyProcessor is executed
and it will call the new window which is the file manager window
The thing is,.. I don't know how to exit the first mainloop and then
display the second window...I even tried calling the mainloop again but
a weird thing happens. I really need help because otherwise I'm stuck
here and I can't complete my assignment. The following is my code:


you don't really have to start a new mainloop to create a new toplevel
window. just call "withdraw" on first window, and create the second
(as a Toplevel), and Tkinter will take care of the rest.

</F>

Jul 19 '05 #2

P: n/a
Well, but where do I call withdraw?

Jul 19 '05 #3

P: n/a
Forgive my ignorance, but where do I call withdraw?

Jul 19 '05 #4

P: n/a
"Clara" wrote:
Well, but where do I call withdraw?


when you want the new window to appear, and the old one to
go away, of course. something like this, perhaps?

from mainmenu import FileManager
app2 = FileManager(self.username.get())
app2.master.title("File Manager")
app2.master.maxsize("400,1500")
- app2.mainloop()
+ app.master.withdraw()

</F>

Jul 19 '05 #5

P: n/a
since the file where i call the first window and the second window is
different,.If I put app.master.withdraw() there,...won't I get error
message that says; app is not defined as global or something like that?

Jul 19 '05 #6

P: n/a
I've found the solution!!!!!!!! I must destroy the first window using
self.master.destroy(), but thanks anyway ^_^

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.