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

wxPython Conventions

I've recently decided to try my hand at GUI programming with wxPython,
and I've got a couple questions about the general conventions regarding
it.

To mess around with it, I decided to create a small app to check my
Gmail. I want something that will just sit in my system tray checking
for new emails every ten minutes or so. As such, I have no need for an
actual window anywhere. So I'm wondering if I should still use a Frame
or not. From playing around with it, it seems it's unnecessary, but
I'm admittedly unfamiliar with what would be considered proper.

My other question involved the proper location of specific functions.
Take for instance the functions meant for logging in and actually
checking for new email. Would it be better to put them in my App
class, my Frame class (if the answer to the above question is that yes,
I should use a Frame regardless), or in an entirely separate class? To
me, it seems most natural to put them in the App class, but I'm not
sure if it would be better to avoid clutter and stick them somewhere
else. And if I would stick them in some other class, where should I
keep the reference to the instance of that class? In my App or Frame?

Like I said, I'm just beginning my experience with wxPython, so any
help would be appreciated. I've looked through all the demos and
searched the group, but nothing else seems to pertain to my specific
questions.

Jared

Jan 31 '06 #1
5 1403
I'm also fairly new to wxPython, but I've done GUI's in a variety of
languages. I'm not sure about putting the systray - haven't had to
do it. But your second question, put it in it's own class. For
desktop apps I almost allways do a limited M/V/C pattern - M/VC - ok so
I mung the view and controller together. Doing that made it easy for
me to replace tKinter with a newer wxGUI, and if a new toolkit comes
out - It'll be easy to move. Since I'm a newbie to wxPython - I've
keep having to change my event handling due to ignorant usage - when
making these mistakes, it's a lot easier to nuke and recreate a widget,
or event path if your data and functions are in separate classes. Now
as for attaching the class, I'm not sure how you've modelled your
software. Performace considerations are also a real factor - if
performance is not a driving factor, and the program is simple enough -
just let each widget have a reference to the objects it talks to.

Ie, I have a package named GMailAccount, which contains a
GMailAccountInformation class. Now when you create the widget for
getting this text, maybe a wx.Panel with a couple of textctrl, assign
the widget a GMailAccountInformation.

When performance starts to matter, probably want to go to some object
caching scheme in a model class, and have the widgets interface with
that - but now we're getting into a full M/V/C - and I haven't had to
do that yet in my playing with wx.

Hope this helps.

Jan 31 '06 #2
Jared Russell wrote:
My other question involved the proper location of specific functions.


Never mix business with plea^h^h^h^hGUI. I'd suggest that you write a
Python module with all your business logic that you can test from the
interactive interpreter. Roughly like this:
import gmailchecker
def show(text): .... print text
.... gmailchecker.login('username', 'password')
gmailchecker.check(show, 10)


When you build a GUI, you will pass in some bound
method of one of your widgets that will alert the
user instead of the show function above.

This approach makes your code much more useful. You
can use it in other contexts than a small GUI app,
you can swap GUI when you want that, and you can
easily write unit tests for your logic.
Feb 1 '06 #3

Jared Russell wrote:
To mess around with it, I decided to create a small app to check my
Gmail. I want something that will just sit in my system tray checking
for new emails every ten minutes or so.


How do you gain access to the system tray?

Iain

Feb 1 '06 #4

Iain King skrev:
How do you gain access to the system tray?


Use wx.TaskBarIcon.
See http://wiki.wxpython.org/index.cgi/FlashingTaskbarIcon for
snippets.

/Johan

Feb 1 '06 #5
Thanks for all the replies. I'm admittedly new to GUI programming, so
I'm making sure to read up on the MVC pattern and related things like
the observer pattern. I appreciate the help.

Jared

Feb 5 '06 #6

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

Similar topics

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...
15
by: Polerio Babao Jr.II | last post by:
Please correct me if im wrong. I have depended much on python and wxpython gui apps. After a year of using python apps I was able to do good application written entirely in python. One big problem...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
1
by: timothy.williams | last post by:
I'm trying to install wxPython 2.5.3.1 using Python 2.3.2 on a Fedora 2 machine. I have python in a non-standard place, but I'm using --prefix with the configure script to point to where I have...
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.0 release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this...
4
by: stef | last post by:
hello, I'm trying to move from Delphi to Python (move from MatLab to Python already succeeded, also thanks to this discussion group). From the discussions in this list about "the best" GUI for...
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...
16
by: Andrea Gavana | last post by:
Hi Diez & All, Do you mind explaining "why" you find it *buttugly*? I am asking just out of curiosity, obviously. I am so biased towards wxPython that I won't make any comment on this thread...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.