| 12
 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
 
 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
#
try:
    from Tkinter import *
except:
    from tkinter import *
 
def fun1(nom, index, mode):
    print('pass by fun1')
    print('nom: ' + nom)
    print('index: ' + index)
    print('mode: ' + mode)
    print('Modification de V2, soit ' + V2._name)
    valeur = V1.get()[0]
    V2.trace_vdelete('w', root.wcb_v2)
    V2.set('b')
    root.wcb_v2 = V2.trace_variable('w', fun2)
 
def fun2(nom, index, mode):
    print('pass by fun2')
    print('nom: ' + nom)
    print('index: ' + index)
    print('mode: ' + mode)
    print('Modification de V1, soit ' + V1._name)
    valeur = V2.get()
    V1.trace_vdelete('w', root.wcb_v1)
    V1.set('b')
    root.wcb_v1 = V1.trace_variable('w', fun1)
 
root = Tk()
 
V1 = StringVar()
V2 = StringVar()
root.wcb_v1 = V1.trace_variable('w', fun1)
root.wcb_v2 = V2.trace_variable('w', fun2)
 
V1.set('aaaaa')
print('Valeur de V2 ' + V2.get())
print('------------------------------------')
V2.set('c')
print('Valeur de V1 ' + V2.get())
print('Valeur de V2 ' + V2.get()) | 
Partager