R
r
---------------------------------------------
Tkinter and IDLE Shortfalls
---------------------------------------------
*The following is an assessment of Tkinter as i have experienced it.
Even with all the problems i list below i strongly believe Tkinter is
a great starter GUI toolkit and we (the Python Community), must keep
and maintain this module for the foreseeable future.
*However, as my assessment will reveal, much needs to be done to
"freshen" up Tkinter and IDLE, and I am not just asking for someone to
fix these problems. I have already coded solutions for most of them
however, some of course still need work, and i would like to hear from
others on this subject too. So buckle your seat belts folks, cause
here we go...
---------------------------------------------
Python offical docs and Tkinter
---------------------------------------------
*The Python docs barely cover anything related to actual Tkinter
coding. At the minimum the Tkinter doc page should have a subpage for
all the widgets available --which is very small(approx 15) and each
subpage should list the available methods on that wiget. Here are two
great resources that really like from Fredrik Lundh and John
Shipman...
http://www.pythonware.com/library/tkinter/introduction/index.htm
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
....I must say that I prefer the latter written by John Shipman because
of the way he lists each widgets options in a nice table structure,
and then lists the methods below. And intersestingly enough, his
manual only weighs in at about 800kb completely uncommpressed and
unedited. I'll bet you a wooden nickel i can reduce it to around 500kb
for the official Python docs *wink*
*Sadly however neither of these great works is mentioned or linked in
the official docs Why?.
*I think a short-and-to-the-point reference, like the afore mentioned
along with a few links to full featured tuts would be a great addition
to the Tkinter section of the official docs and i would be happy to
help make this happen.
---------------------------------------------
from Tkinter import *
---------------------------------------------
*Too many noobs start out with the "from Tkinter import *" idiom,
unknowing that they are horribly polluting their namespace. I feel
that all (tkinter) code should follow the "import Tkinter as tk"
policy and never use "from Tkinter import *". To push this agenda i
propose all docs be modified so that no one should see such global
import blasphemy again. We should at least keep all example code in
the latter non-polluting form and frown heavily upon global imports in
Tkinter code or any code for that matter.
---------------------------------------------
Tkinter Constants
---------------------------------------------
*The Tkconstants module needs to be removed *yesterday* because i
think it reinforces sloppy coding styles. The main problem is with
subtle bugs that are created when someone rebinds one or more of the
constants, for example "W=20". At first i thought the constants were
great but I quickly found out the shortfalls of such a Utopian
approach . Since Tkinter allows strings to be passed-into widget
constructors, we should remove the TkConstants immediately and force
everyone to use strings instead...
#-- instead of this --#
w.pack(side=LEFT,fill=BOTH,anchor=W)
#-- do this --#
w.pack(side='left',fill='both',anchor='w')
The few extra keystrokes are well worth the effort!
---------------------------------------------
IDLE Shell
---------------------------------------------
*IDLE and Pyshell are great but have major flaws in design. One of my
biggest complaints is the shell's eight space indention which
completely bloats your screen! Another annoying fact is that the prompt
(>>>) is actually inside the text widget. This design is all wrong!
The prompt should be in another widget to the left of the text so it
never gets copied or pasted. Or at-least have the copy/paste action
remove the initial four spaces and the prompt, but i think a full
separation of "prompt" and "text" are the best solution. The following
ASCII art won't win me any awards, but it may covey my idea. "W1"
holds the prompt and "W2" is the actual text editor.
... | print x |
... | for y in range(x): |
... | print y |
|1
|2
And don't tell me about Geany or Pythonwin or emacs or vim or whatever
editor happens to float your boat. I know there are tons of great
editors out there but IDLE is most likely the first one a Pynoob will
use so it must be usable! IDLE and Tkinter are what make Python a
stater language -- after the beautiful syntax of course
---------------------------------------------
IDLE Editor
---------------------------------------------
*On M$ windows pressing the MMB without a motion causes the selected
text to be pasted at the insertion cursor, and holding it repeats the
action very quickly! Since IDLE has no horizontal scroll bar you must
use MMB to scroll left-right. I am quite happy that there is no
horizontal scrollbar since using MMB is much quicker, but the text
pasting action always ruins my day . This pasting action is a real
PITA and a waste of good processor time. I know how to override it
with a hack in IDLE, but many newcomers won't and will probably get
frustrated by it so this must be either fixed by hard coding IDLE or
allowing a user to turn is off in the config options dialog.
*Something that always gets a Python IDLE noob is "open-bracket-syntax-
errors" in IDLE. When Python throws this type of error normally the
only clue you will get from IDLE is to see the last line highlighted.
However, the missing or misplaced bracket is usually no where near the
end of the script. IDLE can be easily fixed to show a much closer or
even exact location of the last open bracket.
*The Find dialog forgets the regexp string after finding a match, this
can be a real time waster especially if you typed in a long expression
and need to tweak it just a bit for a second search! if the "regexp"
check box is selected the dialog should not replace the contents of
the Dialog.entry with the texts' selection. (easy fix)
*The replace dialog seems buggy when doing a "replace+find". Sometimes
it will highlight the next match but sometimes the highlight will
immediately disappear so you can't be for sure what you may be
replacing with the next push of the button? (could be a conflict with
the colorizer) Real aggravating! This seems to always happen when a
string is selected.
*One of my all time pet peeves with all text editors. Everybody repeat
after me...
"""NO TEXT EDITOR SHOULD EVER COPY AN EMPTY STRING TO THE
CLIPBOARD!!"""
....I can't tell you how many times I've had to re-copy some text
because i accidentally pressed <Control-C> instead of <Control-V>,
arggh! This bug needs to be fixed yesterday! Pressing <Control-C> with
no active selection should sound the error bell, not copy "".
*Using the goto-line command should highlight the requested line.
Currently all that IDLE does is place the insertion cursor at the
start of the requested line which is completely useless. One more line
of code in the goto method would make this action more useful
---------------------------------------------
Tkinter Canvas
---------------------------------------------
*The Tkinter Canvas widget should return (X,Y) pairs when calling
canvas.coords(obj). The current implementation returns a flat array
that is pretty much useless outside of canvas calls. Of course one
could zip the coords into pairs, but it seems clumsy to call zip() on
2 LC's when Tkinter could, and should, do it for you.
*Canvas needs a canvas.rotate() method for polygons, lines -- (easy).
---------------------------------------------
Tkinter ComboBox -- where's Waldo?
---------------------------------------------
*As much as i hate to support anything related to M$, Tkinter needs an
M$ stlye combobox. Yes, I know Tix has combobox (*puke*), however
using it is like pulling teeth. I have coded up an far more elegant/
simple solution -- and yes, i know about the OptionMenu widget which
serves a useful purpose but is NOT a good replacement for a REAL M$
style combobox .
*For instance, ComboBoxes need values that the user can select from,
this is as universal as humans and oxygen. But sometimes you want to
give the user a detailed set of values in the dropdown listbox and
then insert an abbrieation of the value once selected, such as the
case with state names...
New Mexico -> MN
California -> CA
Florida -> FL
....instead of the laborious and wasteful convention of overriding a
method to insert this value from a mapping each time why not just pass
a pointer to the mapping into the constructor and create a combobox
that actually knows how to walk and chew gum!
[Warning: puesdo code ahead!]
class ComboBox(master, values, etc..)
def __init__(blahblahblah)
self.values = values
if type(values) == dict:
self.values = values.keys())
listbox.load(self.values)
def onUserPick(self, arg):
if type(self.values) == dict:
self.entry.set(self.values[arg])
return
self.entry.set(arg)
---------------------------------------------
Tix In General
---------------------------------------------
*I am not a big fan of the Tix Module. The idea behind the widgets is
great, but using most of them is a nightmare on elm street with Jason
Voorhees in hot pursuit. I have hacked my own far more elegant
versions of the more useful Tix Widgets and i feel mine are less buggy
and more user friendly. So i say lose Tix and go with my fix, or get
stuck with the Tix!
*Python is missing good docs for Tix. The only thing i can find is the
Tcl docs which are riddled with horribly cryptic tcl code.
---------------------------------------------
Tix NoteBook
---------------------------------------------
*The Tix.NoteBook widget has a bug. If you subclass Frame for your
toplevel window you can't create a notebook widget as a descendant of
the frame because it just blows chunks. The only way i have
successfully used the widget is by the noobish style...
*Overall however i feel the IDLE "TabbedWidget" out-performs the
Tix.NoteBook by miles and is easier to use, although it does have a
few design problems that i have fixed. One of the most predominate
being the inability to see the tabs clearly. The selected tab should
"stand-out" from the others so a user can spot it quickly. Also there
is no reason to export TabSet class and this can clean up the code a
bit.
---------------------------------------------
Tix ComboBox
---------------------------------------------
*What is with that big ugly arrow? This widget is an exercise in
cruelty to humans, and thats all i will say about it!
---------------------------------------------
Final Thoughts
---------------------------------------------
Well, that is all i can remember for now. If you've made it this far
without losing your temper or your lunch well i am very surprised .
Anyway, give me some feedback on these ideas so maybe i can get
motivated to submit some patches/enhancements.
psst... help is welcome too ya'know
Tkinter and IDLE Shortfalls
---------------------------------------------
*The following is an assessment of Tkinter as i have experienced it.
Even with all the problems i list below i strongly believe Tkinter is
a great starter GUI toolkit and we (the Python Community), must keep
and maintain this module for the foreseeable future.
*However, as my assessment will reveal, much needs to be done to
"freshen" up Tkinter and IDLE, and I am not just asking for someone to
fix these problems. I have already coded solutions for most of them
however, some of course still need work, and i would like to hear from
others on this subject too. So buckle your seat belts folks, cause
here we go...
---------------------------------------------
Python offical docs and Tkinter
---------------------------------------------
*The Python docs barely cover anything related to actual Tkinter
coding. At the minimum the Tkinter doc page should have a subpage for
all the widgets available --which is very small(approx 15) and each
subpage should list the available methods on that wiget. Here are two
great resources that really like from Fredrik Lundh and John
Shipman...
http://www.pythonware.com/library/tkinter/introduction/index.htm
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
....I must say that I prefer the latter written by John Shipman because
of the way he lists each widgets options in a nice table structure,
and then lists the methods below. And intersestingly enough, his
manual only weighs in at about 800kb completely uncommpressed and
unedited. I'll bet you a wooden nickel i can reduce it to around 500kb
for the official Python docs *wink*
*Sadly however neither of these great works is mentioned or linked in
the official docs Why?.
*I think a short-and-to-the-point reference, like the afore mentioned
along with a few links to full featured tuts would be a great addition
to the Tkinter section of the official docs and i would be happy to
help make this happen.
---------------------------------------------
from Tkinter import *
---------------------------------------------
*Too many noobs start out with the "from Tkinter import *" idiom,
unknowing that they are horribly polluting their namespace. I feel
that all (tkinter) code should follow the "import Tkinter as tk"
policy and never use "from Tkinter import *". To push this agenda i
propose all docs be modified so that no one should see such global
import blasphemy again. We should at least keep all example code in
the latter non-polluting form and frown heavily upon global imports in
Tkinter code or any code for that matter.
---------------------------------------------
Tkinter Constants
---------------------------------------------
*The Tkconstants module needs to be removed *yesterday* because i
think it reinforces sloppy coding styles. The main problem is with
subtle bugs that are created when someone rebinds one or more of the
constants, for example "W=20". At first i thought the constants were
great but I quickly found out the shortfalls of such a Utopian
approach . Since Tkinter allows strings to be passed-into widget
constructors, we should remove the TkConstants immediately and force
everyone to use strings instead...
#-- instead of this --#
w.pack(side=LEFT,fill=BOTH,anchor=W)
#-- do this --#
w.pack(side='left',fill='both',anchor='w')
The few extra keystrokes are well worth the effort!
---------------------------------------------
IDLE Shell
---------------------------------------------
*IDLE and Pyshell are great but have major flaws in design. One of my
biggest complaints is the shell's eight space indention which
completely bloats your screen! Another annoying fact is that the prompt
(>>>) is actually inside the text widget. This design is all wrong!
The prompt should be in another widget to the left of the text so it
never gets copied or pasted. Or at-least have the copy/paste action
remove the initial four spaces and the prompt, but i think a full
separation of "prompt" and "text" are the best solution. The following
ASCII art won't win me any awards, but it may covey my idea. "W1"
holds the prompt and "W2" is the actual text editor.
... | print x |
... | for y in range(x): |
... | print y |
|1
|2
And don't tell me about Geany or Pythonwin or emacs or vim or whatever
editor happens to float your boat. I know there are tons of great
editors out there but IDLE is most likely the first one a Pynoob will
use so it must be usable! IDLE and Tkinter are what make Python a
stater language -- after the beautiful syntax of course
---------------------------------------------
IDLE Editor
---------------------------------------------
*On M$ windows pressing the MMB without a motion causes the selected
text to be pasted at the insertion cursor, and holding it repeats the
action very quickly! Since IDLE has no horizontal scroll bar you must
use MMB to scroll left-right. I am quite happy that there is no
horizontal scrollbar since using MMB is much quicker, but the text
pasting action always ruins my day . This pasting action is a real
PITA and a waste of good processor time. I know how to override it
with a hack in IDLE, but many newcomers won't and will probably get
frustrated by it so this must be either fixed by hard coding IDLE or
allowing a user to turn is off in the config options dialog.
*Something that always gets a Python IDLE noob is "open-bracket-syntax-
errors" in IDLE. When Python throws this type of error normally the
only clue you will get from IDLE is to see the last line highlighted.
However, the missing or misplaced bracket is usually no where near the
end of the script. IDLE can be easily fixed to show a much closer or
even exact location of the last open bracket.
*The Find dialog forgets the regexp string after finding a match, this
can be a real time waster especially if you typed in a long expression
and need to tweak it just a bit for a second search! if the "regexp"
check box is selected the dialog should not replace the contents of
the Dialog.entry with the texts' selection. (easy fix)
*The replace dialog seems buggy when doing a "replace+find". Sometimes
it will highlight the next match but sometimes the highlight will
immediately disappear so you can't be for sure what you may be
replacing with the next push of the button? (could be a conflict with
the colorizer) Real aggravating! This seems to always happen when a
string is selected.
*One of my all time pet peeves with all text editors. Everybody repeat
after me...
"""NO TEXT EDITOR SHOULD EVER COPY AN EMPTY STRING TO THE
CLIPBOARD!!"""
....I can't tell you how many times I've had to re-copy some text
because i accidentally pressed <Control-C> instead of <Control-V>,
arggh! This bug needs to be fixed yesterday! Pressing <Control-C> with
no active selection should sound the error bell, not copy "".
*Using the goto-line command should highlight the requested line.
Currently all that IDLE does is place the insertion cursor at the
start of the requested line which is completely useless. One more line
of code in the goto method would make this action more useful
---------------------------------------------
Tkinter Canvas
---------------------------------------------
*The Tkinter Canvas widget should return (X,Y) pairs when calling
canvas.coords(obj). The current implementation returns a flat array
that is pretty much useless outside of canvas calls. Of course one
could zip the coords into pairs, but it seems clumsy to call zip() on
2 LC's when Tkinter could, and should, do it for you.
*Canvas needs a canvas.rotate() method for polygons, lines -- (easy).
---------------------------------------------
Tkinter ComboBox -- where's Waldo?
---------------------------------------------
*As much as i hate to support anything related to M$, Tkinter needs an
M$ stlye combobox. Yes, I know Tix has combobox (*puke*), however
using it is like pulling teeth. I have coded up an far more elegant/
simple solution -- and yes, i know about the OptionMenu widget which
serves a useful purpose but is NOT a good replacement for a REAL M$
style combobox .
*For instance, ComboBoxes need values that the user can select from,
this is as universal as humans and oxygen. But sometimes you want to
give the user a detailed set of values in the dropdown listbox and
then insert an abbrieation of the value once selected, such as the
case with state names...
New Mexico -> MN
California -> CA
Florida -> FL
....instead of the laborious and wasteful convention of overriding a
method to insert this value from a mapping each time why not just pass
a pointer to the mapping into the constructor and create a combobox
that actually knows how to walk and chew gum!
[Warning: puesdo code ahead!]
class ComboBox(master, values, etc..)
def __init__(blahblahblah)
self.values = values
if type(values) == dict:
self.values = values.keys())
listbox.load(self.values)
def onUserPick(self, arg):
if type(self.values) == dict:
self.entry.set(self.values[arg])
return
self.entry.set(arg)
---------------------------------------------
Tix In General
---------------------------------------------
*I am not a big fan of the Tix Module. The idea behind the widgets is
great, but using most of them is a nightmare on elm street with Jason
Voorhees in hot pursuit. I have hacked my own far more elegant
versions of the more useful Tix Widgets and i feel mine are less buggy
and more user friendly. So i say lose Tix and go with my fix, or get
stuck with the Tix!
*Python is missing good docs for Tix. The only thing i can find is the
Tcl docs which are riddled with horribly cryptic tcl code.
---------------------------------------------
Tix NoteBook
---------------------------------------------
*The Tix.NoteBook widget has a bug. If you subclass Frame for your
toplevel window you can't create a notebook widget as a descendant of
the frame because it just blows chunks. The only way i have
successfully used the widget is by the noobish style...
*Overall however i feel the IDLE "TabbedWidget" out-performs the
Tix.NoteBook by miles and is easier to use, although it does have a
few design problems that i have fixed. One of the most predominate
being the inability to see the tabs clearly. The selected tab should
"stand-out" from the others so a user can spot it quickly. Also there
is no reason to export TabSet class and this can clean up the code a
bit.
---------------------------------------------
Tix ComboBox
---------------------------------------------
*What is with that big ugly arrow? This widget is an exercise in
cruelty to humans, and thats all i will say about it!
---------------------------------------------
Final Thoughts
---------------------------------------------
Well, that is all i can remember for now. If you've made it this far
without losing your temper or your lunch well i am very surprised .
Anyway, give me some feedback on these ideas so maybe i can get
motivated to submit some patches/enhancements.
psst... help is welcome too ya'know