創(chuàng)新互聯(lián)www.cdcxhl.cn八線動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買多久送多久,劃算不套路!
這篇文章將為大家詳細(xì)講解有關(guān)如何實(shí)現(xiàn)基于Python的自媒體小助手---登錄頁面,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
核心技術(shù):Python3.7
GUI技術(shù):Tkinter (Python已經(jīng)內(nèi)置)
1、窗體設(shè)置標(biāo)題和設(shè)置圖標(biāo),圖標(biāo)格式是ICO的,一般我們事宜Png轉(zhuǎn)一下。https://www.easyicon.net/covert/ 這是轉(zhuǎn)換的網(wǎng)址。
2、Tkinter輸入控件、標(biāo)簽控件、按鈕控件、復(fù)選框控件,我就不多說了網(wǎng)上有很多。需要注意的是密碼顯示要用show=‘*'
3、Tkinter 的place部局,就是絕對(duì)定位,因?yàn)椴辉试S改變大小就絕對(duì)定位了。
4、按鈕事件傳參數(shù)需要使用lambda表達(dá)式。
5、背景色采用的是白色所以Lable的背景色都采用了白色。
6、最后一個(gè)就是屏幕居中,這個(gè)網(wǎng)上也一堆大家自己百度吧。
代碼如下:
import tkinter as tk import tkinter.font as tkFont from tkinter import messagebox class LoginView(): window = tk.Tk() def __init__(self): self.initializeUI() def initializeUI(self): self.window.iconbitmap("./resource/icon/hunter.ico") self.window.title('獵人村自媒體小助手平臺(tái)登錄') background_color="white" self.window.configure(background=background_color) #self.window.overrideredirect(True) photo = tk.PhotoImage(file="./resource/images/hunter.png") label = tk.Label(image=photo,width=32, bg=background_color) label.image = photo label.place(x=60,y=40) ft = tkFont.Font(family='Fixdsys', size=16, weight=tkFont.BOLD) tk.Label(self.window, text="獵人村自媒體小助手",font=ft, bg=background_color).place(x=100,y=44) photo = tk.PhotoImage(file="./resource/images/splitline.png") label = tk.Label(image=photo) label.image =photo label.place(x=0,y=90) # 標(biāo)簽 用戶名密碼 #F3F3F4 entryBackGroundColor="#F3F3F4" userNameFont = tkFont.Font(family='Fixdsys', size=10) tk.Label(self.window, text='請輸入用戶名:',font=userNameFont, bg=background_color).place(x=20, y=150) userName = tk.StringVar() tk.Entry(self.window, highlightthickness=1,bg=entryBackGroundColor,textvariable =userName).place(x=20, y=180,width=320, height=30) passWordFont = tkFont.Font(family='Fixdsys', size=10) passWord = tk.StringVar() # tk.Label(self.window, text='請輸入密碼:',font=passWordFont, bg=background_color).place(x=20, y=220) tk.Entry(self.window, highlightthickness=1, bg=entryBackGroundColor,textvariable =passWord, show='*').place(x=20, y=250,width=320, height=30) remeberMeFont=tkFont.Font(family='Fixdsys', size=12) tk.Checkbutton(self.window, text="記住我",fg="#0081FF",variable="0",font=remeberMeFont, bg=background_color).place(x=20, y=300) tk.Button(self.window, text='立即登錄', font=('Fixdsys', 14, 'bold'), width=29,fg='white',bg="#0081FF",command=lambda :self.login(userName,passWord)).place(x=20, y=330) regester_info=tkFont.Font(family='Fixdsys', size=10) tk.Label(self.window, text='還沒有賬號(hào)?:', font=regester_info, bg=background_color).place(x=102,y=375) tk.Label(self.window, text='立即注冊', font=regester_info, bg=background_color,fg="#FFA500").place(x=185,y=375) w = 370 h = 480 sw = self.window.winfo_screenwidth() # 得到屏幕寬度 sh = self.window.winfo_screenheight() # 得到屏幕高度 # 窗口寬高為100 x = (sw - w) / 2 y = (sh - h) / 2 self.window.geometry("%dx%d+%d+%d" % (w, h, x, y)) self.window.mainloop() pass def login(self,userName,passWord): errMessage="" if len(userName.get())==0: errMessage=errMessage+"用戶名不能為空!\r" if len(passWord.get())==0: errMessage=errMessage+"密碼不能為空!" if errMessage!="": messagebox.showinfo('提示', errMessage) print(passWord.get()) pass
分享標(biāo)題:如何實(shí)現(xiàn)基于Python的自媒體小助手---登錄頁面-創(chuàng)新互聯(lián)
文章來源:http://jinyejixie.com/article18/digjdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、企業(yè)建站、ChatGPT、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容