最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python tkinter中的錨點(diǎn)(anchor)問題及處理

 更新時(shí)間:2022年06月20日 15:36:02   作者:未名編程  
這篇文章主要介紹了python tkinter中的錨點(diǎn)(anchor)問題及處理方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

tkinter的錨點(diǎn)(anchor)問題

tkinter中anchor參數(shù)

(注意,參數(shù)的英文都是小寫)

字母方位
n
s
w西
e
center中心
nw西北
ne東北
sw西南
se東南
from tkinter import *
from tkinter import messagebox as box
def main_menu():
    window = Tk()
    window.title('Juke Box')
    window.geometry('800x480')
    window.configure(background = 'black')
    label = Label(window, text = 'Juke-Box', fg = 'light green', bg = 'black', font = (None, 30), height = 2)
    label.pack(side = TOP)
    Jam = Button(window, text = 'The Jam', width = 25, height = 2)
    Jam.pack(pady = 10, padx = 25, anchor = 'n')
    Roses = Button(window, text = 'The Stone Roses', width = 25, height = 2)
    Roses.pack(pady = 10, padx = 25, anchor = 'w')
    Smiths = Button(window, text = 'The Smiths', width = 25, height = 2)
    Smiths.pack(pady = 10, padx = 25, anchor = 'w')
    Wedding = Button(window, text = 'The Wedding Pressent', width = 25, height = 2)
    Wedding.pack(pady = 10, padx = 25, anchor = 'w')
    Blondie = Button(window, text = 'Blondie', width = 25, height = 2)
    Blondie.pack(pady = 10, padx = 25, anchor = 'w')
    Clash = Button(window, text = 'Clash', width = 25, height = 2)
    Clash.pack(pady = 10, padx = 25, anchor = 'w')
    Madness = Button(window, text = 'Madness', width = 25, height = 2)
    Madness.pack(pady = 10, padx = 25, anchor = 'n')
    Pistols = Button(window, text = 'The Sex Pistols', width = 25, height = 2)
    Pistols.pack(pady = 10, padx = 25, anchor = 'n')
    window.mainloop()
main_menu()

幾何管理方法place中anchor的含義

關(guān)于place的用法,重點(diǎn)在于理解anchor的用法。

在一個(gè)大矩形中準(zhǔn)確地定義一個(gè)小矩形(有面積,不是點(diǎn))的位置,需要知道三個(gè)信息:一是坐標(biāo)系定義,二是坐標(biāo)數(shù)據(jù),三是要在小矩形上指定一個(gè)定位點(diǎn)。原點(diǎn)和坐標(biāo)系完全是系統(tǒng)默認(rèn)的定義方式,即原點(diǎn)在master控件的左上角,向右向下為正。

坐標(biāo)數(shù)據(jù)以相對形式給出,取0到1之間的浮點(diǎn)數(shù)。如果取0,則參考點(diǎn)橫坐標(biāo)為0(在最左側(cè)),如果取1,則參考點(diǎn)橫坐標(biāo)為master控件的最右側(cè),縱坐標(biāo)也是如此。

定位點(diǎn)anchor的定義,這個(gè)是最終定位的關(guān)鍵。如圖:

如圖,定義位置時(shí),以master控件的左上角為原點(diǎn),以給定的相對坐標(biāo)(這里都是0.5)指定位置。

每個(gè)控件都有9個(gè)anchor,選一個(gè)作為“把手”,將這個(gè)“把手”安放在指定位置即可。

anchor='nw’的含義是“將控件的左上角安放在指定位置”。

再如:

anchor='n’的含義是“將控件的上邊中點(diǎn)安放在指定位置”,其他的anchor同理。這可能就是為什么很多python技術(shù)文檔中,習(xí)慣先指定坐標(biāo),最后再選擇anchor。

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

广饶县| 建水县| 抚远县| 辰溪县| 邓州市| 阿巴嘎旗| 怀宁县| 阳原县| 调兵山市| 桂平市| 合肥市| 贺州市| 苏尼特左旗| 泰来县| 德昌县| 旌德县| 沙坪坝区| 石渠县| 池州市| 西乌珠穆沁旗| 白沙| 仪征市| 乐业县| 称多县| 乌恰县| 丹东市| 晋江市| 金溪县| 临澧县| 巴塘县| 栖霞市| 南昌市| 靖宇县| 长白| 高雄县| 宾川县| 灌阳县| 博客| 温宿县| 淮滨县| 喀什市|