[Tutor] Dialogbox issues............................
Python-lover
hemanexp@yahoo.com
Mon May 5 01:12:01 2003
hi,
I am using python1.5 and Tkinter. I want to
display the dialog box when i click the button in my
main window. I used tkSimpleDialogBox class. But the
following program is not working as it is expected.
How can i diaplay a dialog box in Tkinter? Let me
know where i gone wrong.
from Tkinter import *
import tkMessageBox
import tkSimpleDialog
import string
class App:
def __init__(self,parent):
self.myparent = parent
Button(self.myparent,text="Click",width=10,
height=10,command=self.showdlg).pack()
def showdlg(self):
MyDialog(self)
#Dialogbox class
class MyDialog(tkSimpleDialog.Dialog):
def body(self, master):
Label(master, text="First:").grid(row=0)
Label(master, text="Second:").grid(row=1)
self.e1 = Entry(master)
self.e2 = Entry(master)
self.e1.grid(row=0, column=1)
self.e2.grid(row=1, column=1)
self.e1.insert(0,"suressh")
self.e2.insert(0,1234)
def validate(self):
try:
first= (self.e1.get())
second = string.atoi(self.e2.get())
self.result = first, second
return 1
except ValueError:
tkMessageBox.showwarning("Bad input",
"Illegal values, please try again")
return 0
def apply(self):
first = (self.e1.get())
second = string.atoi(self.e2.get())
print first, second
root = Tk()
myapp = App(root)
root.mainloop()
Thanx
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com