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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| #!/usr/bin/python
# -*- coding: latin-1 -*
# pyd_maker.py
import wx
import sys, os
import cStringIO
ID_QUIT = 1
ID_OPEN = 2
ID_OPEN2 = 3
ID_OPEN3 = 4
ID_OPEN4 = 5
ID_OPEN5 = 6
ID_RADIO1 = 7
ID_RADIO2 = 8
ID_RADIO3 = 9
ID_RADIO4 = 10
ID_MAKE = 11
class PageOne(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.t1 = wx.StaticText(self, -1, "Votre fichier Python de base: ", (20,30))
self.textbox = wx.TextCtrl(self, -1, "", (200,25), (300,20))
self.bouton1 = wx.Button(self, ID_OPEN, "Choose", (550,23))
self.t2 = wx.StaticText(self, -1, "Votre module est : ", (20,80))
self.radio1 = wx.RadioButton ( self, ID_RADIO3, 'un fichier fortran', (40,120), style = wx.RB_GROUP )
self.radio2 = wx.RadioButton ( self, ID_RADIO4, 'un fichier python précompilé (pyd)', (40,160))
self.textbox2 = wx.TextCtrl(self, -1, "", (250,140), (250,20))
self.bouton2 = wx.Button(self, ID_OPEN2, "Choose", (550,138))
self.boutonmake = wx.Button(self, ID_MAKE, 'Make', (470,500))
self.boutonrun = wx.Button(self, -1, 'Run', (390, 500))
self.t3 = wx.StaticText(self, -1, "Console :", (20,345))
self.output = wx.TextCtrl(self, -1, "", (50,375), (550,100), style = wx.TE_MULTILINE)
self.output.SetEditable(False)
self.Bind(wx.EVT_BUTTON, self.button1Click, id=ID_OPEN)
self.Bind(wx.EVT_BUTTON, self.button2Click, id=ID_OPEN2)
self.Bind(wx.EVT_BUTTON, self.buttonMakeClick, id=ID_MAKE)
self.Bind(wx.EVT_RADIOBUTTON, self.radio1Click, id=ID_RADIO3)
self.Bind(wx.EVT_RADIOBUTTON, self.radio2Click, id=ID_RADIO4)
def button1Click(self, event):
dlgpy = wx.DirDialog(self, "Chemin de votre fichier python", style = wx.DD_DIR_MUST_EXIST)
retour = dlgpy.ShowModal()
chemin = dlgpy.GetPath()
self.textbox.SetValue(chemin)
dlgpy.Destroy()
def button2Click(self, event):
if (self.radio1.GetValue() == True):
wildcard = "Fortran files (.for)|*.for|" \
"Fortran90 files (.f90)|*.f90|" \
"Fortran77 files (.f77)|*.f77|" \
"*.f|*.f|" \
"*.f40|*.f40|" \
"*.ftn|*.ftn"
dlgpy2 = wx.FileDialog(self, "Choisissez un fichier Fortran", style = wx.OPEN)
dlgpy2.SetWildcard(wildcard)
retour = dlgpy2.ShowModal()
chemin = dlgpy2.GetPath()
fichier = dlgpy2.GetFilename()
self.textbox2.SetValue(chemin)
dlgpy2.Destroy()
else :
dlgpy2 = wx.FileDialog(self, "Choisissez un fichier Python", wildcard = "*.pyd", style = wx.OPEN)
retour = dlgpy2.ShowModal()
chemin = dlgpy2.GetPath()
fichier = dlgpy2.GetFilename()
self.textbox2.SetValue(chemin)
dlgpy2.Destroy()
def buttonMakeClick(self, event):
self.boutonmake.Enable(False)
!!!!!!!!! page2.radio2.SetValue(True) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
self.radio2.SetValue(True)
!!!!!!!!!! if page2.radio1.GetValue() == True: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
self.output.SetValue("mouahaha it works")
result = self.output.GetValue()+os.popen('cmd').read()
self.output.SetValue(result)
def radio1Click(self, event):
self.boutonmake.Enable(True)
def radio2Click(self, event):
self.boutonmake.Enable(False)
class PageTwo(wx.Panel):
def __init__(self, parent):
self.cheminpyd = ""
wx.Panel.__init__(self, parent)
self.t = wx.StaticText(self, -1, "Exportation du .pyd une fois compilé :", (20,30))
self.radio1 = wx.RadioButton ( self, ID_RADIO1, 'au même endroit que le fichier Python', (40,70), style = wx.RB_GROUP )
self.radio2 = wx.RadioButton ( self, ID_RADIO2, 'chemin spécifié :', (40,110))
self.textbox = wx.TextCtrl(self, -1, "", (200,105), (300,20))
self.textbox.Enable(False)
self.bouton1 = wx.Button(self, ID_OPEN3, "Choose", (550,103))
self.t2 = wx.StaticText(self, -1, "Chemin de votre compilateur Python :", (20,180))
self.textbox2 = wx.TextCtrl(self, -1, "c:\Python25", (250,175), (250,20))
self.bouton2 = wx.Button(self, ID_OPEN4, "Choose", (550,173))
self.t3 = wx.StaticText(self, -1, "Chemin de votre compilateur Fortran :", (20,220))
self.textbox3 = wx.TextCtrl(self, -1, "c:\gfortran", (250,215), (250,20))
self.bouton3 = wx.Button(self, ID_OPEN5, "Choose", (550,213))
self.boutoncancel = wx.Button(self, -1, 'Cancel', (470,500))
self.boutonrun = wx.Button(self, -1, 'Apply', (390, 500))
self.Bind(wx.EVT_RADIOBUTTON, self.radio1Check, id=ID_RADIO1)
self.Bind(wx.EVT_RADIOBUTTON, self.radio2Check, id=ID_RADIO2)
self.Bind(wx.EVT_BUTTON, self.button1Click, id=ID_OPEN3)
self.Bind(wx.EVT_BUTTON, self.button2Click, id=ID_OPEN4)
self.Bind(wx.EVT_BUTTON, self.button3Click, id=ID_OPEN5)
def radio1Check(self, event):
self.textbox.Enable(False)
def radio2Check(self, event):
self.textbox.Enable(True)
def button1Click(self, event):
dlgpy3 = wx.FileDialog(self, "Chemin de votre .pyd", style = wx.OPEN)
self.radio2.SetValue(True)
self.textbox.Enable(True)
retour = dlgpy3.ShowModal()
chemin = dlgpy3.GetPath()
fichier = dlgpy3.GetFilename()
self.textbox.SetValue(chemin)
dlgpy3.Destroy()
def button2Click(self, event):
dlgpy4 = wx.FileDialog(self, "Chemin de python.exe", wildcard = "python.exe", style = wx.OPEN)
retour = dlgpy4.ShowModal()
chemin = dlgpy4.GetPath()
fichier = dlgpy4.GetFilename()
self.textbox2.SetValue(chemin)
dlgpy2.Destroy()
def button3Click(self, event):
dlgpy5 = wx.FileDialog(self, "Chemin de GFortran", style = wx.OPEN)
retour = dlgpy5.ShowModal()
chemin = dlgpy5.GetPath()
fichier = dlgpy5.GetFilename()
self.textbox3.SetValue(chemin)
dlgpy5.Destroy()
class Frame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(660, 600), style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)
tabmngr = wx.Notebook(self)
page1 = PageOne(tabmngr)
page2 = PageTwo(tabmngr)
page3 = PageThree(tabmngr)
tabmngr.AddPage(page1, "Make")
tabmngr.AddPage(page2, "Config")
tabmngr.AddPage(page3, "Help")
page1.boutonquit = wx.Button(page1, ID_QUIT, "Exit", (550, 500))
page2.boutonquit = wx.Button(page2, ID_QUIT, "Exit", (550, 500))
page3.boutonquit = wx.Button(page3, ID_QUIT, "Exit", (550, 500))
self.Bind(wx.EVT_BUTTON, self.buttonQuitClick, id=ID_QUIT)
self.Centre()
self.Show(True)
def buttonQuitClick (self, event):
self.Close()
app = wx.App()
sys.stderr = open("C:\\Documents and Settings\\bouillanne\\Bureau\\log.txt", "w")
Frame(None, -1, 'pyd Maker')
app.MainLoop() |
Partager