Python tkinter布局與按鈕間距設(shè)置方式
新建label與button,并設(shè)置位置(grid)
import tkinter as tkroot = tk.Tk()label = tk.Label(root, text = ‘Label’)label.grid(column = 3, row = 8)button = tk.Button(root, text = ‘Button’)button.grid(column = 5, row = 1)
按鈕間距設(shè)置
col_count, row_count = root.grid_size()for col in xrange(col_count):root.grid_columnconfigure(col, minsize=20)for row in xrange(row_count):root.grid_rowconfigure(row, minsize=20)
補(bǔ)充知識(shí):Python 窗體(tkinter)按鈕 位置
我就廢話不多說(shuō)了,還是直接看代碼吧
import tkinter def go(): #函數(shù) print('go函數(shù)') win=tkinter.Tk() #構(gòu)造窗體win.title('hello zhaolin')#標(biāo)題win.geometry('800x800+300+0')#800寬度,800高度,x,y坐標(biāo),左上角button=tkinter.Button(win,text='有種點(diǎn)我',command=go) #收到消息執(zhí)行g(shù)o函數(shù)button.pack()#加載到窗體,button1=tkinter.Button(win,text='有種點(diǎn)',command= lambda :print('hello world'),width=20,height=10) button1.pack()#加載到窗體,#button.place(10,10)win.mainloop() #進(jìn)入消息循環(huán)機(jī)制
以上這篇Python tkinter布局與按鈕間距設(shè)置方式就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. Jsp中request的3個(gè)基礎(chǔ)實(shí)踐3. 解析原生JS getComputedStyle4. jsp實(shí)現(xiàn)登錄驗(yàn)證的過(guò)濾器5. msxml3.dll 錯(cuò)誤 800c0019 系統(tǒng)錯(cuò)誤:-2146697191解決方法6. 輕松學(xué)習(xí)XML教程7. jsp+servlet簡(jiǎn)單實(shí)現(xiàn)上傳文件功能(保存目錄改進(jìn))8. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)9. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對(duì)象Application和Session)10. ASP基礎(chǔ)知識(shí)Command對(duì)象講解
