PS: Since your starting with TKinter, and although I do not know what your goal is, I suggest you take a look at wxPython: it is _wonderfull_ ! (no offence to TCL/TK)
Regards, Philippe VK wrote: > Philippe C. Martin wrote: >> Hi, >> >> I think your second call to Tk() does it: this works although the look is >> different: >> >> >> from Tkinter import * >> class GetVariant: >> def __init__(self): >> self.root = Tk() >> self.mainframe = Frame(self.root,bg="yellow") >> self.mainframe.pack(fill=BOTH,expand=1) >> >> self.firstframe = Frame(self.mainframe,bg="red") >> self.firstframe.pack(side=BOTTOM,expand=1) >> >> global v >> v = StringVar() >> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >> 1", variable=v, value="Variant 1") >> self.radiobutton.pack(side=TOP,anchor=W) >> self.radiobutton.select() >> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >> 2", variable=v, value="Variant 2") >> self.radiobutton.pack(side=TOP,anchor=W) >> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >> 3", variable=v, value="Variant 3") >> self.radiobutton.pack(side=TOP,anchor=W) >> >> >> >> self.secondframe = Frame(self.mainframe,bg="blue") >> self.secondframe.pack() >> self.var = Button(self.secondframe,text="What >> Variant",command=self.call) >> self.var.pack(expand=1,side=BOTTOM) >> >> >> >> def call(self): >> self.variant = v.get() >> print 'Input => "%s"' % self.variant >> >> class OneButton: >> def __init__(self): >> self.root = Tk() >> Button(self.root,text="click me",command=self.getvar).pack() >> def getvar(self): >> a=GetVariant() >> >> d = OneButton() >> d.root.mainloop() >> >> >> >> >> VK wrote: >> >> >>>Hi! >>>What I'm missing in following code? Cannot get the values of >>>radiobuttons. Starting only one class (GetVariant), it works. When I put >>>two classes together, it doesn't. >>>Regards, VK >>> >>>from Tkinter import * >>>class GetVariant: >>> def __init__(self): >>> self.root = Tk() >>> self.mainframe = Frame(self.root,bg="yellow") >>> self.mainframe.pack(fill=BOTH,expand=1) >>> >>> self.firstframe = Frame(self.mainframe,bg="red") >>> self.firstframe.pack(side=BOTTOM,expand=1) >>> >>> global v >>> v = StringVar() >>> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >>>1", variable=v, value="Variant 1") >>> self.radiobutton.pack(side=TOP,anchor=W) >>> self.radiobutton.select() >>> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >>>2", variable=v, value="Variant 2") >>> self.radiobutton.pack(side=TOP,anchor=W) >>> self.radiobutton = Radiobutton(self.firstframe,text= "Variant >>>3", variable=v, value="Variant 3") >>> self.radiobutton.pack(side=TOP,anchor=W) >>> >>> >>> >>> self.secondframe = Frame(self.mainframe,bg="blue") >>> self.secondframe.pack() >>> self.var = Button(self.secondframe,text="What >>>Variant",command=self.call) >>> self.var.pack(expand=1,side=BOTTOM) >>> >>> >>> >>> def call(self): >>> self.variant = v.get() >>> print 'Input => "%s"' % self.variant >>> >>>class OneButton: >>> def __init__(self): >>> self.root = Tk() >>> Button(self.root,text="click me",command=self.getvar).pack() >>> def getvar(self): >>> a=GetVariant() >>> >>>d = OneButton() >>>d.root.mainloop() >> >> > > Sorry, but I don't get it. There is no deference between my code and > your answer. I'm beginner... -- http://mail.python.org/mailman/listinfo/python-list