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
|
import wx
import os
import glob
import methode1
class maissa(wx.Frame):
path1="path"
MyList = []
def __init__(self,parent,id):
#******************************************************************************************
wx.Frame.__init__(self,parent,id,"la fenetre dessai",size=(400,300))
panel=wx.Panel(self)
status=self.CreateStatusBar()
menubar=wx.MenuBar()
first=wx.Menu()
first.Append(wx.ID_OPEN,"choose\tCTRL+o","this will choose a new directroy")
menubar.Append(first,"File")
self.SetMenuBar(menubar)
b2=wx.Button(panel,label="exec",pos=(20,30),size=(75,23))
self.Bind(wx.EVT_BUTTON, self.OnTrait,b2)
wx.EVT_MENU(self, wx.ID_OPEN, self.opendir)
self.Bind(wx.EVT_COMBOBOX, self.OnSelect)
#*******************************************************************************************
self.count = 0
self.g1 = wx.Gauge(self, -1, 50, (110, 50), (250, 25))
#self.Bind(wx.EVT_TIMER, self.TimerHandler)
#self.timer = wx.Timer(self)
#self.timer.Start(100)
self.g1.SetRange(1000)
#********************************************************************
def OnTrait(self, event):
listea=os.listdir(maissa.path1)
liste2=glob.glob(maissa.path1)
path_dest='C:\Users\User\Desktop\maissagoge.txt'
self.g1.SetRange(len (listea))
for i in range(len (listea)):
self.g1.SetValue(i)
if self.g1.getValue()==len (listea):
dlg = wx.MessageDialog(self, 'Fin dexecution', 'Talmud', wx.OK|wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
path_s=liste2[0]+'\\' + listea[i]
print path_s
X=path_s.endswith("_SCH.C") or path_s.endswith("_SCH.c")or path_s.endswith("_sch.c")or path_s.endswith("_sch.C")
if X == True:
print X
f1=open(path_s, 'r')
f3=open(path_dest,'a')
lignes=f1.readlines()
liste=[]
liste4=[]
for cnt_1 in range(len(lignes)):
if 'void' in lignes[cnt_1] and '/*' not in lignes[cnt_1]:
cnt_2=cnt_1+1
while 'void' not in lignes[cnt_2]and '/*' not in lignes[cnt_2]:
if '()'in lignes[cnt_2]:
lignes[cnt_1]=lignes[cnt_1].replace("\n","").strip().replace('void',"").replace('()',"").replace(';',"")
liste.append(lignes[cnt_1])
lignes[cnt_2]=lignes[cnt_2].replace("\n","").strip().replace('void',"").replace('()',"").replace(';',"")
liste.append(lignes[cnt_2])
#f3.write(str(liste)+'\n')
liste4.append(liste)
print liste
liste=[]
cnt_2=cnt_2+1
if (cnt_2 > len(lignes)-1):
break
if 'void' in lignes[cnt_1+1] and '/*' not in lignes[cnt_1+1]:
lignes[cnt_1]=lignes[cnt_1].replace("\n","").strip().replace(';',"").replace('void',"").replace('()',"")
liste.append(lignes[cnt_1])
#f3.write(str(liste)+"\n")
print liste
liste4.append(liste)
liste=[]
def OnSelect(self, event):
self.item = event.GetSelection()
print "lelement choisi est", item
def opendir(self, event):
dlg = wx.DirDialog(self, "Choose a directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
if dlg.ShowModal() == wx.ID_OK:
maissa.path1=dlg.GetPath()
#***************************************************************************************************************
if __name__=='__main__':
app=wx.PySimpleApp()
frame=maissa(parent=None,id=-1)
frame.Show()
app.MainLoop() |
Partager