[Tkinter-discuss] why this prog.py crash on win32 ?

francesco.grillo at ciaolab.com francesco.grillo at ciaolab.com
Thu Oct 14 16:53:58 CEST 2004


Hi guys,
i am very surprised how this simple program can hung python (TCL/TK) .
It works fine on a linux system but under windows not .
Can anyone explain why and eventually which by pass apply ?
If i want to write an aplication with a specialized thread that handles

the graphic and that is different than the mainloop what i have to do ?
thanks in advance , Francesco .

# File: hello1.py

from Tkinter import *
import os
import time
import win32ui
import threading
from Tkinter import *
import string
import sys
import glob
import commands
import win32api
    
class App:

    def __init__(self,root ):

        self.r = root        
        self.w = Toplevel(None, background = "#000053")
        self.w.geometry("200x200+0+0")
        self.w.resizable(0,0)
        self.frame = Frame(self.w,width=100,height=100,background = "#000053")
        self.frame.pack()
        self.button = Button(self.frame, text="QUIT", fg="red", command=self.frame.quit)
        self.button.pack(side=LEFT)
        self.button = Button(self.frame, text="max", fg="red", command=self.maxi)
        self.button.pack(side=LEFT)
        self.hi_there = Button(self.frame, text="min", command=self.mini)
        self.hi_there.pack(side=LEFT)
        
        
        
    def mini(self):
        print "MINI hi there, everyone!"
        self.r.deiconify()
        self.w.iconify()
        print "MINI after hi there, everyone!"
        
    def maxi(self):
        print "MAX hi there, everyone!"
        self.r.iconify()
        self.w.deiconify()
        print "MAX after hi there, everyone!"

    
            
        
def grillo(root):
    print 'grillo ThreadID %x ' % win32api.GetCurrentThreadId()
        while(1):
        print 'iconify'
        time.sleep(2.0)
        root.mini()
        print 'deiconify'
        time.sleep(2.0)
        root.maxi()

root = Tk()
root.geometry("20x20")
root.resizable(0,0)
app = App(root)
print 'main ThreadID %x ' % win32api.GetCurrentThreadId()

gThread = threading.Thread(target=grillo,args=[app])
gThread.start()

print 'main start mainloop  %x ' % win32api.GetCurrentThreadId()
root.mainloop()



More information about the Tkinter-discuss mailing list