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 35 36 37 38 39 40 41 42 43 44
| import tkinter
import re
class Commandes():
def __init__(self,fenetre):
self.p=fenetre
def boite(self,event=None):
self.b=tkinter.Tk()
self.b.title("Titre")
self.saisie=tkinter.StringVar()
self.entree=tkinter.Entry(self.b,text="Entrée ",textvariable=self.saisie)
self.entree.focus_set()
self.choix1=tkinter.IntVar()
self.cb=tkinter.Checkbutton(self.b, text ='Coche',variable=self.choix1,command=self.activation)
liste_radio = [('gauche',1),('droite',2)]
self.v = tkinter.IntVar()
self.entree.pack()
self.cb.pack(side=tkinter.LEFT)
for texte,val in liste_radio:
self.r=tkinter.Radiobutton(self.b,text=texte,variable=self.v,value=val,command=self.activation)
self.r.pack(side=tkinter.LEFT)
def activation(self,event=None):
print('Activation ou désactivation de la case à cocher\n Transfert des paramètres')
print('zone saisie : ',self.saisie)
print('case cochée : ',self.choix1.get())
print('droite ou gauche :',self.v.get())
class Application():
def __init__(self):
self.root = tkinter.Tk()
self.root.title("Essai")
self.texte1 = tkinter.Text(self.root)
self.texte1.focus_set()
self.texte1.pack()
self.com=Commandes(self.root)
self.texte1.bind('<Control-f>', self.com.boite)
self.root.mainloop()
if __name__ == '__main__':
Application() |
Partager