私のPythonプログラムで少し問題がある、私はwxpythonで作業していると私は関数に関連付けられているボタンを介して読み取りモードでパイプを開こうとしていますイベントを介して "checkpipe"。pythonエラー:メソッドはちょうど1引数(2与えられます)
class fenetre(wx.Frame): #on va creer une nouvelle classe pour l'interface
def __init__(self, parent, id): #constructeur
filecontent = ""
wx.Frame.__init__(self, parent, id, 'Solution 1 ---> Destinataire', size = (640,480))
panel = wx.Panel(self)
verifybutton = wx.Button(panel,label = "Verifier", pos = (320,10), size = (80,30))
self.currentDirectory = os.getcwd() #trouver le chemin du dossier dans lequel on se trouve
self.Centre() #faire apparaitre la fenetre au centre
textprocessid = wx.StaticText(panel, -1, monid, pos = (400, 213))
self.Bind(wx.EVT_BUTTON, self.checkpipe, verifybutton)
def alertMessagePipeEmpty(self):
dialog = wx.MessageDialog(self, "Rien recu. Veuillez essayer plus tard","Erreur", wx.OK|wx.ICON_ERROR)
result = dialog.ShowModal()
dialog.Destroy()
def closewindow(self, event):
self.Destroy()
def checkpipe(self,names = None):
if not os.path.exists(fifoname):
os.mkfifo(fifoname)
pipein = open(fifoname, 'r')
contenu = pipein.read()
if contenu == "":
self.alertMessagePipeEmpty()
else:
dialog = wx.MessageDialog(self, "Vous avez un fichier a recevoir. Voulez-vous le sauvegarder","Fichier recu", wx.YES_DEFAULT|wx.ICON_ERROR)
result = dialog.ShowModal()
dialog.Destroy()
if result == wx.ID_YES:
dlg = wx.FileDialog(
self, message="Sauvegardez le fichier",
defaultDir=self.currentDirectory,
defaultFile="",
wildcard=wildcard,
style=wx.SAVE | wx.CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
paths = dlg.GetPaths()
pathcomplet = ""
for path in paths:
pathcomplet = pathcomplet + path
dlg.Destroy()
fd2 = open(pathcomplet,'w')
fd2.write(contenu)
os.unlink(fifoname)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = fenetre(parent = None, id = -1)
frame.Show()
app.MainLoop()
はTypeError::checkpipe()私はそれがあると思い、すべてを試み、正確に1引数(2は、与えられた)
がかかるという問題は、私はボタンをクリックすると、Pythonのエラーインタプリタが私に語った、これはということです私が行方不明の何か愚かについては、私はそれを把握するように見えることはできません。どんな助けもありがとう。
?たぶん発信者コード。 – CamilB
少しのコードを投稿できますか? –
野生の推測:関数が静的メソッドではなくクラスメソッドとして呼び出されています。 – MattH