utiliser l' élement de la fonction1 dans la fonction 2 sans variable globale!
Voici mon code. je suis nouvelle sur ce Forum. j aimerai utiliser le lien fourni dans la première fonction dans la deuxieme je ne sais pas trop comment. J ai utilisé une variable globale mais Problème non résolu.
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
| import string, sys,os,win32ui,win32con
def On_Application_LayoutManagement_Schnittstellen0020FPGA2_Push0020Button_1960_ButtonClicked(sender, button):
"""Parameters: sender, button
"""
print 'select file!'
global doc
dialog = win32ui.CreateFileDialog(1,'','', 0,'Csv |*.csv')
dialog.SetOFNTitle('Select CSV File')
if dialog.DoModal() == win32con.IDOK:
print dialog.GetPathName().replace('\\','/')
doc=dialog.GetPathName().replace('\\','/')
msge= Application.LayoutManagement.ActiveLayout.GetInstrument ('MsgBox')
msge.Value= dialog.GetPathName().replace('\\','/')
def On_Application_LayoutManagement_Schnittstellen0020FPGA2_Push0020Button_1961_ButtonClicked(sender, button):
"""
Parameters: sender, button
"""
datei=doc
name = []
value = []
#liste = []
liste=['AO_1','AO_2','AO_3','AO_4','AO_5','AO_6','Interupt_Faktor_10ns']
index1 = liste.index('AO_1')
index2 = liste.index('AO_2')
obj = open(datei,'r')
for zeile in obj:
zeile = zeile.rstrip("\n")
i = 0
while i < len(liste):
if liste[i] in zeile:
teile = zeile.split(';')
name.append(str(teile[0]))
value.append(float(teile[1]))
i = i+1
obj.close() |
je ne comprend pas cette erreur.
obj = open(datei,'r') -->>>>TypeError: coercing to Unicode: need string or buffer, type found
Merci pour toute Aide et tout Conseil.
Davidmir