473,756 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Evil, evil wxPython (and a glimmer of hope)

I rarely do GUIs, and reminded myself today why that is the case
(simply, it's not fun).

I implemented a simple TreeCtrl, and had to implement my own 'children'
method, of all things!

Here it is:

def children(self,n ode):
c = []
nc,cookie = self.GetFirstCh ild(node)
while 1:
info = self.GetItemTex t(nc)
c.append((info, nc))

nc, cookie= self.GetNextChi ld(node,cookie)
if not nc.IsOk():
break

return c
And it even fails with zero children. This is as unpythonic as it gets.

However, it should be pretty easy to write small wrapper over the
wxPython api. I'm thinking of wrapping or injecting additional methods
to TreeCtrl that start with lowercase letters and return something
sensible, with reasonable methods. Something like:

root = self.AddRoot("r oot dir") # root is normal wx TreeCtrl root
tree = EasyWx(root) # now tree is our wrapped, more "fun" root
for c in tree.children() :
print c.name

# etc. etc.

This is a bit like Brian Orendorff's "path" module that turns something
low level to something you can use easily, without throwing you into a
world of "frameworks ", toolkits and whatnot. I can see there are things
like Wax or PythonCard, but they are still too "frameworky ", and you
don't use them to extend wxPython, you use *them* and they use
wxPython. I'd basically like to rely on something that is there for the
long haul (plain wxPython API) but only use convenience wrappers *on my
own initiative*, as it seems convenient. Just like I'd use the "path"
module.

wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
basic design is ok & proven, I'm just too lazy to use it in its current
form.

Feb 16 '06 #1
12 1855
As you just said, wxPython is "...(a simple wrapper for a C++
toolkit)": it is
oriented toward the C++ style/mindset.

Feb 16 '06 #2

