Reputation: 285
I want to link my radiobuttons with the title, like merge my title with the radio button. This is the code which I implemented:
but1 = Radiobutton(text = "Current",value = 0)
but1.place(x =400,y = 150)
but2 = Radiobutton(text = "Previous",value = 1)
but2.place(x =320,y = 150)
but3 = Radiobutton(text = "Current",value = 2)
but3.place(x =400,y = 260)
but4 = Radiobutton(text = "Previous",value = 3)
but4.place(x =320,y = 260)
the_window.geometry("510x430")
label1 = Label(the_window,text = "Most-Discussed \n TV SHOW", font =
"Times 10 bold")
label1.place(x = 350,y = 110)
label2 = Label(the_window,text = "Most-Discussed \n TV SHOW", font =
"Times 10 bold")
label2.place(x = 350,y = 230)
This is the actual result:
This is the expected result:
Upvotes: 2
Views: 92
Reputation: 4407
I don't know if you know this, but that widget is called a LabelFrame
. See the below example.
P.S. I have changed your geometry manager to grid
import tkinter as tk
root = tk.Tk()
f1 = tk.LabelFrame(root, text="Most-Discussed \n TV SHOW", labelanchor="n", font="Verdana 12 bold", bd=4)
f1.grid(row=0, column=0, padx=10, pady=10)
f2 = tk.LabelFrame(root, text="Music Vinyl \n Album Chart", labelanchor="n", font="Verdana 12 bold", bd=4)
f2.grid(row=1, column=0, padx=10, pady=10)
but1 = tk.Radiobutton(f1, text="Current", value = 0)
but1.grid(row=0, column=0)
but2 = tk.Radiobutton(f1, text="Previous" ,value = 1)
but2.grid(row=0, column=1)
but3 = tk.Radiobutton(f2, text="Current", value = 2)
but3.grid(row=0, column=0)
but4 = tk.Radiobutton(f2, text="Previous" ,value = 3)
but4.grid(row=0, column=1)
root.mainloop()
Upvotes: 2