- Merde on peut pas éditer -
Enfin maintenant je suis obligé de faire un bouton 'Parcourir" pour
aller chercher mon fichier, et g repris celui du module d'aide de
wxpython sauf que j'ai un probleme avec une variable < log > que
je ne vois pas comment définir, deplus elle n'est pas déinit dans
le code source du module d'aide
voici mon code :
le bouton
a = wx.Button(self.panelA, -1, "Parcourir", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnParcourir, a)
la méthode
def OnParcourir(self, evt):
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Create the dialog. In this case the current directory is forced as the starting
# directory for the dialog, and no default file name is forced. This can easilly
# be changed in your program. This is an 'open' dialog, and allows multitple
# file selections as well.
#
# Finally, if the directory is changed in the process of getting files, this
# dialog is set up to change the current working directory to the path chosen.
dlg = wx.FileDialog(
self, message="Choose a file", defaultDir=os.getcwd(),
defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.MULTIPLE |
wx.CHANGE_DIR
)
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.
if dlg.ShowModal() == wx.ID_OK:
# This returns a Python list of files that were selected.
paths = dlg.GetPaths()
self.log.WriteText('You selected %d files:' % len(paths))
for path in paths:
self.log.WriteText('
%s\n' % path)
# Compare this with the debug above; did we change working dirs?
self.log.WriteText("CWD: %s\n" % os.getcwd())
# Destroy the dialog. Don't do this until you are done with it!
# BAD things can happen otherwise!
dlg.Destroy()
Le problème est du a la variable log, j'ai beau la définir dans le constructeur comme ceci :
def __init__(self, parent, log):
self.log = log
et elle est bien en argument
panel = TestLayoutConstraints(frame,log)
Je ne vois pas quoi faire
J'ai tenté de la définir en string ainsi qu'en liste mais j'ai eu le
droit a un message d'erreur comme koi cette variable n'avait pas accezs
a la fonction WriteText. Donc je m'en remet à vous
|