python 转盘 圆形,用python实现一个转盘-程序员宅基地

技术标签: python 转盘 圆形  

用python实现一个转盘

发布时间:2019-09-22 08:09:12编辑:auto阅读(624)

#抽奖 面向对象版本

import tkinter

import time

import threading

class choujiang:

#初始化魔术方法

def __init__(self):

#准备好界面

self.root = tkinter.Tk()

self.root.title('lowB版转盘')

self.root.minsize(300, 300)

# 声明一个是否按下开始的变量

self.isloop = False

self.newloop = False

#调用设置界面的方法

self.setwindow()

self.root.mainloop()

#界面布局方法

def setwindow(self):

#开始停止按钮

self.btn_start = tkinter.Button(self.root, text = 'start/stop',command = self.newtask)

self.btn_start.place(x=90, y=125, width=50, height=50)

self.btn1 = tkinter.Button(self.root, text='赵', bg='red')

self.btn1.place(x=20, y=20, width=50, height=50)

self.btn2 = tkinter.Button(self.root, text='钱', bg='white')

self.btn2.place(x=90, y=20, width=50, height=50)

self.btn3 = tkinter.Button(self.root, text='孙', bg='white')

self.btn3.place(x=160, y=20, width=50, height=50)

self.btn4 = tkinter.Button(self.root, text='李', bg='white')

self.btn4.place(x=230, y=20, width=50, height=50)

self.btn5 = tkinter.Button(self.root, text='周', bg='white')

self.btn5.place(x=230, y=90, width=50, height=50)

self.btn6 = tkinter.Button(self.root, text='吴', bg='white')

self.btn6.place(x=230, y=160, width=50, height=50)

self.btn7 = tkinter.Button(self.root, text='郑', bg='white')

self.btn7.place(x=230, y=230, width=50, height=50)

self.btn8 = tkinter.Button(self.root, text='王', bg='white')

self.btn8.place(x=160, y=230, width=50, height=50)

self.btn9 = tkinter.Button(self.root, text='冯', bg='white')

self.btn9.place(x=90, y=230, width=50, height=50)

self.btn10 = tkinter.Button(self.root, text='陈', bg='white')

self.btn10.place(x=20, y=230, width=50, height=50)

self.btn11 = tkinter.Button(self.root, text='褚', bg='white')

self.btn11.place(x=20, y=160, width=50, height=50)

self.btn12 = tkinter.Button(self.root, text='卫', bg='white')

self.btn12.place(x=20, y=90, width=50, height=50)

# 将所有选项组成列表

self.girlfrends = [self.btn1,self.btn2,self.btn3,self.btn4,self.btn5,self.btn6,self.btn7,self.btn8,self.btn9,self.btn10,self.btn11,self.btn12]

def rounds(self):

# 判断是否开始循环

if self.isloop == True:

return

# 初始化计数 变量

i = 0

# 死循环

while True:

if self.newloop == True:

self.newloop = False

return

# 延时操作

time.sleep(0.1)

# 将所有的组件背景变为白色

for x in self.girlfrends:

x['bg'] = 'white'

# 将当前数值对应的组件变色

self.girlfrends[i]['bg'] = 'red'

# 变量+1

i += 1

# 如果i大于最大索引直接归零

if i >= len(self.girlfrends):

i = 0

# 建立一个新线程的函数

def newtask(self):

if self.isloop == False:

# 建立线程

t = threading.Thread(target = self.rounds)

# 开启线程运行

t.start()

# 设置循环开始标志

self.isloop = True

elif self.isloop == True:

self.isloop = False

self.newloop = True

c = choujiang()

关键字:

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_42478330/article/details/116172343

智能推荐

Java编程之伪共享与缓存行填充-程序员宅基地

文章浏览阅读165次。最近在回顾Disruptor的相关知识,觉得Disruptor在计算机底层的领域确实比一般人厉害不少,以前在写程序的时候,基本是从应用逻辑的角度考虑,觉得设计模式+少量算法+ 优美的代码=理想的结果,但看完Disruptor的设计后,觉得只考虑应用本身是有一定的局限性,还需要懂底层,硬件层面的东西,就像Disruptor一样,通过底层优化,让程序有质的飞跃。下面就Disruptor提到的CPU缓存话题,做了一些尝试和研究,如Disruptor所说,CPU有缓存伪共享的问题,并且通过缓存行填充能完美的解决这

使用sqlyog 把excel数据导入到数据表中_sqlyog怎么将excel导入到表中-程序员宅基地

