用户:星落黑影目前已退查看:0 回复:1 评论:0 创建时间:2019-01-28T10:42:51
近日一朋友做了我的世界窗口程序,代码如下:
#CODE_MYTHIC制作
import tkinter as tk
import pickle
from tkinter import messagebox
window = tk.Tk()
window.title("Minecraft 1.13.2")
window.geometry("550x350")
def menu():
l = tk.Label(window, text = "MINECRAFT")
l.place(x = 200, y = 50)
def s():
l.destroy()
b1.destroy()
b2.destroy()
b3.destroy()
b4.destroy()
lb2 = tk.Label(window, text = "世界")
lb2.place(x = 255, y = 0)
name = tk.StringVar()
lb = tk.Listbox(window, listvariable = name, height = 5)
lb.place(x = 150, y = 50)
def c():
b5.destroy()
b6.destroy()
lb.destroy()
b7.destroy()
lb2.destroy()
wn = tk.Entry(window)
wn.place(x = 150, y = 100)
cl = tk.Label(window, text = "输入世界名字")
cl.place(x = 210, y = 55)
def b2():
wn.destroy()
b8.destroy()
b9.destroy()
cl.destroy()
s()
def cc():
world_name = wn.get()
if world_name == "":
messagebox.showerror(message = "世界名字不能为空")
else:
with open("WorldName.pickle", "wb") as file:
pickle.dump(world_name, file)
b2()
b8 = tk.Button(window, text = "取消", width = 15, command = b2)
b8.place(x = 300, y = 200)
b9 = tk.Button(window, text = "创建", width = 15, command = cc)
b9.place(x = 35, y = 200)
b6 = tk.Button(window, text = "创建世界", width = 15, command = c)
b6.place(x = 45, y = 225)
def b():
b5.destroy()
b6.destroy()
b7.destroy()
lb.destroy()
lb2.destroy()
menu()
b5 = tk.Button(window, text = "返回", width = 15, command = b)
b5.place(x = 300, y = 225)
def d():
pass
b7 = tk.Button(window, text = "删除世界", width = 15, command = d)
b7.place(x = 160, y = 285)
b1 = tk.Button(window, text = "单人游戏", width = 20, command = s)
b1.place(x = 125, y = 100)
def m():
messagebox.showinfo(message = "敬请期待")
b2 = tk.Button(window, text = "多人游戏", width = 20, command = m)
b2.place(x = 125, y = 160)
def o():
messagebox.showinfo(message = "敬请期待")
b3 = tk.Button(window, text = "设置", width = 10, command = o)
b3.place(x = 115, y = 220)
def q():
window.destroy()
b4 = tk.Button(window, text = "退出", width = 10, command = q)
b4.place(x = 275, y = 220)
window.mainloop()
menu()