[Code Challenge] WxPython versus Tkinter.

A

Adam Skutt

Well then post a traceback.

None of these issues will supply a traceback; in fact, in some of
these cases, you went out of your way to ensure that would not
happen. That's an additional bug (or 5 additional bugs depending how
mean your tester/QA staff are).
 However you still miss the point. You will do anything to distract
from the point. And what IS that point? Well that Tkinter is
lackluster 20 years old rotware

The fact it doesn't provide a control found almost exclusively in file
browsers and open/save dialogs does not mean that it is "20 years old
rotware".
and you need to resort to these BS tactics to discredit me because 1). You cannot even create a Tkinter
GUI at the basic level,

I certainly can, but there's no point in demonstrating my skill when
you cannot create a wxWidgets GUI at a basic level. You made the
challenge, you intentionally styled it as "rantingrick v. the world",
so you need to actually bring something challenge worthy to the table
first.

That includes picking a challenge that's interesting and not over a
relatively minor widget in the grand scheme of things. Qt, Swing,
Gtk, and Win32 common controls[1] don't provide the same exact control
either, should we view it as deficient?

But regardless of the challenge, I don't think you're capable of
posting a worthwhile example, which is why you dismiss all the
problems found with it instead of actually fixing the code.
Post CODE Adam. Code! Surely you can handle copy/pasting a traceback i
hope!

I certainly can. I don't have much hope for you writing code that
provides tracebacks, much less actually useful ones.

Adam

[1] Hell, I'm not sure /any/ toolkit provides the whole of wxListCtrl
functionality OOB, besides wxWidgets itself. Like I said, it's
specific functionality isn't well suited.
 
R

rantingrick

None of these issues will supply a traceback; in fact, in some of
these cases, you went out of your way to ensure that would not
happen.  

psst: thats because they are FEATURES and NOT BUGS you idiot! I am not
trying to create a working file browser so you can steal my code. No.
I am displaying one use case for a very useful widget. I repeat, i am
not going to code up a free file browser for you Adam. Get a life!
The fact it doesn't provide a control found almost exclusively in file
browsers and open/save dialogs does not mean that it is "20 years old
rotware".

A ListCtrl is useful for many, many purposes. Just one of them happens
to be a file browser. Your statement comes as no great surprise to us
because we all know how you severely lack any kind of vision or
abstract reasoning abilities.
I certainly can, but there's no point in demonstrating my skill when
you cannot create a wxWidgets GUI at a basic level.

BS. You're scared, You're under qualified. And it shows. BIGTIME!
 You made the
challenge, you intentionally styled it as "rantingrick v. the world",
so you need to actually bring something challenge worthy to the table
first.

Where is the world Adam? I am the only one who has summited code.

That includes picking a challenge that's interesting and not over a
relatively minor widget in the grand scheme of things.

ListCtrl's are very useful. And i have many more challenges coming.
WxPython outshines all the competition by leaps and bounds. The
ListCtrl is just the beginning.
 Qt, Swing,
Gtk, and Win32 common controls[1] don't provide the same exact control
either, should we view it as deficient?
Yes.

But regardless of the challenge,

You keep trying to divert attention from the point. Sorry but you're
not going to fool anyone with this foolishness.
I don't think you're capable of
posting a worthwhile example, which is why you dismiss all the
problems found with it instead of actually fixing the code.

Ditto! But at least i have some code to work with. Something to create
a fact based argument from. You have nothing but your own foolishness
to build from.
I certainly can.  I don't have much hope for you writing code that
provides tracebacks, much less actually useful ones.

I suppose you gauge the quality of code by how many tracebacks are
printed. And it seems even more perverse that you expect code to spit
exceptions! And when code fails to spit exceptions you get angry about
it and claim the programmer is insufficient. Hmm, this would explain
why you have yet to provide us with working (or even semi-working)
code. Adam you are by far the most foolish person i have ever met.
 
L

Littlefield, Tyler

RR,
I have not seen anything useful from you thus far, except:
1) "you disagree with me, troll you must be,"
"2) who cares if my programs have bugs and don't compile cross-platform,
defective code is code, none the less.
3) And a lot of unfounded arrogance in stating that no one understands
Tkinter quite like yourself and a select handful of people.

