By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

Question on creating Tkinter Widgets

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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.