problem extending tkSimpleDialog.Dialog

William Gill noreply at gcgroup.net
Sat Aug 13 00:40:27 EDT 2005


Problem solved.  I was not properly passing the master widget reference 
in my frame classes

class MyWidget(Frame):
     def __init__(self, master, columns,rows, trace_write=None):
         Frame.__init__(self) #<<<< here's my mistake
     ...
     ...
     ...

should have been:

class MyWidget(Frame):
     def __init__(self, master, columns,rows, trace_write=None):
         Frame.__init__(self,master)
     ...
     ...
     ...


Bill

P.S.  I haven't been working on this since my last post.  I had to quit 
to go see my oldest graduate.

William Gill wrote:
> I have created a widget that extends Frame() and contains labels, 
> checkboxes, and entrys.  I am trying to use tkSimpleDialog.Dialog to 
> create a modal display of this widget, but am running into some 
> (addressing) problems.  My widget displays in the parent widget, not the 
> tkSimpleDialog.Dialog?  I hope this snippet is enough to help, as my 
> actual code is really too hard to follow.
> 
> class showtestWidget(tkSimpleDialog.Dialog):
>     def body(self,master):
>       Label(master,text="showPhoneNums").grid()
>       testWidget(self).grid()
> 
> class testWidget(Frame):
>     def __init__(self, master):
>       Frame.__init__(self)
>       self.createWidgets()
>     def createWidgets(self):
>       Label(self,text="testWidget").grid()
> 
> When the parent script instantiates showtestWidget() it should create a 
> transient dialog containing a label with the text "showPhoneNums".  It 
> does, but the label containing the text "testWidget" is being created in 
> the parent widget, not the dialog.
> 
> It seems obvious to me that I'm addressing the wrong parent somehow, 
> since the label (probably the testWidget) is being created, but in the 
> wrong place.
> 
> I tried changing   testWidget(self).grid() to testWidget(master).grid(), 
> just to see if that helped, but it made no difference.
> 
> Can someone show me where I went wrong?
> 
> Bill
> 
> 



More information about the Python-list mailing list