python简单窗口制作

更新时间:2023-08-11 06:04:09 阅读: 评论:0

python简单窗⼝制作
依据:mofan python
代码来源:bilibili 视频
框架:tensorflow
库:tkinter(⽐较⽼,现在也有新的相关库)
(mofan python对于初学python,或者初⼊深度学习的伙伴们还是⽐较友好的。)
下图为实验结果图,可以点击下⽅两按钮,继续弹指令或操作。具体可在程序中更改窗⼝⼤⼩,相关指令,⽂字说明提⽰语等。
具体代码:
import tkinter as tk
from tkinter import messagebox  # import this to fix messagebox error
import pickle
window = tk.Tk()
window.title('Welcome to xiao Python')
# ur information
tk.Label(window, text='Ur name: ').place(x=50, y=150)
tk.Label(window, text='Password: ').place(x=50, y=190)
var_usr_name = tk.StringVar()
var_usr_name.t('')
entry_usr_name = tk.Entry(window, textvariable=var_usr_name)
entry_usr_name.place(x=160, y=150)
var_usr_pwd = tk.StringVar()
entry_usr_pwd = tk.Entry(window, textvariable=var_usr_pwd, show='*')
entry_usr_pwd.place(x=160, y=190)
def usr_login():
usr_name = var_()
usr_pwd = var_()
try:
with open('usrs_info.pickle','rb')as usr_file:
usrs_info = pickle.load(usr_file)
except FileNotFoundError:
with open('usrs_info.pickle','wb')as usr_file:
usrs_info ={'admin':'admin'}
pickle.dump(usrs_info, usr_file)
if usr_name in usrs_info:感觉的英文怎么写
jollyrogerif usr_pwd == usrs_info[usr_name]:
is_sign_up = tk.messagebox.askyesno('Welcome',
'You have not signed up yet. Sign up today?')treatment
if is_sign_up:
usr_sign_up()
def usr_sign_up():
def sign_to_Mofan_Python():
np = ()
pomelonpf = new_()
nn = ()
itgwith open('usrs_info.pickle','rb')as usr_file:
exist_usr_info = pickle.load(usr_file)
if np != npf:
阿玛尔克鲁尼el:
exist_usr_info[nn]= np
with open('usrs_info.pickle','wb')as usr_file:
pickle.dump(exist_usr_info, usr_file)
window_sign_up.destroy()
window_sign_up = tk.Toplevel(window)
新东方影院
window_ry('350x200')
window_sign_up.title('Sign up window')
new_name = tk.StringVar()
new_name.t('')
tk.Label(window_sign_up, text='Ur name: ').place(x=10, y=10)
entry_new_name = tk.Entry(window_sign_up, textvariable=new_name)
entry_new_name.place(x=150, y=10)
new_pwd = tk.StringVar()
tk.Label(window_sign_up, text='Password: ').place(x=10, y=50)
entry_usr_pwd = tk.Entry(window_sign_up, textvariable=new_pwd, show='*')六级考试流程
entry_usr_pwd.place(x=150, y=50)
new_pwd_confirm = tk.StringVar()
tk.Label(window_sign_up, text='Confirm password: ').place(x=10, y=90)
bendoverentry_usr_pwd_confirm = tk.Entry(window_sign_up, textvariable=new_pwd_confirm, show='*')
entry_usr_pwd_confirm.place(x=150, y=90)meltdown
btn_comfirm_sign_up = tk.Button(window_sign_up, text='Sign up', command=sign_to_Mofan_Python)    btn_comfirm_sign_up.place(x=150, y=130)
# login and sign up button
btn_login = tk.Button(window, text='Login', command=usr_login)
btn_login.place(x=170, y=230)
btn_sign_up = tk.Button(window, text='Sign up', command=usr_sign_up) btn_sign_up.place(x=270, y=230)
window.mainloop()
希望对⼤家有所帮助,⼀起加油!

本文发布于:2023-08-11 06:04:09,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1129198.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:指令   来源   有所
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图