Assigning entry widget value in a dialog box from other module
Python-lover
hemanexp at yahoo.com
Tue May 6 10:31:07 EDT 2003
Hi,
Iam using python and tkinter. My program run number
of lines. To increase the maintainablity i divided my
program in to two modules (ie, 2 python programs) and
imported them at needed place.
My first program called "a.py" is the main program
in which i placed a button. When u click the button a
dialogbox which is defined in "b.py" will be poped up.
The dialog box contains two entry widgets. Now the
problem is i want to set some default values for the
entry widgets when they displayed. I defined 2
variables called "name" ,"eno" in "a.py" and want to
assign their values to corresponding entry widgets.
When i run the program i got the following error:
File "a.py" line 12, in ?
import b
File "b.py" line 4
from import a
My program is given below.
##########################################
############# a.py
##########################################
from Tkinter import *
import b
class App:
def __init__(self,parent):
self.myparent = parent
Button(self.myparent,text="Click",width=10,
height=10,command=self.showdlg).pack()
self.name = "AAAAA"
self.no = 100
def showdlg(self):
b.MyDialog(self.myparent)
root = Tk()
myapp = App(root)
root.mainloop()
##########################################
############# b.py
##########################################
import tkMessageBox
import tkSimpleDialog
from Tkinter import *
import a
import string
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,a.myapp.name)
self.e2.insert(0,a.myapp.no)
def apply(self):
first = (self.e1.get()) #string.atoi
second = string.atoi(self.e2.get())
print first, second # or something
Let me know where i gone wrong and correct my
mistake.
Thanx
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
More information about the Python-list
mailing list