473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

problem extending tkSimpleDialog.Dialog

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
Aug 12 '05 #1
2 2492
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
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

Aug 12 '05 #2
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

Aug 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Miki Tebeka | last post by:
Hello All, The following script "hangs" on win32 system: from Tkinter import * from tkSimpleDialog import askstring root = Tk() root.withdraw() # <<< Problem here askstring("Yap", "What's...
1
by: John | last post by:
Hello, Is it possible to modify the print dialog box that appears when a user clicks File->Print? Is it possible to make this modification so that all Windows programs use the modified print...
2
by: Stuart | last post by:
I'm looking to implement a Standard File Open Dialog, and put a little File Preview segment onto the dialog. Unfortunately it's not as straightforward as just inheriting a regular file open dialog...
4
by: rajendra | last post by:
how to extend existing windows forms control like if i want to add new add method to combo box ,how to go abt. it? can anyone help me abt. this
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
0
by: Gheorghe Postelnicu | last post by:
Hi, I am using Python to develop a front-end GUI using Tk. I would need to use some of the tkSimpleDialog widgets, but they seem to fail. As far as I could tell, this happens because my...
8
rhitam30111985
by: rhitam30111985 | last post by:
hi all.. python noob here.. i am creating a GUI for an applcation... now i was just testing the working of askstring : from tkSimpleDialog import askstring string=askstring('site','enter site:')...
5
by: msunderwd | last post by:
Having a problem with "compiling" a Tkinter/python program using py2exe (and pyinstaller, for that matter)... I have several dialogs that are derived from the tkSimpleDialog.Dialog class. These...
2
by: WP | last post by:
Hello, I making and Windows Forms program and I have a dialog with two buttons. I have set the DialogResult property for these buttons to DialogResult.OK and DialogResult.No, respectively (however,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.