I hardly think that your tone, attitude and arguments are going to help
you in your battle to prove that WXPython is superior to anything at
all, if you can't manage to provide cross-platform bug-free code. No, no
one else has yet provided code in this thread from what I have seen,
since that's the point you keep making time and time again in numerous
messages that keep cluttering my inbox, but no one really has to. You
are making an argument with a lot of anger and faulty code, which is
supposed to prove that the library, in which you can't write an
application that is bug free (or as bug free as any program can be) and
also maintain the cross-platform goal, which is a huge part of Python
currently, is superior to another that you are screaming and throwing
tantrums over. So I await your response, though my psychic powers tells
me the response will be one of silence, "stfu, you're just a troll," or
"where's the code, I'm not going to produce bug-free code so you can rip
off -my- top security amazing file browser," since such things don't
already exist anyway.
None of these issues will supply a traceback; in fact, in some of
these cases, you went out of your way to ensure that would not
happen.
psst: thats because they are FEATURES and NOT BUGS you idiot! I am not
trying to create a working file browser so you can steal my code. No.
I am displaying one use case for a very useful widget. I repeat, i am
not going to code up a free file browser for you Adam. Get a life!
The fact it doesn't provide a control found almost exclusively in file
browsers and open/save dialogs does not mean that it is "20 years old
rotware".
A ListCtrl is useful for many, many purposes. Just one of them happens
to be a file browser. Your statement comes as no great surprise to us
because we all know how you severely lack any kind of vision or
abstract reasoning abilities.
I certainly can, but there's no point in demonstrating my skill when
you cannot create a wxWidgets GUI at a basic level.
BS. You're scared, You're under qualified. And it shows. BIGTIME!
You made the
challenge, you intentionally styled it as "rantingrick v. the world",
so you need to actually bring something challenge worthy to the table
first.
Where is the world Adam? I am the only one who has summited code.

That includes picking a challenge that's interesting and not over a
relatively minor widget in the grand scheme of things.
ListCtrl's are very useful. And i have many more challenges coming.
WxPython outshines all the competition by leaps and bounds. The
ListCtrl is just the beginning.
Qt, Swing,
Gtk, and Win32 common controls[1] don't provide the same exact control
either, should we view it as deficient? Yes.

But regardless of the challenge,
You keep trying to divert attention from the point. Sorry but you're
not going to fool anyone with this foolishness.
I don't think you're capable of
posting a worthwhile example, which is why you dismiss all the
problems found with it instead of actually fixing the code.
Ditto! But at least i have some code to work with. Something to create
a fact based argument from. You have nothing but your own foolishness
to build from.
I certainly can. I don't have much hope for you writing code that
provides tracebacks, much less actually useful ones.
I suppose you gauge the quality of code by how many tracebacks are
printed. And it seems even more perverse that you expect code to spit
exceptions! And when code fails to spit exceptions you get angry about
it and claim the programmer is insufficient. Hmm, this would explain
why you have yet to provide us with working (or even semi-working)
code. Adam you are by far the most foolish person i have ever met.
 
A

Adam Skutt

psst: thats because they are FEATURES and NOT BUGS you idiot!

Your application not displaying a directory listing, due to one of
these "features", is desirable behavior? I think not. Your
application hanging, due to one of these "features" is desirable
behavior? I think not, nor do the wxWidgets, Qt, Swing, Cocoa, Gtk,
Win32, et al. toolkit developers.
I am not trying to create a working file browser so you can steal my code..

I have ethics, morals, and standards, all of which forbid me from
stealing anything you write.
I am displaying one use case for a very useful widget.

So useful that you've only found one toolkit that provides it OOB!
A ListCtrl is useful for many, many purposes. Just one of them happens
to be a file browser.

The specific functionality the wxWidgets ListCtrl has over its
alternatives in other toolkits is only really seen in file browsers.
Your challenge explicitly relies on making use of that functionality
and in no way, shape, or form illustrates the general utility of a
wxListCtrl.

When you amend the challenge, you can make the claim it's not about
wxListCtrl's unique functionality.
Qt, Swing,
Gtk, and Win32 common controls[1] don't provide the same exact control
either, should we view it as deficient?

Funny, given that the original purpose of wxWidgets was to provide a
cross-platform MFC wrapper, I think you're in the minority of thought
among those developers, to say nothing of developers in general.
I suppose you gauge the quality of code by how many tracebacks are
printed. And it seems even more perverse that you expect code to spit
exceptions!

You're the one who asked for them originally, not I. I merely posited
that since you provided code that prints no tracebacks and expected
them (i.e., what you expect your code to do and what it does are two
different things), that it is highly unlikely you're capable of
providing me code that actually prints tracebacks, much less
tracebacks that assist you in debugging.

Put plainly, you have no clue whatsoever what your code actually does
or how it accomplishes it, which is exactly what we'd expect.

Adam
 
R

rantingrick

if you can't manage to provide cross-platform bug-free code.

