import sys
from tkinter import *
import tkinter as tk
import tkinter.ttk as ttk
def vp_start_gui():
global val, w, root
root = tk.Tk()
top = Toplevel1(root)
root.mainloop()
w = None
def create_Toplevel1(root, *args, **kwargs):
global w, w_win, rt
rt = root
w = tk.Toplevel(root)
top = Toplevel1(w)
return (w, top)
def destroy_Toplevel1():
global w
w.destroy()
w = None
def clicked():
lbl.configure(text=selected.get())
print(lbl.configure(text=selected.get()))
class Toplevel1:
def __init__(self, top=None):
top.geometry("515x311+650+150")
top.title("New Toplevel")
top.configure(background="#d9d9d9")
self.selected = IntVar()
self.Radiobutton1 = tk.Radiobutton(top, value=0, variable=self.selected, command=clicked)
self.Radiobutton1.place(relx=0.252, rely=0.257, relheight=0.08, relwidth=0.113)
self.Radiobutton1.configure(text='''Radio 1''')
self.Radiobutton2 = tk.Radiobutton(top, value=1, variable=self.selected, command=clicked)
self.Radiobutton2.place(relx=0.583, rely=0.257, relheight=0.08 , relwidth=0.113)
self.Radiobutton2.configure(text='''Radio 2''')
self.Button1 = tk.Button(top)
self.Button1.place(relx=0.33, rely=0.386, height=64, width=137)
self.Button1.configure(text='''Button''')
self.Button1.configure(width=137)
self.lbl = Label(top)
self.lbl.grid(column=0, row=1)
if __name__ == '__main__':
vp_start_gui()
self.selected = IntVar()
self.Radiobutton1 = tk.Radiobutton(top, value=0, variable=self.selected)
self.Radiobutton2 = tk.Radiobutton(top, value=1, variable=self.selected)
self.lbl = Label(top. textvariable=self.selected)
class Toplevel1:
def __init__(self, top=None):
...
self.Radiobutton1 = tk.Radiobutton(top, value=0, variable=self.selected, command=self.clicked)
...
def clicked(self):
self.lbl.configure(text=self.selected.get())
self.Radiobutton1 = tk.Radiobutton(top, value=0, variable=self.selected, command=lambda: self.lbl.configure(text=self.selected.get()))
from functools import partial
...
def clicked(window):
window.lbl.configure(text=window.selected.get())
class Toplevel1:
def __init__(self, top=None):
...
self.Radiobutton1 = tk.Radiobutton(top, value=0, variable=self.selected, command=partial(clicked, self))
...