[英]Inside a ttk Radiobutton, how to center the text? (anchor not working)
tkinker.ttk justify
and anchor
is not working for ttk.Radiobutton
. tkinker.ttk
justify
和anchor
不适用于ttk.Radiobutton
。
This is my code:这是我的代码:
from tkinter import *
from tkinter import ttk
window = Tk()
style = ttk.Style()
sty = ttk.Style(window)
op=IntVar(master=window)
sty.configure("TRadiobutton", background="green",foreground="red", anchor="center",justify='center')
entry_0 = ttk.Radiobutton(window,text="text",value=1,variable=op,style="white.TRadiobutton")
entry_0.place(
x=0,
y=0,
anchor="nw",
width=150
)
mainloop()
This is what I get:这就是我得到的:
This is what I except:这是我除了:
PS: I can use anchor=center
in a tk widget. PS:我可以在 tk 小部件中使用
anchor=center
。
As for you at entry level.至于你的入门级。 You cannot jump to the immediate level.
你不能跳到直接的水平。 You have to lean step by step.
你必须一步一步地倾斜。 Here is a newbie tutorial:
这是一个新手教程:
from tkinter import *
from tkinter import ttk
window = Tk()
style = ttk.Style()
sty = ttk.Style(window)
op=IntVar(master=window)
sty.configure("TRadiobutton", background="green",
foreground="red", anchor="center",
justify='center')
entry_0 = ttk.Radiobutton(window,text="text",value=1,variable=op,
style="white.TRadiobutton").pack(side = TOP)
mainloop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.