Clara wrote:
Hi, can somebody help me,..I have an assignment due next week but now
I'm stuck with this problem....
I tried to get values from entry widget using the
widgetcontrolvariable.get(),..but it seems that it won't work....
I can't print the value I input in the entry widget...However when I
first set the value to something I can get the value just fine...
This is my code
Help please...

msg='*~*Please Login to use the system*~*'
class LoginMenu(Frame):

def createWidgets(self, msg):
import tkFont
self.x = StringVar()
self.y = StringVar()
self.x.set("Type here") self.messageLabel= Label(self, text=msg, pady=15,
font=tkFont.Font(weight='bold' ,size=10))
self.messageLabel.grid(row=0, columnspan=6)
self.nameLabel= Label(self, text='UserName :', padx=12,
justify=LEFT)
self.nameLabel.grid(row=1, column=0, ipadx=9, ipady=5)
self.nameEntry= Entry(self,justify=LEFT, textvariable=self.x)
self.nameEntry.grid(row=1, column=3, columnspan=2)
self.nameEntry.update_idletasks()
self.passLabel= Label(self, text='Password :', padx=12,
justify=LEFT)
self.passLabel.grid(row=2, column=0,ipadx=9, ipady=5)
self.passEntry= Entry(self,justify=LEFT, show='*',
textvariable=self.y)
self.passEntry.grid(row=2, column=3, columnspan=2)
self.passEntry.update_idletasks()
self.loginButton = Button(self, text='Login', command =
VerifyProcessor(self.x.get(), self.y.get()) )


Here is the problem, the values of the two entries have been got'on
before the button is pressed and the command is called.

I would replace the above with:-

VerifyProcessor(self.x, self.y)) )

and see below for the changes to the command callback class


self.loginButton.grid(row=4, column=3, ipadx=15, ipady=3, pady=20)
self.quitButton = Button(self, text='Exit', command = self.quit) self.quitButton.grid(row=4, column=4, ipadx=20, ipady=3, pady=20,
padx=10)


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

class VerifyProcessor:

        def __init__(self, thename, thepass):
                self.username = thename
                self.password = thepass

        def __call__(self):
                print self.username
                print self.password

print self.username.get() print self.password.get()




app = LoginMenu(msg) app.master.title("Login Menu") app.master.maxsize(280,200) app.mainloop()


HTH
Martin

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to