I write a program with Python 2.4 + Tkinter
Execute it, there will be a window show something.
If I minimize it, it will be minimized to the taskbar. But I would like it to miniminze to the System Tray, this can make taskbar more clear. Would you please tell me how to modify my program.


   Thanks a lot !!

Soure Code :

# Display digits of pi in a window, calculating in a separate thread.
# Compare with wpi.py in the Demo/threads/wpi.py

import sys
import time
import thread
from Tkinter import *

class ThreadExample:
   def __init__(self, master=None):
       self.ok                = 1
       self.digits            = []
       self.digits_calculated = 0
       self.digits_displayed  = 0
       self.master            = master

       thread.start_new_thread(self.worker_thread, ())

       self.frame = Frame(master, relief=RAISED, borderwidth=2)
       self.text = Text(self.frame, height=26, width=50)
       self.scroll = Scrollbar(self.frame, command=self.text.yview)
       self.text.configure(yscrollcommand=self.scroll.set)
       self.text.pack(side=LEFT)
       self.scroll.pack(side=RIGHT, fill=Y)
       self.frame.pack(padx=4, pady=4)
       Button(master, text='Close', command=self.shutdown).pack(side=TOP)

       self.master.after(100, self.check_digits)

   def worker_thread(self):
       while self.ok:
           self.digits.append(`9`)
           time.sleep(0.001)

   def shutdown(self):
       self.ok =0
       self.master.after(100, self.master.quit)

   def check_digits(self):
       self.digits_calculated = len(self.digits)
       diff = self.digits_calculated - self.digits_displayed
       ix = self.digits_displayed
       for i in range(diff):
           self.text.insert(END, self.digits[ix+i])
       self.digits_displayed =  self.digits_calculated
       self.master.title('%d digits of pi' % self.digits_displayed)
       self.master.after(100, self.check_digits)

root = Tk()
root.option_readfile('optionDB')
example = ThreadExample(root)
root.mainloop()

_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn/


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to