473,586 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The value of the entry widget doesn't get updated

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
widgetcontrolva riable.get(),.. but it seems that it won't work....
I can't print the value I input in the entry widget...Howeve r 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(s elf, msg):
import tkFont
self.x = StringVar()
self.y = StringVar()
self.x.set("Typ e here")
self.messageLab el= Label(self, text=msg, pady=15,
font=tkFont.Fon t(weight='bold' ,size=10))
self.messageLab el.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,just ify=LEFT, textvariable=se lf.x)
self.nameEntry. grid(row=1, column=3, columnspan=2)
self.nameEntry. update_idletask s()
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,just ify=LEFT, show='*',
textvariable=se lf.y)
self.passEntry. grid(row=2, column=3, columnspan=2)
self.passEntry. update_idletask s()
self.loginButto n = Button(self, text='Login', command =
VerifyProcessor (self.x.get(), self.y.get()) )
self.loginButto n.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(colum n=4, row=4)
self.createWidg ets(msg)

class VerifyProcessor :

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

def __call__(self):
print self.username
print self.password
app = LoginMenu(msg)
app.master.titl e("Login Menu")
app.master.maxs ize(280,200)
app.mainloop()
Jul 19 '05 #1
4 1534
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
widgetcontrolva riable.get(),.. but it seems that it won't work....
I can't print the value I input in the entry widget...Howeve r 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(s elf, msg):
import tkFont
self.x = StringVar()
self.y = StringVar()
self.x.set("Typ e here")
self.messageLab el= Label(self, text=msg, pady=15,
font=tkFont.Fon t(weight='bold' ,size=10))
self.messageLab el.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,just ify=LEFT, textvariable=se lf.x)
self.nameEntry. grid(row=1, column=3, columnspan=2)
self.nameEntry. update_idletask s()
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,just ify=LEFT, show='*',
textvariable=se lf.y)
self.passEntry. grid(row=2, column=3, columnspan=2)
self.passEntry. update_idletask s()
self.loginButto n = 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.loginButto n.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(colum n=4, row=4)
self.createWidg ets(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.g et()
print self.password.g et()

app = LoginMenu(msg)
app.master.titl e("Login Menu")
app.master.maxs ize(280,200)
app.mainloop()

HTH
Martin

Jul 19 '05 #2
Clara wrote:
<SNIP>
self.loginButto n = Button(self, text='Login', command =
VerifyProcessor (self.x.get(), self.y.get()) ) <SNIP>
class VerifyProcessor :

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

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


Your VerifyProcessor object is constructed just before your loginButton,
not when you click.
Therefore you may want to pass the x and y StringVars to its __init__
function instead of their value at contruction. Therefore your __call__
method can .get() their values each time the button is clicked.
Jul 19 '05 #3
Yes that solves my problem all right...THanks a bunch to both of you

Jul 19 '05 #4
Yes that solves my problem all right...THanks a bunch to both of you

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2927
by: lawrence | last post by:
A very strange bug. www.monkeyclaus.org is run by a cms I'm developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The purpose of this level of security is to let someone log in and see everything as if they were root, and yet not be able to update or delete...
0
1048
by: Clara | last post by:
I tried to print the value of my entry widget by passing the result of controlvariable.get() in Tkinter to a function. However, I kept printing empty string (eventhough I've written something inside the entry widget). But if I first set the value of the entry widget using .set,...I can get the value just fine...Anybody knows why??
4
6223
by: Michael Onfrek | last post by:
Hi, is copy, paste, cut of selection possible in entry widget? Docs say selection must be copied by default, in my programm it doesn't work. Regards, M.O.
6
9642
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been made for service staff. My problem is the SQL is not retrieving the value of the listbox. I have tested the SQL by entering a fixed value of a...
2
2865
by: Dustan | last post by:
How do I limit what the user can enter in an Entry Widget? I know I can set it to display '*' to hide a password, but what I want to do is limit the contents to numeric characters. What is the easiest way of doing this?
4
1896
by: Dustan | last post by:
Back in this post, I attempted to make a label look like a button:...
2
4108
by: Kevin Walzer | last post by:
I'm trying to construct a simple Tkinter GUI and I'm having trouble with getting the value of an entry widget and passing it onto a callback function. But I'm not grokking variable scope correctly. I have two functions. Here are the relevant excerpts: def makeGUI(): ###lots of code to set up toplevel windows
17
479
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I get the value of a form control? ----------------------------------------------------------------------- In HTML documents, named forms may be referred to as named properties of the « document.forms » collection, and named form controls may be...
3
1901
Elias Alhanatis
by: Elias Alhanatis | last post by:
Hello to everybody!! I am running Python 2.5.1 on Windows Vista and i have a problem with the "Entry" widget of Tkinter. Take a look at this code: from Tkinter import * def fetch(): q=(e.get()) print q
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.