Bonjour a tous,
Je pourrais en faire une tonne pour l'intro de mon topic afin de m'excuser de ma faiblesse en POO, mais faisons bref, je pensais y avoir compris quelques choses mais il faut que je me rende à l'évidence, c'est toujours une nébuleuse.
Alors, "la mort dans l'ame", c'est comme cela qu'on dit je crois, je me suis résigné à venir demander de l'aide.
voici donc un le code.
Test1_ui.py
Test1.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99 """ UI generated by GUI Builder Build 146 on 2009-04-22 17:44:14 from: D:/Python26/MesProjeets/Test1.ui THIS IS AN AUTOGENERATED FILE AND SHOULD NOT BE EDITED. The associated callback file should be modified instead. """ import Tkinter import os # needed for relative image paths # Using new-style classes: create empty base class object # for compatibility with older python interps #if sys.version_info < (2, 2): # class object: # pass def Sortir(): print "fonction" class Test1(object): _images = [] # Holds image refs to prevent GC def __init__(self, root): # Widget Initialization self._entry_1 = Tkinter.Entry(root, width = 0, ) self.button1 = Tkinter.Button(root, text = "Transfert", ) self.labelVariable = Tkinter.StringVar() self.label = Tkinter.Label(root, text = "Transfert ici", ) # widget commands self._entry_1.configure( invalidcommand = self._entry_1_invalidcommand ) self._entry_1.configure( validatecommand = self._entry_1_validatecommand ) self._entry_1.configure( xscrollcommand = self._entry_1_xscrollcommand ) self.button1.configure( command = Sortir ) # Geometry Management self._entry_1.grid( in_ = root, column = 2, row = 1, columnspan = 3, ipadx = 0, ipady = 0, padx = 0, pady = 0, rowspan = 1, sticky = "ew" ) self.button1.grid( in_ = root, column = 3, row = 2, columnspan = 1, ipadx = 0, ipady = 0, padx = 0, pady = 0, rowspan = 1, sticky = "" ) self.label.grid( in_ = root, column = 2, row = 3, columnspan = 3, ipadx = 0, ipady = 0, padx = 0, pady = 0, rowspan = 1, sticky = "" ) # Resize Behavior root.grid_rowconfigure(1, weight = 0, minsize = 40, pad = 0) root.grid_rowconfigure(2, weight = 0, minsize = 40, pad = 0) root.grid_rowconfigure(3, weight = 0, minsize = 40, pad = 0) root.grid_columnconfigure(1, weight = 0, minsize = 3, pad = 0) root.grid_columnconfigure(2, weight = 0, minsize = 40, pad = 0) root.grid_columnconfigure(3, weight = 0, minsize = 48, pad = 0) root.grid_columnconfigure(4, weight = 0, minsize = 40, pad = 0) root.grid_columnconfigure(5, weight = 0, minsize = 5, pad = 0)
Quelqu'un pourrais-t-il m'expliquer comment faire pour que, lorsque je clique sur le boutton1, ce dernier déclenche l'affichage "Transfert ok" dans le Label?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 """ UI generated by GUI Builder Build 146 on 2009-04-22 17:44:15 from: D:/Python26/MesProjeets/Test1.ui This file is auto-generated. Only the code within '# BEGIN USER CODE (global|class)' '# END USER CODE (global|class)' and code inside the callback subroutines will be round-tripped. The 'main' function is reserved. """ from Tkinter import * from Test1_ui import Test1 # BEGIN USER CODE global # END USER CODE global class CustomTest1(Test1): pass # BEGIN CALLBACK CODE # ONLY EDIT CODE INSIDE THE def FUNCTIONS. # _entry_1_invalidcommand -- # # Callback to handle _entry_1 widget option -invalidcommand def _entry_1_invalidcommand(self, *args): pass # _entry_1_validatecommand -- # # Callback to handle _entry_1 widget option -validatecommand def _entry_1_validatecommand(self, *args): pass # _entry_1_xscrollcommand -- # # Callback to handle _entry_1 widget option -xscrollcommand def _entry_1_xscrollcommand(self, *args): pass # button1_command -- # # Callback to handle button1 widget option -command def button1_command(self, *args): pass # END CALLBACK CODE # BEGIN USER CODE class # END USER CODE class def main(): # Standalone Code Initialization # DO NOT EDIT try: userinit() except NameError: pass root = Tk() demo = CustomTest1(root) root.title('Test1') try: run() except NameError: pass root.protocol('WM_DELETE_WINDOW', root.quit) root.mainloop() if __name__ == '__main__': main()
Dans le contexte de programmation de class bien sure.
Avec tous mes remerciements par avance
Partager