tkinker.ttk justify和anchor并不为ttk.Radiobutton工作。
这是我的密码:
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()我得到的是:

这就是我要做的,除了:

PS:我可以在tk小部件中使用anchor=center。
发布于 2022-05-25 01:59:04
在初级阶段。你不能跳到直接的水平。你必须一步一步地倾斜。这里是一个新手教程:
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()https://stackoverflow.com/questions/72363097
复制相似问题