[Code Challenge] WxPython versus Tkinter.

R

rantingrick

WxPython Challenge 1 code updated...
  * Fixed tab traveral
  * Removed hand-holding code
  * Removed some cruft
Good luck!

Still doesn't fix the problem of the code not working on Linux boxes.
Maybe wxPython isn't the best option, it doesn't appear very cross-platform.
Still getting:

Loading Images:
  -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp
  -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp
  -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp
imageMap.keys -> ['folder', 'link', 'file']
Segmentation fault

Have you tried any debugging? Maybe Linux has some specific needs and
NOT wxPython. Stop jumping to conclusions.
 
R

rantingrick

Why not?

I'd understand if this code made use of some Tk extension, as that's not
quite an apples-to-apples comparison. But the treectrl is part of the
core Tkinter widget set.

Well wxPython ha a treectrl too. And if we were comparing apples to
apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl.
However there are many things that a ListCtrl can do that a treectrl
can't. The biggest difference.... COLUMNS
There's no reason to exclude it (Tk::TreeCtrl) unless you are
deliberately trying to handicap Tk in your comparison.

I am not handicapping TclTk. They already did that themselves by
refusing to keep up with 21st century GUI libraries. Sure, you can
say Tkinter is a knife and wxPython is an AK47 but who's to blame when
you bring a knife to gun fight Kevin? Switch to wx and enjoy the
bloodbath.
 
R

rantingrick

For something as common as displaying a file browser, it should be as
simple as this:
import gui_toolkit  # whichever
path = gui_toolkit.select_file()
Something like zenity:
[steve@sylar ~]$ zenity --file-selection
/home/steve/python/findsingle.py
And indeed, it is that simple:
python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()"

Brilliant!


No, that was even weaker than Guido's tag argument. At LEAST when
Guido parrots off minor issues he uses some fact based argument. This
is just pathetic! Only the lemmings would believe such nonsense.
Pity that it is so ugly under Linux :(

And who's fault is that i wonder?
 
C

Corey Richardson

For something as common as displaying a file browser, it should be as
simple as this:
import gui_toolkit # whichever
path = gui_toolkit.select_file()
Something like zenity:
[steve@sylar ~]$ zenity --file-selection
/home/steve/python/findsingle.py

And indeed, it is that simple:

python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()"


Martin the tkFileDialog.ask* uses the platform specific Open, Save
dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not
available to Tkinter uses. You just exposed your weak knowledge of
Tkinter and sadly you are very high on the community totem pole. Very
sad :(

Actually, the people on the top of the totem pole were of less social
status.
http://podcasts.howstuffworks.com/h...otem-poles.mp3?_kip_ipx=1723793795-1295833113

(Finally, useful knowledge from listening to podcasts in my off-time!)

You have also ignored that I gave the same information as him (minus the
traceback), saying that I am on Linux Mint 64bit.

Why can't we use a TreeCtrl? If we can't use all our widgets, why can
you use all yours?

~Corey
 
R

rantingrick

Why can't we use a TreeCtrl? If we can't use all our widgets, why can
you use all yours?

~Corey

Columns Corey, the key word here is "columns". One more
time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet
Corey?
 
C

Corey Richardson

Columns Corey, the key word here is "columns". One more
time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet
Corey?

I sent that email before you sent your email explaining why (responded
to Kevin), sorry that I can't see the future.
 
C

Corey Richardson

On Jan 22, 6:07 pm, rantingrick<[email protected]> wrote:
I await any challengers...
WxPython Challenge 1 code updated...
* Fixed tab traveral
* Removed hand-holding code
* Removed some cruft

Good luck!

Still doesn't fix the problem of the code not working on Linux boxes.
Maybe wxPython isn't the best option, it doesn't appear very cross-platform.
Still getting:

Loading Images:
-- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp
-- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp
-- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp
imageMap.keys -> ['folder', 'link', 'file']
Segmentation fault

Have you tried any debugging? Maybe Linux has some specific needs and
NOT wxPython. Stop jumping to conclusions.


Python (and supposedly wxPython) are cross-platform. Code that runs on
one should run on the other unmodified. This is obviously not the case.

Line 151 fails (determined from a simple binary search using print
statements):

index = self.InsertImageStringItem(sys.maxint, name, imageIdx)

Maybe wxPython (really wxwidgets, python doesn't throw segfaults...that
I've ever seen) isn't suited for the stdlib, unless this is a just a
really silly bug somewhere in your programming (which I doubt it is).
Looks like an issue with the method, because imageIdx is just a
dictionary, sys.maxint is a (surprise!) integer, and name is a string.
 
K

Kevin Walzer

Well wxPython ha a treectrl too. And if we were comparing apples to
apples then we would compare the wx.TreeCtrl to the Tk::TreeCtrl.
However there are many things that a ListCtrl can do that a treectrl
can't. The biggest difference.... COLUMNS

The ttk::treeview widget can also function as a multi-column listbox,
and can include both tree and multi-column listbox features in a single
window. It's a very flexible widget.
 
R

rantingrick

I sent that email before you sent your email explaining why (responded
to Kevin), sorry that I can't see the future.

Don't worry, I forgive you Corey. We can't *all* be visionaries ;-)
 
R

rantingrick

The ttk::treeview widget can also function as a multi-column listbox,
and can include both tree and multi-column listbox features in a single
window. It's a very flexible widget.

Can we see some working code? I would love to see some code Kevin. You
might satisfy the column requirement however you also need editable
labels and two veiw modes; reportview and listview. Actually it
sounds pretty much like a (wait for it...) TreeCtrl to me.

PS: Be sure not to cause any segfaults because these linux folks can't
debug for shite!
 
C

Corey Richardson

No, imageIdx is an integer.

You're right.
imageIdx = self.imageMap[iconname]

I confused imageIdx with self.imageMap. But that still doesn't fix my
problem, so before I go diving into the wxPython source, anyone have a
'quick fix'?
 
S

Steven D'Aprano

Columns Corey, the key word here is "columns". One more
time...COOOOOOLLLLLUUUMMMNNNSSSS. Is this starting to sink in yet Corey?

When I run the code snippet Martin provided under Linux, the file
selection box shows files in columns. That's part of the reason why I
consider it ugly -- I'm an old Mac guy, and I still dislike file
selection tools that use the Windows 95 style 2-D layout:


a-file e-file ...
b-file f-file y-file
c-file g-file z-file
d-file h-file


instead of a simple vertical list:

a-file
b-file
c-file
....
z-file


Call me a dinosaur if you will, but I hate horizontal scrolling.
 
C

Corey Richardson

CODE UPDATE:

* removed sys.maxint (not sure how it got there?)


https://sites.google.com/site/thefutureofpython/home/code-challenges

In the example at
http://www.wxpython.org/OSCON2004/advanced/wxPython-Advanced-OSCON2004.pdf
they use sys.maxint, which may be where you got it (wild shot in the dark!).

The following result in a segfault:
-------item-1---------------------
list_item = wx.ListItem()
list_item.SetId(idx)
list_item.SetText(name)
list_item.SetWidth(50)
index = self.InsertItem(list_item)
-----------end--------------------

------item-2----------------------
self.InsertStringItem(idx, name)
-----------end--------------------


The following will launch the application:
(drop in replacement for line 151):

index = self.SetStringItem(idx, 0, name)

No idea why, I've never used wxPython before today.
Unfortunately, it doesn't actually show the items in the directory.
Since I'm definitely not a wxPython user, would you mind making the
above work, rantingrick? Not trying to worm out of anything, but this
is way over my head.

~Corey
 
L

Littlefield, Tyler

PS: Be sure not to cause any segfaults because these linux folks can't
>debug for shite!
Or maybe it is that the person fighting and throwing insults around like
candy at a parade can't code for shite. Or *gasp* the library that is
supposedly cross-platform has issues on certain platforms. You provided
a challenge to show how superior wxPython was. If it segfaults, that
tells me that: 1) you can't code worth "shite," or 2) the library you
are drooling over sucks and shouldn't be cross-platform. Which is it? I
highly doubt there is a third option, but please feel free to tell me,
rather than insulting again.
 
R

rusi

 >PS: Be sure not to cause any segfaults because these linux folks can't
 >debug for shite!
Or maybe it is that the person fighting and throwing insults around like
candy at a parade can't code for shite. Or *gasp* the library that is
supposedly cross-platform has issues on certain platforms. You provided
a challenge to show how superior wxPython was. If it segfaults, that
tells me that: 1) you can't code worth "shite," or 2) the library you
are drooling over sucks and shouldn't be cross-platform. Which is it? I
highly doubt there is a third option, but please feel free to tell me,
rather than insulting again.

