2005年05月06日 星期五 17:22
随便打个比方,下面程序执行会产生一个窗口 如果最小化那个窗口那么默认是最小化到任务栏,有没有办法让其最小化到托盘呢? 谢谢!! # 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() -- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050506/8048dd0c/attachment.html
2005年05月06日 星期五 23:59
看看python的win32扩展包,里面有一个例子,是调用win32api,来得到TrayIcon的效果的。 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050506/c711eebb/attachment.htm
Zeuux © 2025
京ICP备05028076号