怎么用PYTHON做游戏登录界面

 代码如下:

 

'''zy小游戏'''
'''66666666'''
from platform import java_ver

import tkinter

import tkinter.simpledialog

import sys

import webbrowser




root = tkinter.Tk()

root.minsize(30,30)
 
# 创建函数
def askname():
    # 获取字符串(标题,提示,初始值)
    result = tkinter.simpledialog.askstring(title = '获取信息',prompt='请输入姓名:',initialvalue = '')
    # 打印内容
    print(result)

    if result == "zy":
    
 
# 创建主窗口
        root = tkinter.Tk()
# 设置窗口大小
        root.minsize(30,30)
 
# 创建函数
        def askname():
    # 获取字符串(标题,提示,初始值)
            result = tkinter.simpledialog.askstring(title = '获取信息',prompt='请输入密码:',initialvalue = '')
    # 打印内容
            print(result)

            if result =='zy':

                root = tkinter.Tk()
# 设置窗口大小
                root.minsize(30,30)

                def askname():

                        result = tkinter.simpledialog.askstring(title = '获取信息',prompt='游戏',initialvalue = '')

                        print(result)

                        if result == '1':  

                                sys.path.append("libs")

                                url = 'https://html5games.com/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '2':

                                sys.path.append("libs")

                                url = 'https://code.visualstudio.com/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '3':

                                sys.path.append("libs")

                                url = 'https://www.python.org/'

                                webbrowser.open(url)

                                print(webbrowser.get())


                        elif result == '4':

                                sys.path.append("libs")

                                url = 'edge://surf/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '5':
                                sys.path.append("libs")

                                url = 'https://www.runoob.com/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '6':

                                sys.path.append("libs")

                                url = 'https://next.itellyou.cn/Original/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '7':

                                sys.path.append("libs")

                                url = 'https://python666.cn/cls/lesson/2/'

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '8':

                                sys.path.append("libs")

                                url = ''

                                webbrowser.open(url)

                                print(webbrowser.get())

                        elif result == '9':

                                sys.path.append("libs")

                                url = ''

                                webbrowser.open(url)

                                print(webbrowser.get())
                        
                btn = tkinter.Button(root,text = '游戏名',command = askname)
                
                btn.pack()

                root.mainloop()

        btn = tkinter.Button(root,text = '用户密码',command = askname)

        btn.pack()
 
# 加入消息循环
        root.mainloop()
# 添加按钮
btn = tkinter.Button(root,text = '获取用户名',command = askname)

btn.pack()
 
# 加入消息循环
root.mainloop()

 

你可能感兴趣的:(python,游戏,开发语言)