Используйте значение radiobutton через классы - PullRequest
0 голосов
/ 09 июня 2019

Я делаю окно tkinter и создаю радиокнопки в одном из моих классов.Я хочу использовать значение моей радиопереключателя в другом классе, но у меня не определен «выбор».

class PageOne(tk.Frame):

    def __init__(self, parent, controller):        

        tk.Frame.__init__(self,parent)

        var = tk.IntVar()

        tk.Radiobutton(self, text="Herfindahl Index", variable=var, 
        value=1).place(relx=0.3, rely=0.3, anchor="w")

        tk.Radiobutton(self, text="Crop Diversification Index", variable=var, 
        value=2).place(relx=0.3, rely=0.4, anchor="w")

        choice = var.get()

class PageTwo(tk.Frame):

    def __init__(self, parent, controller):        

        tk.Frame.__init__(self,parent)

        if choice==1:
            button6 = ttk.Button(self, text=str(choice), 
            command=herfindahl_index)
            button6.place(relx=0.5, rely=0.5, anchor="center")
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...