473,583 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck on some "Entry pack" code for GUI

BW
Please ignore the rest of the code, except for the highlighted part (or the line 'ent1=Entry(top f, width=25)' to line 'ent1.insert(IN SERT, wrong, if you cannot see the color). You can copy this into Python and make sure you have the GIF file in the same dir. Also, make sure that you have PIL installed.

I cannot get this to work. I get an error after running it and what I'm trying to do it to evaluate what the person enters in the box for the capital of Alabama. I want the user to enter the capital and if it's not right, I want the program to tell them within that box. Apparently, Python does not like the "0.0" entry within the box. Why is this not working?

from Tkinter import *
import ImageTk
class Gui(Frame):

def lab(self):
# A generic text label for the frame
self.lab1 = Label(base, text = "Text for label") #text will be reset later
self.lab1.grid( columnspan=3)

def but(self):
# A generic button for the frame
self.but1 = Button(bottom, text="Take the quiz") #text and command to be set later
self.but1.pack( side=RIGHT)

def labR(self):
# A generic text label for the right frame
self.lab1R = Label(R, text = "Text for label") #text will be reset later
self.lab1R.pack (side = TOP)

#def butL(self):
# A generic button for the left frame
#self.but1L = Button(L, text="text on button") #text and command to be set later
#self.but1L.pac k(side = LEFT)

def butR(self):
# A generic button for the right frame
self.but1R = Button(RB, text="text on button") #text and command to be set later
self.but1R.pack (side = LEFT)

#def entcap(None):
# A generic text entry for the left frame
#self.entcap1 = Entry(width=25) #width can be changed later
#self.entcap1.p ack(side = BOTTOM)

def entR(self):
# A generic text entry for the right frame
ent1R = Entry(RB, width=20) #width can be changed later
ent1R.pack(side = TOP)

def txtL(self):
# A generic text box for the left frame
self.txt1L = Text(L, width=100, height=5, wrap=WORD)
self.txt1L.pack (side = BOTTOM)

def txtR(self):
# A generic text box for the right frame
self.txt1R = Text(R, width=100, height=5, wrap=WORD, padx=5, pady=5)
self.txt1R.pack (side = TOP)

def rdbut(self):

self.states = StringVar()
Radiobutton(bas e, text="Alabama", variable=self.s tates, value="AL").gri d(row=20, column=0, sticky=W)
Radiobutton(bas e, text="Arkansas" , variable=self.s tates, value="AK").gri d(row=20, column=1, sticky=W)
Radiobutton(bas e, text="Florida", variable=self.s tates, value="FL").gri d(row=20, column=2, sticky=W)
Radiobutton(bas e, text="Georgia", variable=self.s tates, value="GA").gri d(row=25, column=0, sticky=W)
Radiobutton(bas e, text="Kentucky" , variable=self.s tates, value="KY").gri d(row=25, column=1, sticky=W)
Radiobutton(bas e, text="Louisiana ", variable=self.s tates, value="LA").gri d(row=25, column=2, sticky=W)
Radiobutton(bas e, text="Mississip pi", variable=self.s tates, value="MS").gri d(row=30, column=0, sticky=W)
Radiobutton(bas e, text="North Carolina", variable=self.s tates, value="NC").gri d(row=30, column=1, sticky=W)
Radiobutton(bas e, text="South Carolina", variable=self.s tates, value="SC").gri d(row=30, column=2, sticky=W)
Radiobutton(bas e, text="Tennessee ", variable=self.s tates, value="TN").gri d(row=35, column=0, sticky=W)
Radiobutton(bas e, text="Virginia" , variable=self.s tates, value="VA").gri d(row=35, column=1, sticky=W)
Radiobutton(bas e, text="West Virginia", variable=self.s tates, value="WV").gri d(row=35, column=2, sticky=W)



def stateget(self):
state = self.states.get ()
if state == "AL":
top = Toplevel()
top.title("Alab ama Capital Quiz")
topf = Frame(top)
topf.pack()
topb = Frame(top)
topb.pack()
pct = ImageTk.PhotoIm age(file="AL.gi f")
var = Canvas(topb, height=250, width=250)
img = var.create_imag e(10, 10, anchor=N, image=pct)
var.pack()
#top.geometry(" 500x500")
# Now I add a text box
#txtbx2 = Text(topf, height=5, width=40, bg="yellow", wrap=WORD)
#txtbx2.pack(si de=TOP)
#txtbx2.insert( INSERT, message2)
close = Button(topb, text="Close", command=top.des troy)
close.pack(side =RIGHT)
ent1=Entry(topf , width=25)
ent1.insert(INS ERT, "What is the capital of Alabama?")
ent1.pack()
name = ent1.get()
right = "Correct!!! "
wrong = "No, please try again."
if name == "montgomery ":
ent1.delete(0.0 , END)
ent1.insert(INS ERT, right)
else:
ent1.delete(0.0 , END)
ent1.insert(INS ERT, wrong)


root = Tk()
root.title("US Southeast Regional Quiz")
gui = Gui(root)
base = Frame(root)
base.grid()

gui.lab()
gui.lab1.config ure(text="Welco me to the Southeast US State Quiz!")

# I will bring in another label explaining what I want
gui.lab()
gui.lab1["text"]="Please select a state to begin and click on the 'Take the quiz' button below."

# Now for the radiobuttons displayed with the updatemsg textbox
gui.rdbut()
#gui.updatemsg( )

# I Need a frame for my buttons
bottom = Frame(base)
bottom.grid(row =99)

# To get out of the program
gui.but()
gui.but1.config ure(text="Exit" , command=gui.qui t)

# To run the msg function
gui.but()
gui.but1.config ure(text="Take the Quiz", command=gui.sta teget)


root.mainloop()

Jul 19 '05 #1
0 1464

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

Similar topics

14
3934
by: Don G | last post by:
Within the menu for my site, I have inserted 'class="current"' within the link for the current page. So the link looks somthing link: <li><a href="index.php" class="current">Home</a></li> The css for formatting the menu links is: #menu a:hover { background-color: #E00080; color: white;
1
1259
by: seeker | last post by:
I need to develop some fairly basic data entry screens to add, update and delete records in a SQL Server 2000 database. Is anyone aware of some free or shareware VB.NET 2003 code that can be easily downloaded and modified to do this? -- seeker
3
2750
by: D Denholm | last post by:
I am a Access newbie... Hopefully somebody can help me figure this out. I have a database that looks like: Asset Economic Minimum ----- ---------------- 10555 320 10555 320 10555 320
0
5596
by: cherryparadise001 | last post by:
Hi All, I have moved an asp system from Window Server 2000 to Window Server 2003 recently. Many error occured and most of them are unable to get the control's value in the page. I am newbie to asp and I would like to ask any different in Window Server 2000 and 2003 will cause error like this? and is there any KB told how to do the...
8
1720
by: Jeremy | last post by:
If we have a table with say 3 rows in it and one of the columns contains a checkbox such as <table> <tr> <td><input type="checkbox" name="ch_fld"></td> </tr> <tr> <td><input type="checkbox" name="ch_fld"></td> </tr>
10
4159
by: Lung.S.wu | last post by:
Hi all, It is a history question. Recently, I read the book "C A reference manual, third edition". In this book, it list all C language keyword, and one is "entry". I know it is omitted from ANSCI C, but I hope I can find any data about it. Doea any one know how to use it, before?
2
1633
by: Rymfax | last post by:
I have an application that will be used on both XP and Vista. One of the things this application needs to do is determine the exact operating system it is on. To get the correct "flavor" of Vista that might be running, there is a new function in Kernel32.dll called GetProductInfo(). The problem I'm running into is that if I include this...
1
1165
by: HappyChapZA | last post by:
Hi all, I have the following code which displayes properties to let when searched for by "City/Town", "Suburb", "Type" and then between two "Rental" amounts. I would like to also include filtering by the "Status" field so that only approved entries will be displayed in a search result. Any help will be much appreciated. Here is the code: ...
3
30199
by: ElBeardo | last post by:
Hello, Im new to Python.. so this is a newbee question. Id like to put the value enterd in the entryfield in a variable. Im trying to build a calculator with python and TKinter, coding it in just python works good. But making it with TK is a bit hard. This is my unfinished code, i have tryed get() in many ways,.but I cant make it work....
0
7829
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
8189
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. ...
0
8330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7940
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...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5379
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
3824
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...
1
1438
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1162
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.