vi******@gmail. com wrote:
I rarely do GUIs, and reminded myself today why that is the case
(simply, it's not fun).

I implemented a simple TreeCtrl, and had to implement my own 'children'
method, of all things!

Here it is:

def children(self,n ode):
c = []
nc,cookie = self.GetFirstCh ild(node)
while 1:
info = self.GetItemTex t(nc)
c.append((info, nc))

nc, cookie= self.GetNextChi ld(node,cookie)
if not nc.IsOk():
break

return c
And it even fails with zero children. This is as unpythonic as it gets.

However, it should be pretty easy to write small wrapper over the
wxPython api. I'm thinking of wrapping or injecting additional methods
to TreeCtrl that start with lowercase letters and return something
sensible, with reasonable methods. Something like:

root = self.AddRoot("r oot dir") # root is normal wx TreeCtrl root
tree = EasyWx(root) # now tree is our wrapped, more "fun" root
for c in tree.children() :
print c.name

# etc. etc.

This is a bit like Brian Orendorff's "path" module that turns something
low level to something you can use easily, without throwing you into a
world of "frameworks ", toolkits and whatnot. I can see there are things
like Wax or PythonCard, but they are still too "frameworky ", and you
don't use them to extend wxPython, you use *them* and they use
wxPython. I'd basically like to rely on something that is there for the
long haul (plain wxPython API) but only use convenience wrappers *on my
own initiative*, as it seems convenient. Just like I'd use the "path"
module.

wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
basic design is ok & proven, I'm just too lazy to use it in its current
form.


Take a look at dabo, II think they're doing exactly what you're
describing.
http://blog.dabodev.com/

Feb 16 '06 #3
snoe wrote:
Take a look at dabo, II think they're doing exactly what you're
describing.
http://blog.dabodev.com/


Dabo appear to be doing way more than what I want, with database access
etc.

My ideal module, when implemented, would be extremely small as far as
the size of code goes. I'm using path.py as an example:

http://www.jorendorff.com/articles/python/path/path.py

def dirs(self, pattern=None):
""" D.dirs() -> List of this directory's subdirectories.
"""
return [p for p in self.listdir(pa ttern) if p.isdir()]

Feb 16 '06 #4
"vi******@gmail .com" <vi******@gmail .com> writes:
I rarely do GUIs, and reminded myself today why that is the case
(simply, it's not fun).
Programming C++ in Python isn't much fun, true.
However, it should be pretty easy to write small wrapper over the
wxPython api.
[...]
wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
basic design is ok & proven, I'm just too lazy to use it in its current
form.


Fortunately, you're not alone in that thought. The wxPython project's
explicit goal is to make wxPython feel as much like wxWidgets as
feasible.

For those that want wxPython to feel more like Python than C++, Hans
Nowak started the 'wax' wrapper:

"Simply put, Wax is a GUI toolkit. It sits on top of wxPython,
removing some of the low-level aspects of that GUI, and adding
some useful abstractions.

The goal is that Wax should be easier to use than wxPython, but
just as feature-rich. Maybe even more so.

The actual situation is different. Frankly, I don't have the time
to work on this project very much. That's why I only add new
features when I need them. Some of my other projects (Firedrop,
Sourcery, etc) use Wax, so over time, when I need more controls, I
add them. On the other hand, a subset of controls is there, and is
usable."

<URL:http://zephyrfalcon.or g/labs/dope_on_wax.htm l>
<URL:http://zephyrfalcon.or g/labs/wax.html>

The web content is a bit sparse; fortunately the code has seen more
love than the web pages. Wax was the focus of a couple of Google
"Summer of Code" projects, and new life seems to have been gained as a
result.

--
\ "We are not gonna be great; we are not gonna be amazing; we are |
`\ gonna be *amazingly* amazing!" -- Zaphod Beeblebrox, _The |
_o__) Hitch-Hiker's Guide To The Galaxy_, Douglas Adams |
Ben Finney <http://www.benfinney.i d.au/>
Feb 17 '06 #5
Ben Finney wrote:
The web content is a bit sparse; fortunately the code has seen more
love than the web pages. Wax was the focus of a couple of Google
"Summer of Code" projects, and new life seems to have been gained as a
result.


I'm glad to hear that, however, I just took a look at the mailing list:

http://sourceforge.net/mailarchive/f...forum_id=44351

"""
I am going to take a break from blogging and my personal
projects. This includes Wax. In other words, Wax development will be
on hold for a while. During this time, I might still address urgent
bugs and such, but I don't plan to add new features.
"""

Things like this raise a bit of concern about the survivability of the
project. I wouldn't mind if it was a relatively independent component
but it *is* one that is heavily dependent on wxPython...

Also, I have some issues with the design (I don't know how misguided
they may in fact be, as you can see I'm a complete wx newbie). I'd like
the wax classes to be mixins instead of superclasses, so I could just
add them to the inheritance hierarchy if I needed the features... then,
if wax suddenly went belly-up, I could just remove the mixins and
reimplement the parts that use those, yielding a plain wxpython app.
The method names, also, could be more_pythonic() so I could easily tell
wax stuff from wx stuff. This would be insane if we were talking about
a "standard" windowing system of some kind, but we have to recognize
that we are dealing with volatile third party code here.

Feb 17 '06 #6
vi******@gmail. com wrote:
Ben Finney wrote:
The web content is a bit sparse; fortunately the code has seen more
love than the web pages. Wax was the focus of a couple of Google
"Summer of Code" projects, and new life seems to have been gained as a
result.


I'm glad to hear that, however, I just took a look at the mailing list:

http://sourceforge.net/mailarchive/f...forum_id=44351

"""
I am going to take a break from blogging and my personal
projects. This includes Wax. In other words, Wax development will be
on hold for a while. During this time, I might still address urgent
bugs and such, but I don't plan to add new features.
"""

Things like this raise a bit of concern about the survivability of the
project. I wouldn't mind if it was a relatively independent component
but it *is* one that is heavily dependent on wxPython...


Wax is certainly currently usable and not at all unstable. It has a
small userbase, but it is used. I'm about to start a couple of projects
with it.

The code is relatively simple - so it would be easy to maintain the
parts you use if that was necessary. Certainly easier than duplicating
it yourself from scratch. :-)

Once you start using Wax, it really is simple and friendly.

All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Feb 17 '06 #7
Fuzzyman wrote:
The code is relatively simple - so it would be easy to maintain the
parts you use if that was necessary. Certainly easier than duplicating
it yourself from scratch. :-)


Sounds convincing, I'll give it a shot after all.

Feb 17 '06 #8
On 16 Feb 2006 14:07:36 -0800, vi******@gmail. com <vi******@gmail .com> wrote:
snoe wrote:
Take a look at dabo, II think they're doing exactly what you're
describing.
http://blog.dabodev.com/


Dabo appear to be doing way more than what I want, with database access
etc.


That was my first impression, too, but I tried it anyway. Turns out
that you can easily use just the dabo.ui module without ever having to
work with the database stuff.

--

# p.d.
Feb 17 '06 #9
vi******@gmail. com wrote:
Fuzzyman wrote:
The code is relatively simple - so it would be easy to maintain the
parts you use if that was necessary. Certainly easier than duplicating
it yourself from scratch. :-)


Sounds convincing, I'll give it a shot after all.


Ok, after brief eyeballing & experimenting, it appears that Wax is just
what I was looking for. The code is simple, concise and trivially
understandable, the level of wrapping seems about right, and examples
are helpful.

I'm glad I came whining about this in c.l.py instead of sucking it up
or switching toolkits altogether. :-)

Feb 17 '06 #10

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

Similar topics

15
2910
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems to be more low-level than the other GUI toolkits I've used (Tk, GTK, and Trestle), and there are all sorts exposed details in wxWindows/wxPython that I find weird.
25
3355
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 Python GUI toolkit is that Tkinter was there first." - Guido van Rossum Guess, that answers my question, but isn't "Tkinter was there first" a very bad answer? :) It is kinda ugly too, so I wonder why it can't be replaced? Or maybe another GUI...
12
6496
by: Simon John | last post by:
I'm writing my 2nd large wxPython program, and after the problems I found doing the first's layout in code, I'd like to look at using a 'WYSIWYG' IDE, like VisualStudio does for MFC. I've tried a few that I found, wxGlade is probably the best, although it seems to be not 100% WYSIWYG (like the widgets in the preview are not much like the final program), wxDesigner has a horrid GUI for a GUI designer! VisualWX gave me the 'now what?'...
3
1727
by: writeson | last post by:
Hi all, I'm trying to use wxPython from a fairly new installation of Fedora Core 5. I installed wxPython using yum -y install wxPython and that all seemed to work fine. However, when I run Python and do this: import wx I get this:
4
1416
by: Jive Dadson | last post by:
I hope someone can help me with a couple of wxPython questions, or point me to the right newsgroup for the questions. I am trying to modify the floatcanvas demo program. I want to load an image from a file (jpg or whatever), then do a kind of color-picker action on it. I haven't tried yet to figure out how to load the file. Just for starters, when I click on the canvas, I want to get the rgb pixel value for the point under the...
6
1842
by: BartlebyScrivener | last post by:
If there is a wxPython on Debian user in the house? I am using the version of the demo that came with the apt-get download of wxPython. I thought I'd followed the instructions for installing and unpacking the wxPython demo program. It appears to run after a fashion, but I also get this at the commandline. Any help much appreciated. (python:5865): Gtk-CRITICAL **: gtk_window_realize_icon: assertion
1
1749
by: Benjamin | last post by:
Hello! I am writing a search engine with wxPython as the GUI. As the search thread returns items, it adds them to a Queue which is picked up by the main GUI thread calling itself recursively with wx.CallAfter. These are then added to a ListCtrl. This works fine for small searches, but with larger and longer searchs the GUI is clogged and won't respond. I suspect (I may be wrong) that there are so many results being sent to the ListCtrl...
2
1190
by: ahlongxp | last post by:
Sorry, I know this is not the most appropriate place to talk about wxPython. But I can't have access to wxPython mail list page(because I don't pay enough). I downloaded python2.5 and wxPython 2.8.4.0 from pythonmac.org and installed them into one of my friends' Mac 10.4.8(intel) and I found wx.lib.flatnotebook and wx.xrc were broken(which are quite OK under both Linux and Windows).
1
1848
by: codemania | last post by:
Disappointing me extremely, with the "generate python" function within Resource Editor, I only get a segment of python code which load xrc(xml format) file, rather than real python code in which I could append my own code. Does that mean RE(Resource Editor) is of little use? I hope not, maybe the way I use it is wrong? Tell me please.
0
9455
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5140
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.