本文实例讲述了Python实现彩票机选器的方法。分享给大家供大家参考。具体实现方法如下:
# -*- Coding: utf8 -*-from Tkinter @R_404_5565@ *@R_404_5565@ tkFont@R_404_5565@ randomclass 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='双色球',fg='red',Font=tkFont.Font(family='微软雅黑',size=20),wIDth=20,command=self.creatDouble) self.button1.pack(sIDe=left) self.button2 = button(frame[1],text='大乐透',fg='blue',command=self.creatDaleTou) self.button2.pack(sIDe=left) self.button3 = button(frame[2],text='清空',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 for 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(33,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(35,5) afterarea = self.creatRandum(12,2) ballstr = '' for i in beforeArea : ballstr = ballstr + str(i) + ' ' ballstr = ballstr + '|' for i in afterarea : ballstr = ballstr + str(i) + ' ' ballstr = ballstr + '\n' self.text.insert(1.0,ballstr)root = Tk()app = App(root)root.Title('彩票机选器')root.mainloop()
运行效果如下所示:
希望本文所述对大家的Python程序设计有所帮助。
总结以上是内存溢出为你收集整理的Python实现的彩票机选器实例全部内容,希望文章能够帮你解决Python实现的彩票机选器实例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)