文章浏览阅读1.8k次。使用sqlyog 把excel数据导入到数据表中先说一点注意事项, 我的电脑中最开始装的是 office 2010, 是的没错, 都2020年12月份了, 我还在用 office 2010 因为它是一个破解版的, 不用去找激活码, 所以就一直在用当我使用我的 sqlyog 来导入excel 数据表的时候, sqlyog 给我报错说一个AccessDatabaseEngine_X64.exe文件没有安装, 但是 office 2010是 32位的, 又装不了这个, 所以最终只有卸载了 office ._sqlyog怎么将excel导入到表中

C语言绘图_c语言画图像-程序员宅基地

文章浏览阅读938次,点赞4次,收藏2次。在C语言中使用OpenGL进行绘图,首先需要包含OpenGL的头文件,并初始化OpenGL。然后,你可以使用OpenGL的函数来创建和操作图形对象,例如多边形、线条、圆形等等。但是,你可以使用外部库来进行绘图,比如SDL,OpenGL,或者Windows的GDI库。此外,除了以上提到的SDL和OpenGL,还有许多其他的C语言绘图库可供选择。以上这些是常见的C语言绘图库,每个库都有其独特的特点和优势,你可以根据自己的需求选择适合自己的库。首先,你需要在你的计算机上安装SDL库。来设置渲染颜色,然后使用。_c语言画图像

2022年6月TIOBE编程语言排名:Python、C、Java_tiobe 语言排名-程序员宅基地

文章浏览阅读4.3k次。2022年6月TIOBE编程语言排名:Python、C、Java。6 月榜单中TIOBE 官方用“C++ 即将超越 Java”为标题凸显出了最大的变化,早在2021年,Python 在人工智能这条大船下势不可挡也超越了Java,Java排名第三。_tiobe 语言排名

无法定位软件包,Ubuntu_unable to locate package libxcb-xinerama0-程序员宅基地

文章浏览阅读629次。无法定位软件包,Ubuntu。_unable to locate package libxcb-xinerama0

设置Intellij IDEA中全文搜索的file mask属性,让搜索更方便!_idea file mask-程序员宅基地

文章浏览阅读5.8k次,点赞10次,收藏11次。最近IDEA换成了2021.1版本,在进行全局搜索的时候发现file mask中是空的,这就让我很难受,必须整回来修改步骤:1.找到IDEA的配置文件find.xml我的路径是:C:\Users\Letsuner\AppData\Roaming\JetBrains\IntelliJIdea2021.1\options【每个人的可能不一样】奉劝一句:不要直接在C盘搜索find.xml,你会发现搜了个寂寞,推荐使用Everything【秒出搜索结果】2.修改配置文件并保存<applicat_idea file mask

随便推点

自定义对话框——7种_没有窗口时如何定义对话框的所有者-程序员宅基地

文章浏览阅读829次。Activities提供了一种方便管理的创建、保存、回复的对话框机制,例如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog(int), dismissDialog(int)等方法,如果使用这些方法的话,Activity将通过getOwnerActivity()方法返回该Activity管理的对话框(dialog)._没有窗口时如何定义对话框的所有者

求基于图像处理的身份证号码识别的程序-程序员宅基地

文章浏览阅读1.6k次。要求是MATLAB编写的根据身份证号码来进行识别,0~9和一个x来进行识别(不是通过姓名(汉字))识别要求最后能显示详细信息例如姓名:性别:身份证号:籍贯:

探索ArcMap2SLD:GIS领域的效率提升利器-程序员宅基地

文章浏览阅读193次,点赞3次,收藏6次。探索ArcMap2SLD:GIS领域的效率提升利器项目地址:https://gitcode.com/sufan89/ArcMap2SLD项目简介ArcMap2SLD 是一个基于Python编写的开源工具,专为地理信息系统(GIS)用户设计。它旨在帮助用户将ArcGIS ArcMap中的图层样式快速转换为可共享的 Styled Layer Descriptor (SLD) 格式,从而实现地图样...

GetSecurityInfo-程序员宅基地

文章浏览阅读2.5k次。ISecurityInformation::GetSecurity 该函数通过句柄找到某一对象,并获取该对象的安全描述符。DWORD GetSecurityInfo( HANDLE handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID* ppsidOwner,_getsecurityinfo

【uni-app基础教程】_uniapp教程-程序员宅基地

文章浏览阅读6.7k次,点赞6次,收藏24次。uni-app基础教程_uniapp教程

LeetCode 89: Gray Code-程序员宅基地

文章浏览阅读80次。题目描述java实现class Solution { public List<Integer> grayCode(int n) { List<Integer> result = new LinkedList<>(); //1<<2 = 100(4) for (int i = 0; i &l...