1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55-56 |
#-*-Coding:utf8-*-from tkinter import * Import tkfont Import random class App:def __init__ (self, master): frame = [FRAME () for I in range (4)] for I in range (4): frame[i] = FRAME (master) frame[i].pack () Self.button1 = Button (frame[0], text= ' Shuangse Qiu ', fg= ' Red ', Font=tkfont.font (family= ' Microsoft Ya-black ', size=20), width=20, command= self.creatdouble) Self.button1.pack (side=left) Self.button2 = Button (frame[1), text= ' Grand Lotto ', fg= ' blue ', Tkfont.font (family= ' Microsoft Youngor, size=20), width=20, Command=self.creatdaletou) self.button2.pack (side=left) Self.button3 = Button (frame[2], text= ' empty ', Font=tkfont.font (family= ' Microsoft Ya-black ', size=20), width=20, Command=self.clearall) Self.button3.pack () Self.text = text (frame[3], width=53, height=15) Self.scroll = Scrollbar (frame[3), width=4, command= Self.text.yview) self.text.configure (yscrollcommand=self.scroll.set) self.scroll.pack (Side=right, fill=y) Self.text.pack (Side=left) def say_hi (self): print ' Hello World ' def clearall (self): self.text.deLete (' 1.0 ', end) def creatrandum (self, Rangesize, arrsize): arr = [0 to I in range (0,arrsize)] Rangearr = [x + 1 for x in Range (rangesize)] for I in range (len (arr)): arr[i] = rangearr[random.randint (0, Len (rangearr)-1)] Rangearr.remove (arr[i ] Arr.sort () return arr def creatdouble (self): RedBall = self.creatrandum (6) BlueBall = Random.randint (1,16) ballstr = ' for i in REDBALL:BALLSTR = Ballstr + str (i) + ' ballstr = ballstr + ' | ' + str (blueball) + ' n ' self.text.insert (1). 0, BALLSTR) def Creatdaletou (self): Beforearea = Self.creatrandum (5) Afterarea = Self.creatrandum (2) ballstr = ' For i in BEFOREAREA:BALLSTR = Ballstr + str (i) + ' ballstr = ballstr + ' | ' for i in afterarea:ballstr = Ballstr + St R (i) + ' ballstr = ballstr + ' n ' Self.text.insert (1.0, ballstr) root = Tk () app = app (root) root.title (' Lottery Machine selector ') Root.mai Nloop () |