我的第一個登陸界面:
import tkinter
import tkinter.messagebox
root=tkinter.Tk()
root.title('學生選課管理系統')
root['height']=330
root['width']=450
labelName=tkinter.Label(root,text='用戶名:',justify=tkinter.RIGHT,width=80)
labelName.place(x=10,y=5,width=80,height=20)
varName=tkinter.StringVar(root,value='')
entryName=tkinter.Entry(root,width=80,textvariable=varName)
entryName.place(x=100,y=5,width=80,height=20)
labelPwd=tkinter.Label(root,text='密 碼:',justify=tkinter.RIGHT,width=80)
labelPwd.place(x=10,y=30,width=80,height=20)
varPwd=tkinter.StringVar(root,value='')
entryPwd=tkinter.Entry(root,show='*',width=80,textvariable=varPwd)
entryPwd.place(x=100,y=30,width=80,height=20)
def login():
name=entryName.get()
pwd=entryPwd.get()
if name=='admin'and pwd=='123456':
tkinter.messagebox.showinfo(title='恭喜',message='登錄成功!')
else:
tkinter.messagebox.showerror('警告',message='用戶名或密碼錯誤')
buttonOk=tkinter.Button(root,text='登錄',command=login)
buttonOk.place(x=30,y=70,width=50,height=20)
def cancel():
varName.set('')
varPwd.set('')
buttonCancel=tkinter.Button(root,text='取消',command=cancel)
buttonCancel.place(x=90,y=70,width=50,height=20)
root.mainloop()
我的主界面:
import sqlite3
conn = sqlite3.connect("D:123123.db")
print("資料庫連接成功!");
print("\t\t通訊錄管理")
while True:
print("1.新建",end='')
print("2.查找",end='')
print("3.添加",end='')
print("4.修改",end='')
print("5.洗掉",end='')
print("6.排序",end='')
print("0.退出",end='')
choice=int (input("請輸入你的選擇(0~7)"))
if(choice==0):
break;
if(choice<0 or choice>7):
print("輸入非法,請重新輸入!")
continue
if(choice==1):
conn.execute('''CREATE TABLE MYADDRESS
(ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
TELEPHONE TEXT NOT NULL,
EMAIL TEXT,
ADDRESS TEXT,
WEICHART TEXT,
QQ TEXT);''')
print("成功建立通訊錄資料庫表!")
elif(choice==2):
。。。。。。。
。。。。。。。
然后不知道怎么連接起來,求解求解!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/119276.html
