OT: need python help please
Roger
arelem at bigpond.com
Fri Jul 27 10:50:07 UTC 2012
My daughter wants to teach her students tkinter interface with python.
She cannot get an entry into the field entry1=Entry(fishDisplay,
width=35).grid(row=0, column=1)
to display and this is out of my expertise. Can someone point us to a
suitable tutorial on how to get test in a tk field into a variable and
how to display it.
I ran Idle debug and the result from entry1 is None.
Part of the little app she wrote is as follows.
Please help if possible.
thanks in advance
Roger
from fish import *
from tkinter import *
def searchFish():
def fishies(*args):
#names
siamon = fish[0][0]
goldfish = fish[1][0]
norbert = fish[2][0]
slug = fish[3][0]
snail = fish[4][0]
howzart = fish[5][0]
fidget = fish[6][0]
#aggressive
siamon_a = fish[0][1]
goldfish_a = fish[1][1]
norbert_a = fish[2][1]
slug_a = fish[3][1]
snail_a = fish[4][1]
howzart_a = fish[5][1]
fidget_a = fish[6][1]
#habit
siamon_h = fish[0][2]
goldfish_h = fish[1][2]
norbert_h = fish[2][2]
slug_h = fish[3][2]
snail_h = fish[4][2]
howzart_h = fish[5][2]
fidget_h = fish[6][2]
if entry1=="Goldfish":
details=Label(fishDisplay, bg='lightblue',
text='Goldfish').grid(row=3, column=1)
#print(goldfish[0], goldfish_a[0],goldfish_h[0]) #use the [0] to
remove the ['']'s when printed
#### THE START OF THE TKINTERFACE ####
# sf = searchFish
sf = Tk()
sf.title('Jackson\'s Pond Emporium >> Search A Fish')
sf.geometry("500x400")
sf['background']='lightblue'
window=Frame(sf).pack()
green = PhotoImage(file='GreenFish.gif', master=sf)
topFrame = Frame(window, bg='lightblue').pack(side=TOP, anchor=NW)
newfont = ('arial', 20, 'bold')
g = Label(topFrame, image=green, bg='lightblue').pack(side=LEFT,
anchor=NW, padx=2, pady=2)
title = Label(topFrame, text = 'Fishbase', font = newfont,
bg='lightblue')
title.config(height=3, width=3)
title.pack(side=TOP, fill=BOTH)
fishDisplay = Canvas(window, bg='lightblue')
Label(fishDisplay, text='Keyword:', bg='lightblue',
fg='black').grid(row=0, column=0, sticky=W)
entry1=Entry(fishDisplay, width=35).grid(row=0, column=1)
btn_search=Button(fishDisplay, width=6, text='Search',
command=fishies).grid(row=0, column=3)
Label(fishDisplay, text='Details:', bg='lightblue',
fg='black').grid(row=2, column=0, sticky=W)
details=Label(fishDisplay, bg='lightblue', text='Search the
Fishbase').grid(row=2, column=1)
fishDisplay.pack(side=TOP, anchor=W, fill=X)
sf.bind('<Return>', fishies)
print('entry1 ',entry1)
sf.mainloop()
More information about the users
mailing list