473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2318
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 "megawidget s" 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*****@REMTHI Searthlink.net> wrote in message news:<jc******* **********@news read2.news.atl. earthlink.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(Tkinte r.Frame):
def __init__(self, master, special_attribu te='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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6999
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter import * class App:
3
2137
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I...
3
2217
by: William Gill | last post by:
Working with tkinter, I have a createWidgets() method in a class. Within createWidgets() I create several StringVars() and assign them to the textvariable option of several widgets. Effectively my code structure is: def createWidgets(self): ... var = StringVar() Entry(master,textvariable=var) ...
26
1881
by: Kevin Walzer | last post by:
....with a twist. I'm undertaking my first semi-substantial Python GUI application after a long time dabbling with the language. I'm fairly experienced with Tcl/Tk, so Tkinter seems the obvious choice to reduce my Python learning curve. However, my Tcl applications typically make use of a *lot* of extensions to the core widget set, such...
2
14825
by: python programming newb | last post by:
Hi all, first post. I'm new to python and tkinter. I'm trying to write a program that opens the root window with a button that then opens a toplevel window that then has it's own widgets. I can get the new toplevel window to open but none of the widgets appear. The console gives me: AttributeError: 'NewWindow' object has no attribute...
32
7442
by: Kevin Walzer | last post by:
I'm a Tcl/Tk developer who has been working, slowly, at learning Python, in part because Python has better support for certain kinds of applications that I want to develop than Tcl/Tk does. Naturally, I thought that I would use Tkinter as the GUI for these programs. However, in doing research into GUI development techniques, sample code, and...
2
5365
by: Ben Finney | last post by:
Howdy all, Python programmers looking for a built-in GUI toolkit are told two things: one, Python already comes with a GUI toolkit, and two, it looks equally ugly on all platforms. This is because the Tk widget library, that Tkinter uses, defaults to looking like Motif, which hasn't been the default widget set of *anything* for a long time....
1
4765
by: Ankit | last post by:
Hi guys i need to make a table to store a certain data using Tkinter..I have searched on the group but i have not been able to find a solution that would work for me..The thing is that i want my table to be scrollable both horizontally and vertically and i also want to transmit the data from the table serially to a microcontroller so i also...
3
3902
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By this I mean that the format would be something like this: You have Page1 : This has 2-3 buttons on it. Clicking on each button opens up a new...
0
7467
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5326
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.