No one has posted even one traceback Tyler (including yourself!). And
until they do i will assume that my code is bug free. I know it to be
bug free on windows. If and when someone *actually* provides proof
(supported by a traceback) then i will take them seriously.
 
C

Corey Richardson

No one has posted even one traceback Tyler (including yourself!). And
until they do i will assume that my code is bug free. I know it to be
bug free on windows. If and when someone *actually* provides proof
(supported by a traceback) then i will take them seriously.


There are more types of bugs than syntax errors, which are one of the
only types of bug that raise exceptions in Python. Try looking at [1] or
[2].

Here is the output on my system (Linux Mint 64bit):

/home/corey/Downloads/Wx_Tk_Challenge/Bitmaps
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
['folder', 'link', 'file']
Segmentation fault



[1] http://en.wikipedia.org/wiki/Software_bug#Common_types_of_computer_bugs
[2] http://msdn.microsoft.com/en-us/library/s9ek7a19(v=vs.80).aspx
 
S

Steven D'Aprano

I am not
trying to create a working file browser so you can steal my code.

Dammit! There goes my brilliant idea for getting rich.

Step 1: Start company.
Step 2: Steal working file browser from Internet.
Step 4: Profit!



I think rantingrick's comment inadvertently shows in a nutshell
everything wrong with this thread and why there is so little interest in
his proposal. If RR is right about the GUI toolkit making or breaking the
entire Python community, there should be hundreds of people with an
opinion, not just a handful.

(1) rantingrick is willing to spend *hours* brow-beating people,
insulting them, and cajoling them into doing things *his* way, supposedly
because of his deep concern for the Python community, but isn't willing
to donate a lousy *file browser* to the community.

(2) GUI programming is TOO DAMN HARD, and until that fact is addressed,
it's difficult for the majority of people to care whether the toolkit
used (or, more likely, not used at all) is Tkinter, or wxPython, or
something else.

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


Of course there are times when you need to do more complicated things,
and a decent toolkit should allow you to do so. But simple things should
be simple, and as far as I can see, there are no GUI toolkits that make
*anything* simple.
 
K

Kevin Walzer

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:

"""A directory browser using Ttk Treeview.

Based on the demo found in Tk 8.5 library/demos/browse
"""
import os
import glob
import Tkinter
import ttk

def populate_tree(tree, node):
if tree.set(node, "type") != 'directory':
return

path = tree.set(node, "fullpath")
tree.delete(*tree.get_children(node))

parent = tree.parent(node)
special_dirs = [] if parent else glob.glob('.') + glob.glob('..')

for p in special_dirs + os.listdir(path):
ptype = None
p = os.path.join(path, p).replace('\\', '/')
if os.path.isdir(p): ptype = "directory"
elif os.path.isfile(p): ptype = "file"

fname = os.path.split(p)[1]
id = tree.insert(node, "end", text=fname, values=[p, ptype])

if ptype == 'directory':
if fname not in ('.', '..'):
tree.insert(id, 0, text="dummy")
tree.item(id, text=fname)
elif ptype == 'file':
size = os.stat(p).st_size
tree.set(id, "size", "%d bytes" % size)


def populate_roots(tree):
dir = os.path.abspath('.').replace('\\', '/')
node = tree.insert('', 'end', text=dir, values=[dir, "directory"])
populate_tree(tree, node)

def update_tree(event):
tree = event.widget
populate_tree(tree, tree.focus())

def change_dir(event):
tree = event.widget
node = tree.focus()
if tree.parent(node):
path = os.path.abspath(tree.set(node, "fullpath"))
if os.path.isdir(path):
os.chdir(path)
tree.delete(tree.get_children(''))
populate_roots(tree)

def autoscroll(sbar, first, last):
"""Hide and show scrollbar as needed."""
first, last = float(first), float(last)
if first <= 0 and last >= 1:
sbar.grid_remove()
else:
sbar.grid()
sbar.set(first, last)

root = Tkinter.Tk()

vsb = ttk.Scrollbar(orient="vertical")
hsb = ttk.Scrollbar(orient="horizontal")

tree = ttk.Treeview(columns=("fullpath", "type", "size"),
displaycolumns="size", yscrollcommand=lambda f, l: autoscroll(vsb,
f, l),
xscrollcommand=lambda f, l:autoscroll(hsb, f, l))

vsb['command'] = tree.yview
hsb['command'] = tree.xview

tree.heading("#0", text="Directory Structure", anchor='w')
tree.heading("size", text="File Size", anchor='w')
tree.column("size", stretch=0, width=100)

populate_roots(tree)
tree.bind('<<TreeviewOpen>>', update_tree)
tree.bind('<Double-Button-1>', change_dir)

