Résolu merci!
Version imprimable
Résolu merci!
Bonjour,
Effectivement, dans ta fonction config(), les variables créées sont des variables locales qui sont détruites à la fin de cette fonction... ce qui n'est probablement pas ce que tu voulais.
Une des possibilités: abandonne le fichier config() et met son contenu en exécution au niveau global.
Tyrtamos
malhereusement se n'est pas possible (enfin je croix ) sa doit rester dedans pour que tout fonctionne
programme complet :
Code:
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 #-*- coding:Utf-8 -*- from Tkinter import * import os fichier_config= open('config.ini', 'r') contenu = fichier_config.readlines() fichier_config.close () try: hostloc = str(contenu[1][0:len(contenu[1])-1]) # emplacement host gameloc = str(contenu[2][0:len(contenu[2])-1]) #emplacement game ipadress = str(contenu[3][0:len(contenu[3])-1]) #adresse ip core = str(contenu[4][0:len(contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" def patcher(choix) : if choix ==1 : host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(gameloc) def config() : fenetre2 = Tk() fenetre2.title('Modifiez... ' + core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) entr1 = Entry(fenetre2).grid(row =0, column =1) entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd() : global entr2 ipadress = str(entr2.get()) host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') # affichage Tk fenetre = Tk() # image can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ='header.gif') item = can1.create_image(250, 125, image =photo) #image fenetre.title('l2-Luncher by Noquioz ' + core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy()
Pour éviter ces problèmes, il faut encapsuler ton programme dans une classe (j'ai longtemps galéré avant de le faire et plus après !!)
exemple :
class Application:
def __init__(self):#ici les variables initiales de ton script
self.entr2=3#puis tes fonctions (attention à ajouter self
def config(self) :fenetre2 = Tk()ffenetre2.title('Modifiez... ' + core)
def configadd(self) :def configadd(self) :#puis tu instance la classe :self.ipadress = str(self.entr2.get())
import os
import shutil
f = Application() # instanciation de l'objet application
maintenant si tu déclare une variable avec self. devant elle est valable dans toutes les fonction de la classe. Sans le self, elle n'est valable que dans la fonction ou elle est utilisée. Avec ça, plus de problème de poertée de variables !
Tout à fait, mais pour ce cas précis, si ne veut pas encapsuler ton prog dans une classe (ce qui serait vraiment dommage), au début ta procédure 'config', met ici aussi global entr2. Par contre comme je ne me sert jamais des globales, je ne sais plus si il faut que tu retires du coup global entr2 de ton autre procédure ou pas...essayes, tu verras bien :roll:
Voila :
il ya rien qui apparait se qui me semble normal =P car faut que j'appelle affichage mais comment ?Code:
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 #-*- coding:Utf-8 -*- from Tkinter import * import os import shutil class programme : def __init__(self): self.hostloc = 0 self.gameloc = 0 self.ipadress = 0 self.core = 0 self.entr1 = 0 self.entr2 = 0 self.fichier_config = 0 self.contenu = 0 self.fichier_config= open("config.ini", "r") self.contenu = fichier_config.readlines() self.fichier_config.close () try: self.hostloc = str(self.contenu[1][0:len(self.contenu[1])-1]) # emplacement host self.gameloc = str(self.contenu[2][0:len(self.contenu[2])-1]) #emplacement game self.ipadress = str(self.contenu[3][0:len(self.contenu[3])-1]) #adresse ip self.core = str(self.contenu[4][0:len(self.contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" raw_input() def patcher(self, choix) : if choix ==1 : host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(self.gameloc) def config(self) : fenetre2 = Tk() fenetre2.title('Modifiez... ' + self.core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) self.entr1 = Entry(fenetre2).grid(row =0, column =1) self.entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =self.configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd(self) : self.ipadress = str(self.entr2.get()) host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') # affichage Tk fenetre = Tk() # image can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ="header.gif") item = can1.create_image(250, 125, image =photo) #image def affichage(self) : fenetre.title('l2-Luncher by Noquioz ' + self.core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: self.patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: self.patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =self.config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy()
bon maintenant :Code:
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 #-*- coding:Utf-8 -*- from Tkinter import * import os import shutil class programme : def __init__(self): self.hostloc = 0 self.gameloc = 0 self.ipadress = 0 self.core = 0 self.entr1 = 0 self.entr2 = 0 self.fichier_config = 0 self.contenu = 0 self.fichier_config= open("config.ini", "r") self.contenu = fichier_config.readlines() self.fichier_config.close () try: self.hostloc = str(self.contenu[1][0:len(self.contenu[1])-1]) # emplacement host self.gameloc = str(self.contenu[2][0:len(self.contenu[2])-1]) #emplacement game self.ipadress = str(self.contenu[3][0:len(self.contenu[3])-1]) #adresse ip self.core = str(self.contenu[4][0:len(self.contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" raw_input() def patcher(self, choix) : if choix ==1 : host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(self.gameloc) def config(self) : fenetre2 = Tk() fenetre2.title('Modifiez... ' + self.core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) self.entr1 = Entry(fenetre2).grid(row =0, column =1) self.entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =self.configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd(self) : self.ipadress = str(self.entr2.get()) host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') def affichage(self) : fenetre = Tk() can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ="header.gif") item = can1.create_image(250, 125, image =photo) fenetre.title('l2-Luncher by Noquioz ' + self.core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: self.patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: self.patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =self.config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy() h= affichage(fenetre) h.pack()
Code:
1
2
3
4
5
6
7
8 Traceback (most recent call last): File "C:\Users\Julien Moret\Desktop\luncher\luncher.py", line 144, in <module> h= affichage(fenetre) File "C:\Users\Julien Moret\Desktop\luncher\luncher.py", line 127, in affichage fenetre.title('l2-Luncher by Noquioz ' + self.core) File "C:\Python25\lib\lib-tk\Tkinter.py", line 1721, in __getattr__ return getattr(self.tk, attr) AttributeError: core
la j'ai enlever self dans la dernière définition.Code:
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 #-*- coding:Utf-8 -*- from Tkinter import * import os import shutil class programme : def __init__(self): self.hostloc = 0 self.gameloc = 0 self.ipadress = 0 self.core = 0 self.entr1 = 0 self.entr2 = 0 self.fichier_config = 0 self.contenu = 0 self.fichier_config= open("config.ini", "r") self.contenu = fichier_config.readlines() self.fichier_config.close () try: self.hostloc = str(self.contenu[1][0:len(self.contenu[1])-1]) # emplacement host self.gameloc = str(self.contenu[2][0:len(self.contenu[2])-1]) #emplacement game self.ipadress = str(self.contenu[3][0:len(self.contenu[3])-1]) #adresse ip self.core = str(self.contenu[4][0:len(self.contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" raw_input() def patcher(self, choix) : if choix ==1 : host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(self.gameloc) def config(self) : fenetre2 = Tk() fenetre2.title('Modifiez... ' + self.core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) self.entr1 = Entry(fenetre2).grid(row =0, column =1) self.entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =self.configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd(self) : self.ipadress = str(self.entr2.get()) host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') def affichage() : fenetre = Tk() can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ="header.gif") item = can1.create_image(250, 125, image =photo) fenetre.title('l2-Luncher by Noquioz ' + self.core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: self.patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: self.patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =self.config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy() h=affichage() h.pack()
j'en conclu que c'est *** de self marche pas =(Code:
1
2 fenetre.title('l2-Luncher by Noquioz ' + self.core) NameError: global name 'self' is not defined
mais comment ?
Voici un lien qui te sera très utile ;)
Merci de ta réponse
(j'ai déjà tout lu et je viens de relire)
mais sa m'aide pas =(
ZzZzZ
sans classe
Code:
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 #-*- coding:Utf-8 -*- from Tkinter import * import os fichier_config= open('config.ini', 'r') contenu = fichier_config.readlines() fichier_config.close () try: hostloc = str(contenu[1][0:len(contenu[1])-1]) # emplacement host gameloc = str(contenu[2][0:len(contenu[2])-1]) #emplacement game ipadress = str(contenu[3][0:len(contenu[3])-1]) #adresse ip core = str(contenu[4][0:len(contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" def patcher(choix) : if choix ==1 : host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(gameloc) def config() : global entr2 fenetre2 = Tk() fenetre2.title('Modifiez... ' + core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) entr1 = Entry(fenetre2).grid(row =0, column =1) entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd() : ipadress = str(entr2.get()) host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') # affichage Tk fenetre = Tk() # image can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ='header.gif') item = can1.create_image(250, 125, image =photo) #image fenetre.title('l2-Luncher by Noquioz ' + core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy()
TT *déprime*Code:
1
2 ipadress = str(entr2.get()) AttributeError: 'NoneType' object has no attribute 'get'
je sais que vous savez =(
Bonjour,
"global entr2" permet de dire à la fonction config qu'il faut chercher la variable "entr2" dans les variables globales, mais elle n'existe pas comme variable globale.
=> initialise entr2 comme variable globale comme je te l'ai suggéré.
Tyrtamos
Non, tu fais quelque chose comme:
Ainsi, lors de la config, c'est bien le entr2 global qui sera pris, et sa valeur sera reconnue sans pb partout dans les autres fonctions, à condition de le dire avec global entr2.Code:
1
2
3
4
5
6
7
8
9 ... entr2 = None ... def config() : global entr2 ... entr2 = Entry(fenetre2).grid(row= 1, column =1) ...
Ok?
Tyrtamos
j'ai fait se que tu m'as dis mais c'est pareil.Code:
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 #-*- coding:Utf-8 -*- from Tkinter import * import os fichier_config= open('config.ini', 'r') contenu = fichier_config.readlines() fichier_config.close () entr2 = None try: hostloc = str(contenu[1][0:len(contenu[1])-1]) # emplacement host gameloc = str(contenu[2][0:len(contenu[2])-1]) #emplacement game ipadress = str(contenu[3][0:len(contenu[3])-1]) #adresse ip core = str(contenu[4][0:len(contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" def patcher(choix) : if choix ==1 : host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(gameloc) def config() : global entr2 fenetre2 = Tk() fenetre2.title('Modifiez... ' + core) txt1 = Label(fenetre2, text = 'Jeu :').grid(row=0, sticky =E) txt2 = Label(fenetre2, text = 'Ip :').grid(row=1, sticky =E) entr1 = Entry(fenetre2).grid(row =0, column =1) entr2 = Entry(fenetre2).grid(row= 1, column =1) bouton4 =Button(fenetre2, text= ' Ok ', command =configadd).grid(row=2, column=1, sticky =E) fenetre2.mainloop() fenetre2.destroy() def configadd() : ipadress = str(entr2.get()) host= open(hostloc, "a") host.close() host= open(hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(ipadress +' l2authd.lineage2.com\n') host.write(ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') # affichage Tk fenetre = Tk() # image can1 = Canvas(fenetre, width =500, height =250, bg ='gray') photo = PhotoImage(file ='header.gif') item = can1.create_image(250, 125, image =photo) #image fenetre.title('l2-Luncher by Noquioz ' + core) can1.pack() bouton1 = Button(fenetre, text='Patch', command = (lambda: patcher(1))).pack(side =BOTTOM) bouton2 = Button(fenetre, text='Play', command = (lambda: patcher(2))).pack(side =BOTTOM) bouton3 = Button(fenetre, text='Option', command =config).pack(side =BOTTOM) chaine = Label(fenetre) chaine.pack() fenetre.mainloop() fenetre.destroy()
(le none est au debut)
Si je simplifie à l'extrême cette partie de code concernant entr2, ça donne:
Ce qui affiche, bien entendu "5": la fonction config() a bien fait son boulot.Code:
1
2
3
4
5
6
7
8
9 entr2=None def config(): global entr2 entr2=5 config() print entr2
Tyrtamos
Je crois avoir piger, en fait c'est tout con ton problème : dans ta procédure configadd tu fais un appel a entry2, seulement l'ordi lui cherche entry2 en tant que variable locale, donc à l'intérieur de la procédure... donc, au début de la dite procédure (configadd), rajoute global entry2, tout simplement :lol:
Sinon, la totalité de l'application encapsulée dans une classe donne à peu près ça :
Code:
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 from Tkinter import * import os class Appli: def __init__(self): self.fichier_config= open('config.ini', 'r') self.contenu = self.fichier_config.readlines() self.fichier_config.close () self.entr2 = None try: self.hostloc = str(contenu[1][0:len(contenu[1])-1]) # emplacement host self.gameloc = str(contenu[2][0:len(contenu[2])-1]) #emplacement game self.ipadress = str(contenu[3][0:len(contenu[3])-1]) #adresse ip self.core = str(contenu[4][0:len(contenu[4])-1])#no version except: print "ERREUR! veuillez verifiez le fichier config.ini" self.defwidget() def defwidget(self): # affichage Tk self.fenetre = Tk() # image self.can1 = Canvas(self.fenetre, width =500, height =250, bg ='gray') self.item = can1.create_image(250, 125, image =PhotoImage(file ='header.gif')) #image self.fenetre.title('l2-Luncher by Noquioz ' + self.core) self.can1.pack() self.bouton1 = Button(self.fenetre, text='Patch', command = (lambda: self.patcher(1))) self.bouton1.pack(side =BOTTOM) self.bouton2 = Button(self.fenetre, text='Play', command = (lambda: self.patcher(2))) self.bouton2.pack(side =BOTTOM) self.bouton3 = Button(self.fenetre, text='Option', command =self.config) self.bouton3.pack(side =BOTTOM) self.chaine = Label(self.fenetre) self.chaine.pack() def patcher(self,choix) : if choix ==1 : host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') elif choix ==2 : os.startfile(self.gameloc) def config(self) : self.fenetre2 = Toplevel() self.fenetre2.title('Modifiez... ' + self.core) self.txt1 = Label(self.fenetre2, text = 'Jeu :') self.txt1.grid(row=0, sticky =E) self.txt2 = Label(self.fenetre2, text = 'Ip :') self.txt2.grid(row=1, sticky =E) self.entr1 = Entry(self.fenetre2) self.entr1.grid(row =0, column =1) self.entr2 = Entry(self.fenetre2) self.entr2.grid(row= 1, column =1) self.bouton4 =Button(self.fenetre2, text= ' Ok ', command =self.configadd) self.bouton4.grid(row=2, column=1, sticky =E) def configadd(self) : self.ipadress = str(self.entr2.get()) host= open(self.hostloc, "a") host.close() host= open(self.hostloc, "w") host.write('127.0.0.1 localhost\n') host.write(self.ipadress +' l2authd.lineage2.com\n') host.write(self.ipadress +' L2testauthd.lineage2.com\n') host.write('216.107.250.194 nprotect.lineage2.com\n') #lancement a=Appli() a.fenetre.mainloop()
sa fait déjà un moment, mais je cherche toujours...
Voila j'ai mis en pièce jointe les fichiers
je serai très reconnaissant a la personne qui arrive a faire fonctionner le menu option.
Merci d'avance
J'ai ma solution
il faut tout simplement séparer les .grid
entrer = entry()
entrer.grid()
voila c'était vraiment con. ^^