Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327883
  • 博文数量: 130
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 554
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-19 19:24
文章分类

全部博文(130)

文章存档

2016年(31)

2015年(16)

2014年(13)

2013年(70)

分类: LINUX

2015-10-28 13:24:59


点击(此处)折叠或打开

  1. from tkinter import *
  2. from tkinter.ttk import *
  3. import tkinter.font as font
  4. import random


  5. # Define an application for our time-out
  6. class tmOtApp:
  7.     def __init__(self,master = None):
  8.         self.windows = master
  9.         self.timeout = 1000*5
  10.         self.drawstop = Variable(0)
  11.         self.drawcounts = 0
  12.         self.frame = Frame(master)
  13.         self.titVar = StringVar(self.frame,'Time tools')
  14.         tfont = font.Font(family = 'Fixdsys',size = 20,weight = font.BOLD)
  15.         self.titles = Label(self.frame, textvariable = self.titVar, font=tfont)
  16.         self.selectEmu = StringVar(self.frame, ('one hour', 'two hour'))
  17.         self.selectTime = Listbox(self.frame, listvariable=self.selectEmu, width=10, height=5)
  18.         self.callback = None
  19.         self.startButton = Button(self.frame, text='Start', command=self.pushTOdeamo)
  20.         self.cavs = Canvas(self.frame,height=200, width=200)
  21.         self.cavsExitButton = Button(self.frame, text='ScreenEixt', command=self.cavsexit)
  22.     def titleSet(self, value=None):
  23.         self.titVal.set(value)
  24.         
  25.     def titleGet(self):
  26.         return self.titVal.get()
  27.     
  28.     def cavsexit(self):
  29.         self.drawstop.set(1)
  30.     
  31.     def makefullscreen(self):
  32.         root = self.windows
  33.         width,height = root.winfo_screenwidth(), root.winfo_screenheight()
  34.         root.overrideredirect(1)
  35.         root.geometry("%dx%d+0+0"%(width, height))
  36.         
  37.     def drawCavs(self):
  38.         self.drawcounts += 1
  39.         random.seed(self.drawcounts)
  40.         x1,y1,x2,y2 = (random.randrange(1000), random.randrange(1200), random.randrange(500), random.randrange(700))
  41.         b = self.drawcounts % 4
  42.         if b == 0:
  43.             self.cavs.create_arc(x1,y1,x2,y2)
  44.             self.cavs.create_rectangle(x1,y1,x2,y2)
  45.         elif b == 1:
  46.             self.cavs.create_line(x1,y1,x2,y2)
  47.             self.cavs.create_bitmap(x1,y1)
  48.         elif b == 2:
  49.             self.cavs.create_text(x1,y1, text='HTOHL', font=('Helvetica','12'))
  50.         else :
  51.             self.cavs.create_oval(x1,y1,x2,y2)
  52.             self.cavs.create_polygon(x1,y1,x2,y2, 200, 145, 450, 890)
  53.         if not self.drawstop.get():
  54.             self.windows.after(100,self.drawCavs)

  55.     def checktimeout(self):
  56.         if self.timeout:
  57.             self.windows.deiconify()
  58.             self.drawCavs()
  59.             # Wait user stop draw
  60.             self.windows.wait_variable(self.drawstop)
  61.             self.windows.iconify()
  62.             self.cavs.delete('all')
  63.             self.drawstop.set(0)
  64.         self.windows.after(5000, self.checktimeout)
  65.         
  66.     def pushTOdeamo(self):
  67.         # start timer to check time
  68.         self.windows.after(5000,self.checktimeout)
  69.         self.windows.iconify()
  70.         self.cavs.grid(row=0, rowspan=15, column=0, columnspan=15, sticky=NSEW)
  71.         self.cavsExitButton.grid(rowspan=15, columnspan=15, sticky=NSEW)
  72.         
  73.         
  74.     def Show(self):
  75.         self.frame.grid()
  76.         self.titles.grid(column=5, columnspan=5, rowspan=8, sticky=NSEW)
  77.         self.selectTime.grid(row= 9, column=2, columnspan=1, sticky=NSEW)
  78.         self.startButton.grid(row=9, column=10, columnspan=1, sticky=NSEW)
  79.         
  80.         
  81.     def mainLoop(self):
  82.         self.windows.mainloop()
  83.         
  84.         
  85. if __name__ == '__main__':
  86.     Root = Tk()
  87.     app = tmOtApp(Root)
  88.     app.Show()
  89.     app.mainLoop()


点击(此处)折叠或打开

  1. from distutils.core import setup
  2. import py2exe

  3. setup(windows=["time-out.py"])

阅读(953) | 评论(0) | 转发(0) |
0

上一篇:Yacc gramer rule

下一篇:lex yacc 实例

给主人留下些什么吧!~~