Need GUI pop-up to edit a (unicode ?) string

rantingrick rantingrick at gmail.com
Tue Jan 25 18:02:18 EST 2011


On Jan 25, 3:54 pm, Bryan <bryan.oak... at gmail.com> wrote:

> tkinter is likely the easiest solution. Here's a quick hack,

[...snip code...]

Well this is nice Bryan however it should be much easier than this.
Basically your code is creating most of the functionality that should
be wrapped up in a Dialog class. Tkinter has the tkSimpleDialog from
which one can inherit and build custom dialogs like the one you have
here however it has a major flaw! Fredrick choose not give the class a
show method and instead just threw all the code that should be in a
"show" method into the __init__ method. This is not a good idea. And
i'll explain why...

What Fredrick was trying to do was to make noob programmers life
easier. And he accomplished this in a specific way! However by NOT
creating a show method he has at the same time handicapped these same
people! The proper way to use a dialog class is...

 * Subclass a built-in in Dialog class and insert some widgets.
   class MyDialog(tkSimpleDialog.Dialog): blah

 * Create and instance of your custom dialog.
   dlg = MyDialog(blah)

 * Configure any widget values (if needed!)
   dlg.origText['text'] = unicodestring

 * and show the dialog
  dlg.show(blah)

This design pattern promotes reuse-ability and encapsulation. However
with Fredricks design you cannot configure the contained widgets after
creating the instance because the dialog has entered a local event
loop brought on by "self.wait_window(self)" which is in the DAMN
INITIAL METHOD! This is a major flaw in the design and i would be
happy to fix the flaw. However our "friend" Fredrick decided to
copyright the module to himself! What a jerk! Which is quite
disgusting considering that Tkinter, and TclTk are completely open
source!

And i don't want to hear any arguments about invoking the __init__
method because if you read the source you will see why doing that is
completely ridiculous because of Fredericks design. This is another
example of how few people actually use Tkinter. If many people where
using the module obviously bad code such as this would not exist for
14 years! Someone would have complained.

If Frederic wants some pointers for how to create a proper dialog he
should contact me, or we should have a discussion here. The sad thing
is that this dialog has not been fixed since 1997. And you people
wonder why i hate Tkinter!




More information about the Python-list mailing list