I have a radio-button looking like this
created by this script:
import tkinter as tk
app = tk.Tk()
rbtn = tk.Radiobutton(text="A Radiobutton")
rbtn.pack()
app.mainloop()
I would like the text A Radiobutton
to be on the left side. How do I accomplish this?
CodePudding user response:
you could use .place(x=,y=)
import tkinter as tk
app = tk.Tk()
rbtn = tk.Radiobutton()#text="A Radiobutton")
rbtn.place( x=175 )
label=tk.Label(text="A Radiobutton")
label.place(x=100)
app.mainloop()
CodePudding user response:
You can put a label and a radiobutton without text in a frame, with the label on the left and the radiobutton on the right. This is exactly the sort of think that Frame widgets were designed for.
import tkinter as tk
app = tk.Tk()
frame = tk.Frame(app)
frame.pack()
lbl = tk.Label(frame, text="A Radiobutton")
rbtn = tk.Radiobutton(frame, text="")
rbtn.pack(side="right")
lbl.pack(side="left", fill="x")
app.mainloop()
Another solution is to switch to the ttk Radiobutton, because it allows you to change the layout of the widget.
I'm not a ttk expert, but this seems to work for me on my machintosh. It's likely not exactly what you want, but you can read more about styles and themes on