经过无数次修改的Gui猜数字游戏
上代码:from tkinter import *
from tkinter import messagebox as m
import random
root = Tk()
root.title("猜数字")
root.geometry("250x150")
TIME = 0
answer = random.randint(1,100)
gepi = ('个屁,正确答案是',answer)
def check():
eg = int(en.get())
global TIME
TIME += 1
if TIME > 5:
m.showinfo('正确','恭喜你答对了')
m.showinfo('个屁',gepi)
root.destroy()
elif eg == answer:
m.showinfo('正确','恭喜你答对了')
root.destroy()
elif (eg > 100)or(eg < 1):
m.showinfo('输入错误','请输入1~100的整数')
elif eg > answer:
m.showinfo('错误','你猜大了')
elif eg < answer:
m.showinfo('错误','你猜小了')
la = Label(root,text='1~100选一个数',font=('华文行楷',15))
la.place(x=50,y=0)
en = Entry(root,font=('华文行楷',15))
en.place(x=20,y=50)
bu = Button(root,text='提交',font=('华文行楷',15),command=check)
bu.place(x=90,y=90)
root.mainloop()
如果喜欢,不要忘了长按,点赞,三连
呸呸呸
不要忘了点赞,评分
如果有建议,不要忘了私信 如果喜欢,不要忘了长按,点赞,三连B i l i b i l i 化 {:10_256:} 完了,点错了{:10_266:} 论坛逐渐bilibili化。。。 乘号 发表于 2020-4-16 08:59
论坛逐渐bilibili化。。。
記得點讚,訂閱,開啟小鈴鐺 老八秘制 发表于 2020-4-16 08:47
完了,点错了
没事,我帮他加上去 稍微修改一下代碼:
from tkinter import *
from tkinter import messagebox as m
import random
root = Tk()
root.title("猜数字")
root.geometry("250x150")
TIME = 0
answer = random.randint(1,100)
gepi = ('个屁,正确答案是',answer)
def check():
eg = int(en.get())
global TIME
TIME += 1
if TIME > 5:
m.showinfo('正确','恭喜你答对了')
m.showinfo('个屁',gepi)
root.destroy()
elif eg == answer:
m.showinfo('正确','恭喜你答对了')
root.destroy()
elif (eg > 100)or(eg < 1):
m.showinfo('输入错误','请输入1~100的整数')
elif eg > answer:
m.showinfo('错误','你猜大了')
elif eg < answer:
m.showinfo('错误','你猜小了')
Label(root, text = '1~100选一个数', bg = 'yellow', fg = 'blue',
font = ('华文行楷', 15)).place(x = 50, y = 0)
a = Entry(root, bg = 'yellow', fg = 'blue', font = ('华文行楷', 15))
a.place(x = 20, y = 50)
b = Button(root, text='提交', bg = 'yellow', fg = 'blue', font = ('华文行楷', 15), command = check)
b.place(x = 80, y = 90)
root.mainloop()
我来凑热闹啦~~~~~~
{:10_297:} 我这个才叫终极版。
戳我前进
{:5_109:}
页:
[1]