資源簡介
Python 簡單的登錄界面源碼,希望大家多多指教指教。。。。
代碼片段和文件信息
import?tkinter?as?tk
import?pymysql.cursors
from?tkinter?import?messagebox
def?center_window(root?width?height):??
????screenwidth?=?root.winfo_screenwidth()??
????screenheight?=?root.winfo_screenheight()??
????size?=?‘%dx%d+%d+%d‘?%?(width?height?(screenwidth?-?width)/2?(screenheight?-?height)/2)??
????print(size)??
????root.geometry(size)??
window?=?tk.Tk()
window.title(‘uiw?財務(wù)系統(tǒng)?V2.1.3‘)
center_window(window900600)
#?welcome?image
canvas?=?tk.Canvas(window?height=400?width=900)#創(chuàng)建畫布
image_file?=?tk.PhotoImage(file=‘E:/python/www/uiw_login_message.png‘)#加載圖片文件
image?=?canvas.create_image(00?anchor=‘nw‘?image=image_file)#將圖片置于畫布上
canvas.pack(side=‘top‘)#放置畫布(為上端)
?
#?user?information
tk.Label(window?text=‘UserName:?‘).place(x=250?y=?400)#創(chuàng)建一個‘label‘名為‘User?name:?‘置于坐標(biāo)(50150)
tk.Label(window?text=‘PassWord:?‘).place(x=250?y=?430)
var_usr_name?=?tk.StringVar()
var_usr_pwd?=?tk.StringVar()
entry_usr_name?=?tk.Entry(window?textvariable=var_usr_name).place(x=350?y=?400)#創(chuàng)建一個‘entry‘,顯示為變量‘var_usr_name‘即圖中的‘example@python.com‘
entry_usr_pwd?=?tk.Entry(window?textvariable=var_usr_pwd?show=‘-‘).place(x=350?y=?430)#‘show‘這個參數(shù)將輸入的密碼變?yōu)椤?**‘的形式
def?usr_login():
user_name?=?v
- 上一篇:python編程小游戲漢諾塔hanoi
- 下一篇:微博圖片視頻小爬蟲
評論
共有 條評論