首页 > > 详细

讲解matlab setdefaultencoding、matlab语言程序解析、调试matlab、matlab语言程序解析

#coding: utf8
import Tkinter as tk
from Tkinter import *
import tkMessageBox as tb
import sqlite3
import sys
CODINGING = 'utf8'
reload(sys)
sys.setdefaultencoding(CODINGING)
#conn = sqlite3.connect('D:\\11\\demo2.db')
#def getinfo():
#a = conn.execute('''select name,password from test''')
#info = []
#for x in a.fetchall():
#info.append({'name':str(x[0]),'password':str(x[1])})
#return info
def window_info():
ws = window.winfo_screenwidth()
hs = window.winfo_screenheight()
x = (ws / 2) - 200
y = (hs / 2) - 200
print("%d,%d" % (ws, hs))
return x,y
window = tk.Tk()
window.title('Weclome to Acquirer')
a,b=window_info()
window.geometry("450x300+%d+%d"%(a,b))
tk.Label(window,text=ur"Acquirer Login",font=(ur"",32)).place(x=80,y=50)
tk.Label(window,text=ur"Account:").place(x=120,y=150)
tk.Label(window,text=ur"Password:").place(x=120,y=190)
var_usr_name = tk.StringVar()
var_usr_name.set(u'admin1')
entry_usr_name=tk.Entry(window,textvariable=var_usr_name)
entry_usr_name.place(x=190,y=150)
var_usr_pwd = tk.StringVar()
entry_usr_pwd = tk.Entry(window,textvariable=var_usr_pwd,show='*')
entry_usr_pwd.place(x=190,y=190)
def usr_login():
usr_name = var_usr_name.get()
usr_pwd = var_usr_pwd.get()
dicts = [ {'name': 'admin1', 'password': '123456'} ,{'name': 'admin2', 'password': '111111'} ]
#dicts = getinfo()
bool = False
is_sign_up = False
for Dict in dicts:
if Dict['name'] == usr_name:
bool = True
break
if bool == True:
if Dict['password'] == usr_pwd:
tb.showinfo('Welcome','Hello ! '+ usr_name)
window.destroy()
else:
tb.showinfo('Wrong','Try again !')
else:
tb.askyesno(ur'Wrong', ur"You don't have an account yet ? Do you want to regisit now?")
is_sign_up = True
if is_sign_up:
usr_sign_up()
def usr_sign_up():
def sign_to_Pyhon():
nn = new_name.get()
np = new_pwd.get()
npc = new_pwd_confirm.get()
dicts = [ {'name': 'admin1', 'password': '123456'} ,{'name': 'admin2', 'password': '111111'} ]
#dicts = getinfo()
bool = False
for Dict in dicts:
if Dict['name'] == nn:
bool = True
if bool:
tb.showerror(ur'Sorry','This account is already exists!')
elif len(np) == 0:
tb.showinfo(ur'Sorry','Password can not be empty!')
elif np npc:
tb.showinfo(ur'Sorry','Two input passwords must be same!')
else:
try:
conn.execute('''insert into test(name,password) values('%s','%s')''' % (str(nn),str(np)));
conn.commit()
tb.showinfo(ur'Welcome','Regisit successed!')
window.destroy()
except:
tb.showerror((ur'Regisit failed!'))
window_sign_up = tk.Toplevel(window)
window_sign_up.geometry('350x200')
window_sign_up.title(ur'Regist')
new_name = tk.StringVar()
new_name.set('visitor01')
tk.Label(window_sign_up,text=ur'Account:').place(x=80,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=ur'Password:').place(x=80, 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=ur'Again:').place(x=80,y=90)
entry_usr_pwd_again = tk.Entry(window_sign_up,textvariable=new_pwd_confirm,show='*')
entry_usr_pwd_again.place(x=150, y=90)
btn_again_sign_up = tk.Button(window_sign_up,text=ur'Regist',command=sign_to_Pyhon)
btn_again_sign_up.place(x=160,y=130)
btn_login = tk.Button(window,text=ur"Login",command=usr_login)
btn_login.place(x=170,y=230)
btn_sign_up = tk.Button(window,text=ur"Regist",command=usr_sign_up)
btn_sign_up.place(x=270,y=230)
window.mainloop()
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!