python -猜字小游戏
代码运行效果如下:

注意:
1.必须要在python3环境想使用
2.QQ:3084276329(一起交流学习)
3.还请大家评论
Guess the word game代码如下:
#! /usr/bin/env python
# -*- coding: utf- -*-
# Guess the word game
# 博客:https://www.cnblogs.com/muxii
# 那个木兮啊
import tkinter
import threading
import time
from tkinter import *
from tkinter import messagebox
from tkinter import messagebox root = tkinter.Tk()
root.title('那个木兮啊-Guess the word')
root.minsize(,) label =(root)
label = Label(root,text = '博客:https://www.cnblogs.com/muxii/\nQQ:3084276329\n—-————那个木兮啊——-———',font = ('微软雅黑',),fg = 'red')
label.grid(row = ,column =)
btn1 = tkinter.Button(root,text ='',width = ,height =,bg='blue')
btn1.place(x=,y=)
btn2 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn2.place(x=,y=)
btn3 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn3.place(x=,y=)
btn4 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn4.place(x=,y=)
btn5 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn5.place(x=,y=)
btn6 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn6.place(x=,y=)
btn7 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn7.place(x=,y= )
btn8 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn8.place(x=,y=)
btn9 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn9.place(x=,y= )
btn10 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn10.place(x=,y=)
btn11 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn11.place(x=,y=)
btn12 = tkinter.Button(root,text = '',width = ,height =,bg ='white')
btn12.place(x=,y=)
herolists = [btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn11] isloop = False stopsing = False
#定义停止id
stopid = None #定义函数,循环选项 设置背景颜色,选中的为红色,
def round():
global isloop
global stopid
if isloop ==True:
return
i =
#判断一个对象是否已经类型 type
#考虑继承关系
if isinstance(stopid,int):
i = stopid while True:
#
time.sleep(0.05)#延时
for x in herolists:
x['bg'] = 'white' herolists[i]['bg'] ='blue' i += if i >= len(herolists):
i = if stopsing == True:
isloop =False
stopid = i
break #停止
def stop1(): global stopsing if stopsing == True:
return
stopsing = True #开始
def newtask():
global isloop
global stopsing
stopsing = False
#建立线程
t = threading.Thread(target = round )
t.start()
isloop = True btn_start = tkinter.Button(root,text = '开始',bg = 'red',command = newtask)
btn_start.place(x=,y=)
#
btn_stop = tkinter.Button(root,text = '结束',bg = 'yellow',command = stop1)
btn_stop.place(x=,y= ) root.mainloop()
2018.8.3
python -猜字小游戏的更多相关文章
- LY.猜字小游戏
猜字小游戏
- Demo_2:Qt实现猜字小游戏
1 环境 系统:windows 10 代码编写运行环境:Qt Creator 4.4.1 (community) Github: 2 简介 参考视频:https://www.bilibili.co ...
- Python猜数小游戏
使用random变量随机生成一个1到100之间的数 采集用户所输入的数字,如果输入的不符合要求会让用户重新输入. 输入符合要求,游戏开始.如果数字大于随机数,输出数字太大:如果小于随机数,输出数字太小 ...
- 初识python: while循环 猜年龄小游戏
知识点: 1.python注释方法: 单行注释: # 多行注释: '''注释内容 ''' (单引号或双引号都可以),亦可打印多行 例: #此处是单行注释信息 print('这里是打印内容') #这里 ...
- 简单的猜数字小游戏--Python
猜数字小游戏: #coding=utf-8 import random answer =random.randint(1,100) #生成随机数 n=int (input("Please ...
- 关于切片/截取(slice)和random模块的使用(实例:猜单词小游戏)
切片和random的使用在源码中都有注释(可以直接下载):https://github.com/NoobZeng/GuessWords 1. README.MD 基于Python的猜单词游戏 猜单词小 ...
- day06-java-(方法,猜字符小游戏)
day05-java-(方法,猜字符小游戏) 1.方法: 1)用于封装一段特定的逻辑功能 2)方法应尽可能的独立,只干一件事 3)方法可以被反复的调用多次 4)避免代码重复,有利于代码的维护, ...
- Java基础知识强化之IO流笔记70:Properties练习之 如何让猜数字小游戏只能玩5次的案例
1. 使用Properties完成猜数字小游戏只能玩5次的案例: 2. 代码实现: (1)猜数字游戏GuessNumber: package cn.itcast_08; import java.uti ...
- java猜数字小游戏
/* * * 猜数字小游戏 * * 先由系统生成一个2-100之间的随机数字, * * 然后捕获用户从控制台中输入的数字是否与系统生成的随机数字相同, * * 如果相同则统计用户所猜的次数,并给出相应 ...
随机推荐
- python学习 day22 (3月29日)----(生成器推导式)
新手上路请多担待 1 2 封装 3 私有化封装 #__author : 'liuyang' #date : 2019/3/29 0029 上午 9:35 # 不想让别人看 修改 我的属性 # 源码来说 ...
- floor函数
C++中 可以用floor函数来截断小数部分 floor(x)返回一个不大于x的整数,有点像取整函数
- iOS知识基础篇--@property,@synthesize, nonatomic,atomic,strong,weak,copy,assign,retain详解
一.@property 这个关键词的唯一作用就是声明getter.setter方法接口. 二.@synthesize 实现setter.getter方法,找不到实例变量则主动创建一个. 三.nonat ...
- hdu-1036(格式题+精确度)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1036 心得:注意,要进行四舍五入的精确可以用+0.5实现. #include<iostream& ...
- 容器监控告警方案(cAdvisor + nodeExporter + alertmanager + prometheus +grafana)
一.prometheus基本架构 Prometheus 是一套开源的系统监控报警框架.它启发于 Google 的 borgmon 监控系统,由工作在 SoundCloud 的 google 前员工在 ...
- error C4430: error 2141
c:\evan\workspace\1\1\netwowkippack.h(50) : error C2146: 语法错误 : 缺少“;”(在标识符“nSourPort”的前面) c:\evan\wo ...
- 第28章:MongoDB-索引--过期索引(TTL)
①过期索引(TTL) TTL索引是让文档的某个日期时间满足条件的时候自动删除文档,这是一种特殊的索引,这种索引不是为了提高查询速度的,TTL索引类似于缓存,缓存时间到了就过期了,就要被删除了 ②范例: ...
- 返回结点值为e的二叉树指针
题意为,如果二叉树某结点的值为e(假定是整型二叉树),返回这个结点的指针.初看这道题,联想到二叉树可以很简单的遍历,直接返回这个指针不就行了吗?如下图所示,假如要返回值为3的结点指针: 设计好了一个函 ...
- 1.2.4注意Sysyem.out.println与i--
package com.cky.thread; /** * Created by chenkaiyang on 2017/11/27. */ public class MyThreadThird ex ...
- Ng第十二课:支持向量机(Support Vector Machines)(三)
11 SMO优化算法(Sequential minimal optimization) SMO算法由Microsoft Research的John C. Platt在1998年提出,并成为最快的二次规 ...