problem extending tkSimpleDialog.Dialog

W

William Gill

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
 
W

William Gill

I'm still hammering away, and have found that when I change:

class testWidget(Frame):
def __init__(self, master):
Frame.__init__(self)
self.createWidgets()
def createWidgets(self):
Label(self,text="testWidget").grid()
to:
def __init__(self, master):
Frame.__init__(self)
self.x=master
self.createWidgets()
def createWidgets(self):
Label(self.x,text="testWidget").grid()

It seems to work correctly. However my actual widget, an extended Frame
widget, still doesn't work correctly. This seems to confirm what I
thought about addressing the correct parent, but I still haven't figured
it out completely.

Unless someone can give me a clue, I guess I can keep modifying
testWidget(Frame) to add the components of my original until I can see
where it breaks down. On the surface it looks like I'm not passing the
correct master reference to my frame.

Bill
 
W

William Gill

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top