[Tutor] Tkinter in classes...why?

Liam Clarke-Hutchinson liam at steelsky.co.nz
Fri Jan 21 06:30:04 CET 2011


Your signature is obscenely large David.

> But, the tutorials I have encountered all mentioned that it is supposed to
be a good idea to put one's GUI stuff in a class, then create an instance of
the class (which I don't entirely understand, since I thought the whole
"class" thing was for stuff that you were gonna have a lot of, like similar
records in a database or something, so you could use the class like a
factory to spit out little copies of itself.

You're creating an instance of a class, with all the state of that instance
relevant to only that instance. Consider an instance of a class to be a
convenient way of handling variable scope, I guess. Coming from Tcl to
Python will have some significant differences, I'm sure, but Python's OOP is
far more likely to be aligned to mainstream coding than Tk... give me a
second to google Tcl to determine if it has OO paradigms... ...okay, sorta
does.

> All this in Tcl\Tk seems to me, in comparison, just dead nuts simple...but
Tkinter...seems to have made unnecessarily complicated. Maybe once I
understand it, I won't think of it that way, but for now...whatta PITA!

Tcl is not Python. Fair enough that you recoil at what you consider to be
unnecessary complexity, but yeah, Tcl is is not Python. I've heard good
things about Tcl, but I also know that none of my programming peers use it.
Perhaps try another Python GUI library like wxPython, or pyGTK or pyQT etc.
That way, they might be different enough that you can escape comparisons to
Tcl.

But hey, sometimes, a language just doesn't fit your way of working. If Tcl
suits you better, then stick with Tcl.

Regards,

Liam Clarke


On Fri, Jan 21, 2011 at 8:57 AM, David Hutto <smokefloat at gmail.com> wrote:

> On Thu, Jan 20, 2011 at 2:43 PM, Elwin Estle <chrysalis_reborn at yahoo.com>
> wrote:
> > I have some experience in Tcl\Tk, and so far, Tkinter is striking me as
> harder to use that Tk in it's "native" environment.
> >
> > I am attempting to re-write a program I originally did in Tcl\Tk in
> Python.  I managed to get a GUI done using just Tkinter, and, after an
> initial struggle with the Tkinter syntax (and especially the widget "naming"
> conventions),  had no problem getting widgets to display, etc.
> >
> > But, the tutorials I have encountered all mentioned that it is supposed
> to be a good idea to put one's GUI stuff in a class, then create an instance
> of the class (which I don't entirely understand, since I thought the whole
> "class" thing was for stuff that you were gonna have a lot of, like similar
> records in a database or something, so you could use the class like a
> factory to spit out little copies of itself.
> >
> > Anyway, when I attempted to convert my non-class based Tkinter code into
> a class, that's when the problems started.  I guess I still don't have a
> handle on all the "self.this's & self.that's", tho I have created some
> classes for the aforementioned database entry type stuff and haven't had too
> much trouble.
> >
> > For starters, it seems like the first thing these class based tutorials
> do is to start with a frame inside the main Tkinter window?  Why?  Why not
> just grid stuff right into the window, instead of making a frame and
> gridding widgets into that.
> >
> > Is the (self, master) thing in the __init__ section a convention, or is
> the use of the "master" a requirement?   Can you call it something else?
>  What is the purpose of doing an __init__ with a frame after having done
> __init__ with (self, master)?
> >
> > All this in Tcl\Tk seems to me, in comparison, just dead nuts
> simple...but Tkinter...seems to have made unnecessarily complicated.  Maybe
> once I understand it, I won't think of it that way, but for now...whatta
> PITA!
>
> It's just like any other concept, at first it is a PITA, then it
> becomes a normal utilization for your projects. Stick to your own
> platform, and design for it, then expand for others in your portfolio.
>
> >
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
>
> --
> The lawyer in me says argue...even if you're wrong. The scientist in
> me... says shut up, listen, and then argue. But the lawyer won on
> appeal, so now I have to argue due to a court order.
>
> Furthermore, if you could be a scientific celebrity, would you want
> einstein sitting around with you on saturday morning, while you're
> sitting in your undies, watching Underdog?...Or better yet, would
> Einstein want you to violate his Underdog time?
>
> Can you imagine Einstein sitting around in his underware? Thinking
> about the relativity between his pubic nardsac, and his Fruit of the
> Looms, while knocking a few Dorito's crumbs off his inner brilliant
> white thighs, and hailing E = mc**2, and licking the orangy,
> delicious, Doritoey crust that layered his genetically rippled
> fingertips?
>
> But then again, J. Edgar Hoover would want his pantyhose intertwined
> within the equation.
>
> However, I digress, momentarily.
>
> But Einstein gave freely, for humanity, not for gain, other than
> personal freedom.
>
> An equation that benefited all, and yet gain is a personal product.
>
> Also, if you can answer it, is gravity anymore than interplanetary static
> cling?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110121/56fd837f/attachment-0001.html>


More information about the Tutor mailing list