I think there is a third option
About rr's code-ing ability... this thread is long enough :)
Likewise if a certain library not in python standard distribution does
not work properly its the problem of the library.
But if python crashes its not good for the image of python.

Personal note 1: I am often teaching python with code I am seeing for
the first time -- typically something the class presents me which we
understand/debug/refactor together.
Usually I am not afraid of python because errors are helpful and
gentle.
Segfaulting on the other hand is the last thing I want to see in such
a context :)

Personal note 2: I dont regard myself as a gui programmer and Ive
often wondered which toolkit to demonstrate. I probably wont be
looking at wx now unless someone gives a convincing argument that the
segfault did not happen "inside" wx.

Of course as Steven pointed out wx is written in C++ which is almost
certainly where the crash is occurring.
But this is technical nitpicking.
The real issue is that when coding in C/C++ segfaults are a daily
affair.
Whereas for python its the first time I am seeing it in 10 years...
 
O

Octavian Rasnita

From: "Kevin Walzer said:
I found this code in the Demo/tkinter/ttk directory of the Python 2.7.1
source distribution. I'm NOT the author (credit should probably go to
Guilherme Polo, developer of the Tkinter wrapper for the ttk themed widgets
that is now in the stdlib). But, using a tree/listview widget that is part
of the Tk/Tkinter core (NOT an extension), it presents a decent, simple
file browser:


Well, I have also tested the program dirbrowser.py, but it is not decent at
all.
I have tested it with JAWS screen reader and it is absolutely inaccessible.

The single "accessible" things in it are the title bar which is "tk".
It can't compare with the same program made using WxPython.
And it can't be made to be more accessible than it is, because it uses Tk.

So Tkinter is really bad.

Octavian
 
O

Octavian Rasnita

From: "Kevin Walzer said:
The ttk::treeview widget can also function as a multi-column listbox, and
can include both tree and multi-column listbox features in a single
window. It's a very flexible widget.


But unfortunately it is not accessible for screen readers and it
discriminates many potential users.

Octavian
 
O

Octavian Rasnita

From: "Littlefield said:
Or maybe it is that the person fighting and throwing insults around like
candy at a parade can't code for shite. Or *gasp* the library that is
supposedly cross-platform has issues on certain platforms. You provided a
challenge to show how superior wxPython was. If it segfaults, that tells
me that: 1) you can't code worth "shite," or 2) the library you are
drooling over sucks and shouldn't be cross-platform. Which is it? I highly
doubt there is a third option, but please feel free to tell me, rather
than insulting again.


Hi Tyler,

Are you able to use Tkinter-based applications under Windows?
Or you have started to use Linux and now you don't care about the majority
of users that need to use a screen reader?

Octavian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top