簡體   English   中英

Tkinter create_window,居中對齊

[英]Tkinter create_window, justify to center

我有這段代碼,我希望這些按鈕位於行的中心。 不幸的是 justify 不起作用, text.window_config(INSERT, align="center")給了我這樣的錯誤: no embedded window at index "insert"我知道 INSERT 有問題,但我不知道我還應該放什么那里。

#text.window_config(INSERT, align="center")
for page in range(number_of_pages):
    page = page+1
    button = Button(text, text=page)
    button.configure(command=lambda button=button: goTo(page))
    text.window_create(INSERT, window=button)

在插入 cursor 處添加 window 會導致插入 cursor 向右移動一位。 要引用新創建的 window,您可以使用“insert-1c”,意思是“插入 cursor 減去一個字符”,因為 window 在邏輯上占用一個“字符”空間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM