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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
| #!/usr/bin/python
# -*- coding:Utf-8 -*-
import wxversion, os, getopt, sys, urllib, signal, urlparse
wxversion.select("2.8")
import wx
class VarGUI(object):
currentBuffer = ""
currentFile = ""
class VarPOL(object):
int2 = 0
class VarOther(object):
int3 = 0
########################## DECLARATION FENï¿TRE PRINCIPALE #########################
class POLscFenp(wx.Frame): #fenï¿tre principale
def __init__(self, titre):
wx.Frame.__init__(self, None, -1, title = titre,
style = wx.DEFAULT_FRAME_STYLE |wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX, size = (1024, 768))
self.SetIcon(wx.Icon("./images/configure.png", wx.BITMAP_TYPE_ANY))
#print self
#******************* Menus ******************
#main
self.fileMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.commandMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.sendMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.configMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.aboutMenu = wx.Menu(style = wx.MENU_TEAROFF)
#sub
self.fileDirectorySubMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.prefixeSubMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.wineVersionSubMenu = wx.Menu(style = wx.MENU_TEAROFF)
self.CDROMSubMenu = wx.Menu(style = wx.MENU_TEAROFF)
#******************* Assignation ***************
#Fichier
self.fileMenu.Append(wx.ID_NEW, "&Nouveau", "Nouveau script")
self.fileMenu.Append(wx.ID_OPEN, "&Ouvrir", "Ouvrir un script/fichier")
self.fileMenu.Append(wx.ID_SAVE, "&Enregistrer", "Enregistrer le fichier courant")
self.fileMenu.Append(wx.ID_SAVEAS, "&Enregistrer sous...","Enregistrer sous")
self.fileMenu.AppendSeparator()
self.fileMenu.Append(wx.ID_EXIT, "&Quitter", "Quitter")
#Send
self.runMenuObject = wx.MenuItem(self.sendMenu, 100, "&Executer le script")
self.runMenuObject.SetBitmap(wx.Bitmap("images/run.png"))
self.sendMenu.AppendItem(self.runMenuObject)
self.proposeMenuObject = wx.MenuItem(self.sendMenu, 101, "&Proposer son script")
self.proposeMenuObject.SetBitmap(wx.Bitmap("images/up.png"))
self.sendMenu.AppendItem(self.proposeMenuObject)
#Files and directory (SUB)
self.fileDirectorySubMenu.Append(-1, "Se placer dans un répertoire", "")
#Prefix (SUB)
self.prefixeSubMenu.Append(-1, "Créer un préfixe", "")
#Wine Versions (SUB)
self.wineVersionSubMenu.Append(-1, "Assigner une version de Wine", "")
self.wineVersionSubMenu.Append(-1, "Désassigner une version de Wine", "")
self.wineVersionSubMenu.Append(-1, "Installer une version de Wine", "")
self.wineVersionSubMenu.Append(-1, "Désinstaller une version de Wine", "")
#CDROM (SUB)
self.CDROMSubMenu.Append(-1, "Choisir le point de montage", "")
self.CDROMSubMenu.Append(-1, "Monter le lecteur sur un point de montage", "")
self.CDROMSubMenu.Append(-1, "Tester la présence d'un executable", "")
#Commands
self.commandMenu.AppendSubMenu(self.fileDirectorySubMenu, "Fichier et répertoire", "")
self.commandMenu.AppendSubMenu(self.prefixeSubMenu, "Préfixes Wine", "")
self.commandMenu.AppendSubMenu(self.wineVersionSubMenu, "Versions de Wine", "")
self.commandMenu.AppendSubMenu(self.CDROMSubMenu, "CD-ROM", "")
#Config
self.configureMenuObject = wx.MenuItem(self.configMenu, 102, "&Configurer l'interface")
self.configureMenuObject.SetBitmap(wx.Bitmap("images/configure.png"))
self.configMenu.AppendItem(self.configureMenuObject)
self.langMenuObject = wx.MenuItem(self.configMenu, 103, "&Langue")
self.langMenuObject.SetBitmap(wx.Bitmap("images/flag.png"))
self.configMenu.AppendItem(self.langMenuObject)
#About
self.aboutMenu.Append(wx.ID_HELP, "&Aide en ligne", "Obtenir de l'aide en ligne")
self.aboutMenu.Append(wx.ID_ABOUT, "&À propos de PolScriptCreator", "A propos de PolScriptCreator")
#******************* Implantation **************
self.menuBar = wx.MenuBar()
self.menuBar.Append(self.fileMenu, "&Fichier")
self.menuBar.Append(self.sendMenu, "&Finalisation")
self.menuBar.Append(self.commandMenu, "&Fonctions")
self.menuBar.Append(self.configMenu, "&Configuration")
self.menuBar.Append(self.aboutMenu, "&A propos")
self.SetMenuBar(self.menuBar)
#******************* ToolBar ********************
self.toolBar = self.CreateToolBar(wx.TB_TEXT | wx.TB_FLAT)
self.toolBar.AddLabelTool(wx.ID_NEW, "Nouveau fichier",wx.ArtProvider.GetBitmap("gtk-new", wx.ART_TOOLBAR))
self.toolBar.AddLabelTool(wx.ID_OPEN, "Ouvrir un fichier", wx.ArtProvider.GetBitmap("gtk-open", wx.ART_TOOLBAR))
self.toolBar.AddLabelTool(wx.ID_SAVE, "Sauvegarder", wx.ArtProvider.GetBitmap("gtk-save", wx.ART_TOOLBAR))
self.toolBar.AddLabelTool(wx.ID_FIND, "Rechercher", wx.ArtProvider.GetBitmap("gtk-find", wx.ART_TOOLBAR))
#******************* TextArea *******************
self.currentTextArea = wx.TextCtrl(self, -1, "", wx.DefaultPosition, (1024, 768), wx.TE_MULTILINE)
self.textBox = wx.BoxSizer(wx.VERTICAL)
self.textBox2 = wx.BoxSizer(wx.HORIZONTAL)
self.textBox2.Add(self.currentTextArea, 1,wx.ALL)
self.textBox.Add(self.textBox2, 0, wx.EXPAND | wx.ALL)
######################################### EVENENEMENTS ##############################################
wx.EVT_MENU(self, wx.ID_ABOUT, self.aboutPOLSC)
wx.EVT_MENU(self, wx.ID_OPEN, self.openFile)
wx.EVT_MENU(self, wx.ID_SAVE, self.saveFile)
wx.EVT_MENU(self, wx.ID_SAVEAS, self.saveFileAs)
wx.EVT_MENU(self, wx.ID_NEW, self.cdFunctionShow)
#wx.EVT_CLOSE(self.onQuit)
######################################## FONCTIONS GUI ##############################################
def aboutPOLSC(self, event):
self.aboutBox = wx.AboutDialogInfo()
self.aboutBox.SetName("PolScriptCreator")
self.aboutBox.SetVersion("0.1~beta1")
self.aboutBox.SetDescription("Créateur de script pour PlayOnLinux")
self.aboutBox.SetCopyright("© Zoloom 2007\nSous licence GPL version 3")
self.aboutBox.AddDeveloper("Zoloom (Cassarin-Grand Arthur)")
self.aboutBox.AddArtist("Les logos sont issus des projets Tango et Crystal Project")
self.aboutBox.SetWebSite("http://www.playonlinux.com")
self.about = wx.AboutBox(self.aboutBox)
def openFile(self, event):
self.nameFile1 = wx.FileSelector("Script à ouvrir...")
self.file1 = open(self.nameFile1 , 'r')
self.bufferFile1Opened = self.file1.read()
self.currentTextArea.AppendText(self.bufferFile1Opened)
VarGUI.currentFile = self.nameFile1
self.file1.close()
def openFileWithoutEvent(self, nameFileAs):
self.currentTextArea.SetValue("")
self.file1 = open(nameFileAs , 'r')
self.bufferFile1Opened = self.file1.read()
self.currentTextArea.AppendText(self.bufferFile1Opened)
VarGUI.currentFile = self.nameFileAs
self.file1.close()
def saveFile(self, event):
if (VarGUI.currentFile == ""):
wx.MessageBox("Aucun fichier ouvert", "POLSC", wx.ICON_ERROR)
else:
VarGUI.currentBuffer = self.currentTextArea.GetValue()
self.currentFileOpenSaved = open(VarGUI.currentFile, "w")
self.currentFileOpenSaved.write(VarGUI.currentBuffer)
self.currentFileOpenSaved.close()
def saveFileAs(self, event):
self.askFileSaveAs = wx.FileDialog(self, "Enregistrer sous...", style = wx.FD_SAVE)
self.askFileSaveAs.ShowModal()
self.nameFileAs = self.askFileSaveAs.GetFilename()
if (self.nameFileAs != ""):
VarGUI.currentBuffer = self.currentTextArea.GetValue()
self.currentFileOpenSavedAs = open(self.nameFileAs, "a")
self.currentFileOpenSavedAs.write(VarGUI.currentBuffer)
VarGUI.currentFile = self.nameFileAs
self.currentFileOpenSavedAs.close()
self.openFileWithoutEvent(self.nameFileAs)
def newFile(self, event):
self.dialogSureNew = wx.MessageDialog(self, "Cette action effacera toute modification anterieure. Voulez vous continuer ?", "POLSC", wx.YES_NO | wx.ICON_QUESTION)
if (self.dialogSureNew.ShowModal() == wx.ID_YES):
self.currentTextArea.SetValue("")
def OnQuit(self, event):
if (self.currentTextArea.GetValue() != ""):
self.dialogSureQuit = wx.MessageDialog(self, "Êtes vous sûr de vouloir quitter ?", "POLSC", wx.YES_NO | wx.ICON_QUESTION)
if (self.dialogSureNew.ShowModal() == wx.ID_YES):
exit(255)
def cdFunctionShow(self, event):
cdFen = cdFunction(POLscFenp.fenp, "POUET")
class cdFunction(wx.MiniFrame):
def __init__(self, *args, **kwargs):
wx.MiniFrame.__init__(self, *args, **kwargs)
self.parent = self.GetParent()
self.parent.currentTextArea.SetValue("POUEEEEEEEEEEEEEEEEEEET")
########################## DECLARATION DE L'APPLICATION ###########################
class POLscApp(wx.App): #instance principale classe application
def OnInit(self):
fenp = POLscFenp("PlayOnLinux - PolScriptCreator")
fenp.Center(wx.BOTH)
fenp.Show(True)
self.SetTopWindow(fenp)
return True
FenpApp = POLscApp(redirect=False) #création de l'application
FenpApp.MainLoop() |