# Arrange the tree and its scrollbars in the toplevel
tree.grid(column=0, row=0, sticky='nswe')
vsb.grid(column=1, row=0, sticky='ns')
hsb.grid(column=0, row=1, sticky='ew')
root.grid_columnconfigure(0, weight=1)
root.grid_rowconfigure(0, weight=1)

root.mainloop()
 
M

Martin v. Loewis

Segmentation fault
[Actually this is the first time in my 10 years of python that Ive
seen a pure python module segfault :) ]

Congratulations genius! However if you are really smart you would have
read the note in the source that says "tested on windows only!".
Segfault. Thanks for the laugh!

I get the same:

/tmp/Wx_Tk_Challenge/Bitmaps
Loading Images:
-- /tmp/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp
-- /tmp/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp
-- /tmp/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp
['folder', 'link', 'file']
Speicherzugriffsfehler

Since you are asking for a traceback, here is one:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) () from
/usr/lib/libwx_gtk2u_core-2.6.so.0
(gdb) bt
#0 0x00007ffff554c8cd in wxListMainWindow::InsertItem(wxListItem&) ()
from /usr/lib/libwx_gtk2u_core-2.6.so.0
#1 0x00007ffff554c940 in wxGenericListCtrl::InsertItem(wxListItem&) ()
from /usr/lib/libwx_gtk2u_core-2.6.so.0
#2 0x00007ffff554f012 in wxGenericListCtrl::InsertItem(long, wxString
const&, int) () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#3 0x00007fffee58c460 in ?? () from
/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode/wx/_controls_.so
#4 0x00000000004a794b in PyEval_EvalFrameEx ()
#5 0x00000000004a95c1 in PyEval_EvalCodeEx ()
#6 0x00000000004a7752 in PyEval_EvalFrameEx ()
#7 0x00000000004a84a0 in PyEval_EvalFrameEx ()
#8 0x00000000004a95c1 in PyEval_EvalCodeEx ()
#9 0x0000000000538b0d in ?? ()
#10 0x000000000041ef47 in PyObject_Call ()
#11 0x0000000000427c1f in ?? ()
#12 0x000000000041ef47 in PyObject_Call ()
#13 0x00000000004778ff in ?? ()
#14 0x000000000046f16f in ?? ()
#15 0x000000000041ef47 in PyObject_Call ()
#16 0x00000000004a72b8 in PyEval_EvalFrameEx ()
#17 0x00000000004a95c1 in PyEval_EvalCodeEx ()
#18 0x00000000004a9692 in PyEval_EvalCode ()
#19 0x00000000004c98be in PyRun_FileExFlags ()
#20 0x00000000004c9ad4 in PyRun_SimpleFileExFlags ()
#21 0x000000000041a6bd in Py_Main ()
#22 0x00007ffff69eac4d in __libc_start_main () from /lib/libc.so.6
#23 0x00000000004198d9 in _start ()

If you had expected a Python traceback, sorry Rick: it didn't produce
one, since it crashed.

So Rick you managed to crash wxPython, in just 248 lines of code. This
doesn't give a very good impression of wxPython - "regular" Python
libraries shouldn't crash the interpreter.

Regards,
Martin
 
M

Martin v. Loewis

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()"

Regards,
Martin
 
C

Corey Richardson

WxPython Challenge 1 code updated...

* Fixed tab traveral
* Removed hand-holding code
* Removed some cruft

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

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
 
R

rantingrick

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:

"""A directory browser using Ttk Treeview.

The only way i can respond to this is to quite the requirements for my
challenge...
 
K

Kevin Walzer

The only way i can respond to this is to quite the requirements for my
challenge...

---------------------------------------
Challenge 1: (Simple Directory Viewer)
---------------------------------------
Create a simple Directory Viewer GUI. You CANNOT use a treectrl!


Any questions?

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. There's no reason to exclude it unless you are
deliberately trying to handicap Tk in your comparison.

--Kevin
 
S

Steven D'Aprano

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! Pity that it is so ugly under Linux :(
 
R

rantingrick

Since you are asking for a traceback, here is one:

[...snip: barf...]
If you had expected a Python traceback, sorry Rick: it didn't produce
one, since it crashed.

Well i did "expect" that you would at least include some info as to
your OS and version. That would be helpful also. Obviously the
wx.ImageList is barfing. Do you have the Bitmap folder containing the
three images. Did you try to comment out the "_createImages()" line.
Simple debug skills we are talking about here Martin, simple. But yet
again this is only tested on Windows. I clearly noted that in the
source.
 
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()"


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 :(
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top