Some basic questions about Tkinter (probably v easy for experts!)

Neil Cerutti cerutti at together.net
Thu Feb 8 11:29:58 EST 2001


Martyn Quick posted:
>On 7 Feb 2001, Neil Cerutti wrote:
>
>> >As I said in my reply to Fredrik Lundh's answer, I did *try* to
>> >read this, but unfortunately I found it rather difficult.  It
>> >doesn't actually seem to be aimed at beginners who are new to
>> >Object Oriented Programming.
>> 
>> Oh! That'll make it difficult to follow. Sorry. Using Tkinter
>> isn't a good way to learn OOP.
>> 
>> Luckily, the semantics and syntax of OOP is easy to learn
>> in Python, if not the practice.
>
>I *think* I'm beginning to get the idea of OOP - it just doesn't
>come as second nature yet.  Thanks very much for your example
>below - I have one question about it (apologies!) but I've
>managed to make a start on writing the code I want.  My own code
>isn't very OOP yet - but I've put lots of comments in to remind
>me to adjust it when I've got a better idea of what will make
>sensible classes, etc.

Just remember the syntax. And use Fredrik Lundh's docs to find
out what options, methods, and especially programming patterns
are in there for the widgets you use.

>> Here's a small demo. I'm not going to use "import *" here, to
>> hopefully make it a little clearer. You don't need to type in the
>> comments. ;-)
>> 
>> [snip example]
>>
>> # The window won't appear and your other widgets won't function
>> # until:
>> root.mainloop()
>
>OK, I followed that example and it was very helpful - *however*
>I think I am misunderstanding your final comment here.  When I
>typed the example into python running in a DOSbox window, the
>window & button did appear and did do what they were supposed to
>before I used root.mainloop().  This seems contrary to what
>you've written above.  (Perhaps when I run the thing as a script
>I need the mainloop() but less so when it's done at command
>prompt??).

I'm confused about this issue too, I guess.

-- 
Neil Cerutti <cerutti at together.net>



More information about the Python-list mailing list