添加了设定从(0,0)显示:self.root.geometry('1000x200+0+0')其实主要是两个0。那个1000和200是没用的,因为已经设定了minsize。
添加了窗口置顶:self.root.wm_attributes('-topmost',1)
1.主模块,设定时间
#-*-coding:utf-8-*- import Tkinter,time,tkMessageBox,sys,BeBigModule class MainFrame: def __init__(self): self.frame=Tkinter.Frame() self.frame.pack() contentsWork=Tkinter.StringVar() contentsRelax=Tkinter.StringVar() self.entryWorkWidget=Tkinter.Entry(self.frame,text=contentsWork) contentsWork.set('input workTime here:') self.entryWorkWidget["width"]=35 #这句话和下句话的先后顺序不会影响程序 self.entryWorkWidget.pack(side='top') self.entryRelaxWidget=Tkinter.Entry(self.frame,text=contentsRelax) contentsRelax.set('input relaxTime here:') self.entryRelaxWidget.config(width=35) self.entryRelaxWidget.pack(side='top') self.startButton=Tkinter.Button(self.frame,text="OK",command=self.start) self.startButton.pack(side='left') self.quitButton=Tkinter.Button(self.frame,text="Exit",command=self.quit) self.quitButton.pack(side='right') self.frame.mainloop() def start(self): workTime=self.entryWorkWidget.get().strip() workTimeNum=int(workTime) # self.frame.deiconify() # self.frame.withdraw relaxTime=self.entryRelaxWidget.get().strip() relaxTimeNum=int(relaxTime) self.frame.destroy() beBigFrame=BeBigModule.BeBig(workTimeNum,relaxTimeNum) def quit(self): pass # root=Tkinter.Tk() # root.title("CountDowm") # # mainFrame=MainFrame(root) # root.mainloop() mainFrame=MainFrame()
2.遮挡窗口:
import Tkinter,sys,time class BeBig(): workTime=0 relaxTime=0 root=Tkinter.Tk() Label1=Tkinter.Label(root,text=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())),compound = 'center',font=20) def __init__(self,workTimeNum,relaxTimeNum): self.workTime=workTimeNum self.relaxTime=relaxTimeNum self.root.minsize(self.root.winfo_screenwidth(), self.root.winfo_screenheight()) #self.root.geometry('300x200-100-100') self.root.config(bg='black') self.root.wm_attributes('-topmost',1) self.root.geometry('1000x200+0+0') self.Label1.pack(side='top') topTitle=self.root.winfo_toplevel() topTitle.overrideredirect(True) self.trickit(self.relaxTime,self.workTime) self.root.mainloop() def trickit(self,relaxTime,workTime): for j in range(relaxTime,0,-1): self.Label1["text"]=j self.root.update() time.sleep(1) self.root.withdraw() time.sleep(workTime) self.root.minsize(self.root.winfo_screenwidth(), self.root.winfo_screenheight()) self.root.update() self.root.deiconify() self.trickit(self.relaxTime,self.workTime) #beBig=BeBig(5,5)