繁体   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