1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #!/usr/bin/python3
# -*-coding:utf-8 -*
class Test_00:
def __init__(self):
# Création de la fenêtre
self.fenetre = tk.Tk()
tk.Button(self.fenetre,text="TEST", command=self.test).grid(row = 0, column = 0)
# Labelframe
self.frame_resolution = tk.LabelFrame(self.fenetre, text="Choix")
self.frame_resolution.grid(row = 0, column = 1, rowspan = 4, padx = 5, pady = 5)
self.choix_radio_bouton = tk.StringVar()
tk.Radiobutton(self.frame_resolution, text="Choix 1", variable=self.choix_radio_bouton, value=(1, 2)).grid(row = 1, column = 0)
tk.Radiobutton(self.frame_resolution, text="Choix 2", variable=self.choix_radio_bouton, value=(3, 4)).grid(row = 2, column = 0)
tk.Radiobutton(self.frame_resolution, text="Choix 3", variable=self.choix_radio_bouton, value=(5, 6)).grid(row = 3, column = 0)
tk.Radiobutton(self.frame_resolution, text="Choix 4", variable=self.choix_radio_bouton, value=(7, 8)).grid(row = 4, column = 0)
self.choix_radio_bouton.set((7, 8))
self.fenetre.mainloop()
self.fenetre.destroy()
def test(self):
print(self.choix_radio_bouton.get())
#----------------------------------------------------------------------------------------------------------------------
# PROPGRAMME PRINCIPAL
#----------------------------------------------------------------------------------------------------------------------
import tkinter as tk
Test_00() |
Partager