473,406 Members | 2,769 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,406 software developers and data experts.

tkinter how to write

as I write my first gui program (text editor) I wanna ask you guys how
to separate code in classes.?
Should I put in one class my menu and in another class text and
scorllbars etc?

or something else?
thanks
Mar 8 '07 #1
3 1193
On Mar 8, 7:07 pm, Gigs_ <g...@hi.t-com.hrwrote:
as I write my first gui program (text editor) I wanna ask you guys how
to separate code in classes.?
Should I put in one class my menu and in another class text and
scorllbars etc?

or something else?

thanks

Use the force. Do whatever feels most right. Remember that you can
always refactor.
A good rule of thumb for GUIs is MVC [a class or set of classes to
encapsulate the abstract relationships known as the Model, another
class or set of classes to handle translating changes to the model
into changes in the GUI aka View, and another class or set of classes
to encapsulate the Controlling of everything], but do not pursue this
to its extreme inanity as Java does. Follow guidelines only so long as
they clarify the code. The second you can no longer keep the overall
structure of the code in your head at once, hit control+z until you
can.

When I wrote my text editor, I wanted to keep everything in one class
because I thought it would be cleaner. Several thousand lines later, I
realized that the notion of a Tab is a significant and powerful
abstraction, as is the UndoStack and the entries in it [UndoEntry].
Right now, I'm thinking about separating all the menuitem callbacks
into their own class because they are different in kind from the
methods which encapsulate the Tabs, menubar, statusbar, etc. into an
application. The reason that I probably won't do this is that a class
is not for grouping methods, it's for representing objects.

UML is another expounded tool for achieving OOP zen before you set
fingertips to keyboard. i've never grokked it, but you should try it
at least once, if only so you can say that you have in a job interview.

Mar 8 '07 #2
Gigs_ wrote:
as I write my first gui program (text editor) I wanna ask you guys how
to separate code in classes.?
Should I put in one class my menu and in another class text and
scorllbars etc?

or something else?
thanks
Check out Grayson: http://www.manning.com/grayson/

Its $25 for the pdf and is worth about 20 or 30 times that in the effort
it will take you if you attempt to re-invent the wheel.

For an example of a Tkinter code disaster from not having a good
reference, glimpse at the source of <http://passerby.sf.net>.

How I wish I'd just read the damn book first!

James
Mar 8 '07 #3
James Stroud wrote:
Gigs_ wrote:
>as I write my first gui program (text editor) I wanna ask you guys how
to separate code in classes.?
Should I put in one class my menu and in another class text and
scorllbars etc?

or something else?
thanks

Check out Grayson: http://www.manning.com/grayson/

Its $25 for the pdf and is worth about 20 or 30 times that in the effort
it will take you if you attempt to re-invent the wheel.

For an example of a Tkinter code disaster from not having a good
reference, glimpse at the source of <http://passerby.sf.net>.

How I wish I'd just read the damn book first!

James
thx for both replies
Mar 8 '07 #4

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

Similar topics

0
by: Mark 'Kamikaze' Hughes | last post by:
In the new Python game I'm developing, I need to crop out individual tiles from larger tilesets, and maintain transparency. Unfortunately, I've run into major deficiencies in both Tkinter and PIL...
7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
7
by: Justin Ezequiel | last post by:
What font is Tkinter using for displaying utf-8 characters? On my Windows XP, most of the characters with names (unicodedata.name) are displayed WYSIWYG. However, on my Mandrake (warning: Linux...
1
by: Pekka Niiranen | last post by:
Hi there, after reading TkInter/thread -recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 I wondered if it was possible to avoid using threads for the following problem: ...
6
by: Richard Lewis | last post by:
Hi there, I've got a tree control in Tkinter (using the ESRF Tree module) but I can't get it to layout how I want it. I'd like to have it so that it streches north/south (anchored to the top...
3
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...
3
by: Jo Schambach | last post by:
I am trying to write a GUI with tkinter that displays the stdout from a regular C/C++ program in a text widget. The idea i was trying to use was as follows: 1) use "popen" to execute the C/C++...
1
by: yvesd | last post by:
hello i want to intercept tkinter python system events like wm_delete_window and if possible for any window, but the newest code I've produced give me an error : Traceback (most recent call...
32
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....
44
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.