Исправление дизайна RadioButtons в Tkinter - PullRequest
0 голосов
/ 10 января 2019

Я хочу связать свои радиокнопки с заголовком, как объединить мой заголовок с радиокнопкой. Вот код, который я реализовал:

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)

Это фактический результат:

Actual

Это ожидаемый результат:

Expected

1 Ответ

0 голосов
/ 10 января 2019

Не знаю, знаете ли вы это, но этот виджет называется LabelFrame. Смотрите пример ниже.

P.S. Я изменил ваш менеджер геометрии на 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()

Result

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...