I've just started playing with Python. Installed 2.5 on Windows XP
system. I'm working through some of the examples in Programming Python
3ed by Mark Lutz. Given the following example when the Quit All button
action is assigned to root.quit the windows aren't dismissed or
destroyed. The application appears to terminate, but the windows
remain. When the action is assigned to root.destroy, the windows are
closed. Questions:
1) Which way is preferred / correct?
2) Is something wrong with 2.5? (I haven't tried older versions of
python)
3) Is there something wrong with my installation?
############### ############### ############### ############### ############### ##
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app;
top-level
# windows have title, icon, iconify/deiconify and protocol for wm
events;
# there always is an app root window, whether by default or created as
an
# explicit Tk() object; all top-level windows are containers, but never
# packed/gridded; Toplevel is like frame, but new window, and can have
menu;
############### ############### ############### ############### ############### ##
from Tkinter import *
root = Tk() # explicit root
trees = [('The Larch!', 'light blue'),
('The Pine!', 'light green'),
('The Giant Redwood!', 'red')]
for (tree, color) in trees:
win = Toplevel(root)
# new window
win.title('Sing ...')
# set border
win.protocol('W M_DELETE_WINDOW ', lambda:0) # ignore close
win.iconbitmap( 'py-blue-trans-out.ico') # not red Tk
msg = Button(win, text=tree, command=win.des troy) # kills one win
msg.pack(expand =YES, fill=BOTH)
msg.config(padx =10, pady=10, bd=10, relief=RAISED)
msg.config(bg=' black', fg=color, font=('times', 30, 'bold italic'))
root.title('Lum berjack demo')
Label(root, text='Main window', width=30).pack( )
#Button(root, text='Quit All', command=root.qu it).pack() # kills
all app
Button(root, text='Quit All', command=root.de stroy).pack() # kills all
app
root.mainloop() 5 13307
mzdude wrote:
I've just started playing with Python. Installed 2.5 on Windows XP
system. I'm working through some of the examples in Programming Python
3ed by Mark Lutz. Given the following example when the Quit All button
action is assigned to root.quit the windows aren't dismissed or
destroyed. The application appears to terminate, but the windows
remain. When the action is assigned to root.destroy, the windows are
closed. Questions:
1) Which way is preferred / correct?
quit() causes the mainloop() call to return. if calling mainloop() is
the last thing you do in your program, the program terminates.
destroy() destroys the given window. if that's the last window, the
mainloop() is terminated as well.
2) Is something wrong with 2.5? (I haven't tried older versions of
python)
not that I can see.
3) Is there something wrong with my installation?
works for me. are you perhaps running this under some kind of IDE that
keeps the process running even after the program has terminated?
</F>
Fredrik Lundh wrote:
[snip]
works for me. are you perhaps running this under some kind of IDE that
keeps the process running even after the program has terminated?
It works the same way if I run from IDLE or from the DOS command prompt.
On 2006-10-13, mzdude <js****@cox.net wrote:
>
Fredrik Lundh wrote:
[snip]
>works for me. are you perhaps running this under some kind of IDE that keeps the process running even after the program has terminated?
It works the same way if I run from IDLE or from the DOS
command prompt.
I had some fun trying to run Tkinter from from the Python
embedded in Vim. My advice: Do not do that.
--
Neil Cerutti
The majority of time, it seems to be one thing or the other.
--Ron Mercer
mzdude wrote:
>works for me. are you perhaps running this under some kind of IDE that keeps the process running even after the program has terminated?
It works the same way if I run from IDLE or from the DOS command prompt.
I find very hard to believe that a Python interpreter run from the DOS
command prompt wouldn't terminate when it reaches the end of the main
program.
what Python distribution are you using?
</F>
Fredrik Lundh wrote:
mzdude wrote:
works for me. are you perhaps running this under some kind of IDE that
keeps the process running even after the program has terminated?
It works the same way if I run from IDLE or from the DOS command prompt.
I find very hard to believe that a Python interpreter run from the DOS
command prompt wouldn't terminate when it reaches the end of the main
program.
what Python distribution are you using?
</F>
Not sure I understand the question. I downloaded python-2.5.msi from
python.org/download.
>From the IDLE
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright" , "credits" or "license()" for more information. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Josh |
last post by:
Caution, newbie approaching...
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles filling the remainder of the window. Mind you,
this is a contrived test application to help me understand Tkinter and
Python, not an actual application yet. I've trivially subclassed
Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
|
by: Jane Austine |
last post by:
>Jane Austine wrote:
>>>>from Tkinter import *
>>>>>r=Tk()
>>>>>b=Button(r,text='Quit',command=r.quit)
>>>>>b.pack()
>>>>>r.mainloop()
>>
>>
>> And when I press the "Quit" button the mainloop exits. After that,
if
|
by: SeeBelow |
last post by:
Do many people think that wxPython should replace Tkinter? Is this
likely to happen?
I ask because I have just started learning Tkinter, and I wonder if I
should abandon it in favor of wxPython.
Mitchell Timin
--
"Many are stubborn in pursuit of the path they have chosen, few in
|
by: syed_saqib_ali |
last post by:
Please take a look at and run the code snippet shown below.
It creates a canvas with vertical & Horizontal scroll-bars.
If you shrink the window to smaller than the area of the canvas, the
scroll-bars work as advertised. That's great.
However, if you click the Left Mouse button, it calls code which
expands the width of the canvas by 100 pixels. The area being viewed
expands correspondingly..... BUT I DON'T WANT IT TO!!
|
by: syed_saqib_ali |
last post by:
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust accordingly.
However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the...
| |
by: Brandon |
last post by:
Hi All,
I'm attempting to develop a Tcl/Tk application on the mac using python
and Tkinter. The one problem I'm having is adding basic keyboard
support to my application, specifically binding command-q so that it
quits the application (this is standard behavior for almost every mac
application, the equivalent of alt-f4 on windows). Has anyone
successfully been able to do this? If so, could you please share some
code which...
|
by: al pacino |
last post by:
i have a weired problem with button widget in Tkinter
the callback function(Tk.quit()) for button widget is not working! when
i 'press' the button
the GUI hangs.
code for displaying a 'button objec':
###################
import Tkinter
top=Tkinter.Tk()
button=Tkinter.Button(top,text='press me',command=top.quit)#callback to
end the appllication
|
by: dwelch91 |
last post by:
I'm trying unsuccessfully to do something in Tk that I though would be
easy. After Googling this all day, I think I need some help. I am
admittedly very novice with Tk (I started with it yesterday), so I am
sure I am overlooking something simple.
The basic idea is that my application will consist of a series of modal
dialogs, that are chained together in "wizard" fashion. There will be
some processing in between dialogs, but for the most...
|
by: karthikbalaguru |
last post by:
Hi,
One of my python program needs tkinter to be installed to run
successfully.
I am using Redhat 9.0 and hence tried installing by copying the
tkinter-2.2.2-36.i386.rpm
alone from the CD 3 to my pc. But, it is not getting installed and is
failing by throwing
the below errors. Should i need to configure / install any specific
files for resolving this issue ?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |