469,585 Members | 2,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,585 developers. It's quick & easy.

Question on creating Tkinter Widgets

I am creating some widgets by inheriting from Tkinter.Frame and populating
the frame with whatever the widget will be then creating certain
attributes/methods to be accessed later. My question is, is this a poper way
to create widgets or should I take a different approach?

Any help is greatly appreciated.

Adonis
Jul 18 '05 #1
2 2095
Adonis wrote:
I am creating some widgets by inheriting from Tkinter.Frame and populating
the frame with whatever the widget will be then creating certain
attributes/methods to be accessed later. My question is, is this a poper way
to create widgets or should I take a different approach?

Any help is greatly appreciated.

Adonis


Most Tkinter "megawidgets" are created by either specializing Tkinter.Frame or
Tkinter.Canvas, so it seems to be the way to go. It has at least a major
advantage: the widgets you create directly inherit the basic behaviour of all
Tkinter widgets, so you can directly pack them, grid them, or whatever else,
without having a single line of code to write. I made some Tkinter widgets
myself and always used this approach; up to this time, it worked pretty well.

HTH
--
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #2
"Adonis" <ad*****@REMTHISearthlink.net> wrote in message news:<jc*****************@newsread2.news.atl.earth link.net>...
I am creating some widgets by inheriting from Tkinter.Frame and populating
the frame with whatever the widget will be then creating certain
attributes/methods to be accessed later. My question is, is this a poper way
to create widgets or should I take a different approach?

Any help is greatly appreciated.

Adonis


So far this sounds perfectly "proper" to me.
Usually when I create my own widgets it looks like:

class Mywidget(Tkinter.Frame):
def __init__(self, master, special_attribute='default', *args, **kw):
Tkinter.Frame.__init__(self, master, *args, **kw)
<widget's contents......>

def widget_method1(self):
<.......>

(etc.)

Sounds like you are doing quite the same.

Regards

Michael
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by srijit | last post: by
3 posts views Thread by Matt Hammond | last post: by
3 posts views Thread by William Gill | last post: by
26 posts views Thread by Kevin Walzer | last post: by
2 posts views Thread by python programming newb | last post: by
2 posts views Thread by Ben Finney | last post: by
1 post views Thread by Ankit | last post: by
3 posts views Thread by J-Burns | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.