1

tkinker.ttk justifyandanchor is not working for 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:

Radio button on the left of a green rectangle

This is what I except:

Radio button in the middle of a green rectangle

PS: I can use anchor=center in a tk widget.

smitop
  • 4,770
  • 2
  • 20
  • 53
Lzc Tuhao
  • 11
  • 4

1 Answers1

0

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()
toyota Supra
  • 3,181
  • 4
  • 15
  • 19