Package medite :: Package GUI :: Module MainPanel
[hide private]
[frames] | no frames]

Source Code for Module medite.GUI.MainPanel

  1  # -*- coding: iso-8859-1 -*- 
  2  # Copyright 20003 - 2008: Julien Bourdaillet (julien.bourdaillet@lip6.fr), Jean-Gabriel Ganascia (jean-gabriel.ganascia@lip6.fr) 
  3  # This file is part of MEDITE. 
  4  # 
  5  #    MEDITE is free software; you can redistribute it and/or modify 
  6  #    it under the terms of the GNU General Public License as published by 
  7  #    the Free Software Foundation; either version 2 of the License, or 
  8  #    (at your option) any later version. 
  9  # 
 10  #    MEDITE is distributed in the hope that it will be useful, 
 11  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  #    GNU General Public License for more details. 
 14  # 
 15  #    You should have received a copy of the GNU General Public License 
 16  #    along with Foobar; if not, write to the Free Software 
 17  #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 18  #---------------------------------------------------------------------------- 
 19  # Nom:          MainPanel.py 
 20  # Objet:        Classe correspondant au panel principal de l'interface medite 
 21  #---------------------------------------------------------------------------- 
 22  #from wxPython.wx import * 
 23  #from wx import Panel 
 24  #from wxPython.stc import * 
 25  import wx 
 26  import wx.stc 
 27  from Utile.constantesGUI import * 
 28  from GUI.Legende import * 
 29  from GUI.Parametres import * 
 30  import traceback 
 31  import FMPanel 
 32  import MediteAppli.synthetic 
 33  #from wxPython.lib.rcsizer import RowColSizer 
 34  #from wxPython.lib.grids import wxGridSizer, wxFlexGridSizer 
 35  import __main__ 
 36  #---------------------------------------------------------------------------- 
 37   
38 -class MainPanel(wx.Notebook):
39 """ Notebook gérant les différents panels autour d'une comparaison """
40 - def __init__(self, parent, planTravail):
41 wx.Notebook.__init__(self, parent, -1) 42 self.planTravail = planTravail 43 compPanel = ComparaisonPanel(self, self.planTravail) 44 self.InsertPage(0, compPanel, "Comparaison", True) #panel de comparaison en position 0 45 #self.SetClientSize(self.GetChildren()[0].GetSize()) 46 #self.SetBestFittingSize(wx.Size(900, 700)) 47 self.Refresh()
48 - def getComparaisonPanel(self):
49 """Renvoie le panel de comparaison """ 50 return self.GetPage(0)
51 - def isTreePanel(self):
52 return False
53 - def getTitre(self):
54 return self.getComparaisonPanel().getTitre()
55 - def setTitre(self, titre):
56 self.getComparaisonPanel().setTitre(titre)
57 - def addStatPanel(self,frequencyMatrix,textMatrix):
58 """ Ajoute des pages avec les panels de stat 59 pre: isinstance(frequencyMatrix,MediteAppli.Synthetic.TagFrequencyMatrix) 60 isinstance(frequencyMatrix,MediteAppli.Synthetic.TextFrequencyMatrix) 61 """ 62 fmPanelHisto = FMPanel.FMPanelHisto(self,frequencyMatrix) 63 self.AddPage(fmPanelHisto, u"Histogrammes", True) 64 65 fmPanelCam = FMPanel.FMPanelCamembert(self,frequencyMatrix) 66 self.AddPage(fmPanelCam, u"Etiquetage", True) 67 68 fm2 = MediteAppli.synthetic.TagFrequencyMatrix2(frequencyMatrix) 69 fmPanelCam2 = FMPanel.FMPanelCamembert2(self,fm2) 70 self.AddPage(fmPanelCam2, u"Etiquetage2", True) 71 72 fm3 = MediteAppli.synthetic.TagFrequencyMatrix3(frequencyMatrix) 73 fmPanelCam3 = FMPanel.FMPanelCamembert3(self,fm3) 74 self.AddPage(fmPanelCam3, u"Etiquetage3", True) 75 76 fmPanelCam4 = FMPanel.FMPanelCamembert4(self,textMatrix) 77 self.AddPage(fmPanelCam4, u"Etiquetage4", True)
78 79
80 -class ComparaisonPanel2(wx.Panel):
81 """ Classe du panel principal permettant d'afficher les informations du dossier genetique courant 82 les deux fenetres des états source et cible, et les fenetres transformations et commentaire 83 """
84 - def __init__(self, parent, planTravail):
85 wx.Panel.__init__(self, parent, -1) 86 87 self.planTravail = planTravail 88 self.initialised = False 89 90 self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) 91 self.fenetreMedite = parent.GetParent().GetParent() 92 93 w,h = self.fenetreMedite.GetSize() 94 w2 = (w/2)-10 95 ## line = wxStaticLine(self, -1, pos = wx.Point(0,0)) 96 97 # Fenetre d informations du dossier genetique charge 98 infoDGWin = wx.SashLayoutWindow(self, ID_WINDOW_TOP, wx.DefaultPosition, 99 wx.Size(300, 200), wx.NO_BORDER|wx.SW_3DSASH) 100 infoDGWin.SetDefaultSize(wx.Size(1000, 50)) 101 infoDGWin.SetMinimumSizeY(50) 102 infoDGWin.SetOrientation(wx.LAYOUT_HORIZONTAL) 103 infoDGWin.SetAlignment(wx.LAYOUT_TOP) 104 infoDGWin.SetSashVisible(wx.SASH_BOTTOM, True) 105 106 fe = wx.FontEnumerator() 107 fe.EnumerateFacenames() 108 listFont = fe.GetFacenames() 109 listFont.sort() 110 s1 = wx.StaticText(self, -1, "Police : ", (150, 10)) 111 self.lbFont = wx.ListBox(self, -1, wx.DefaultPosition, (180, 10), 112 listFont, wx.LB_SINGLE) 113 self.Bind(wx.EVT_LISTBOX, self.OnSelectFont, id=self.lbFont.GetId()) 114 115 self.textAuteur = wx.StaticText(infoDGWin, -1, "Auteur : ", (10, 10)) 116 #nomAuteur = self.fenetreMedite.planTravail.getAuteur() 117 nomAuteur = self.planTravail.getAuteur() 118 if nomAuteur == '': ecrireA = u"DG Non Charg\xe9" 119 else: ecrireA = nomAuteur 120 ## ecrireA = "DG Non Charg\xe9" 121 self.textInfoAuteur= wx.StaticText(infoDGWin, -1, ecrireA, (70, 10)) 122 123 #nomOeuvre = self.fenetreMedite.planTravail.getOeuvre() 124 nomOeuvre = self.planTravail.getOeuvre() 125 if nomOeuvre == '': ecrireO = u"DG Non Charg\xe9 " 126 else: ecrireO = nomOeuvre 127 ## ecrireO = "DG Non Charg\xe9 " 128 self.textOeuvre = wx.StaticText(infoDGWin, -1, "Oeuvre : ",(w2+100, 10), (90, -1)) 129 self.textInfoOeuvre= wx.StaticText(infoDGWin, -1,ecrireO,(w2+170, 10)) 130 131 #nomVS = self.fenetreMedite.planTravail.getVersionSource() 132 nomVS = self.planTravail.getVersionSource() 133 self.textVS = wx.StaticText(infoDGWin, -1, "VS : ",(10, 30)) 134 self.textInfoVersionS= wx.StaticText(infoDGWin, -1, nomVS, (35, 30)) 135 136 #nomFS = self.fenetreMedite.planTravail.getEtatSource() 137 nomFS = self.planTravail.getEtatSource() 138 self.textFS = wx.StaticText(infoDGWin, -1, "FS : ",(200, 30)) 139 self.textInfoEtatS= wx.StaticText(infoDGWin, -1, nomFS, (225, 30)) 140 141 self.indiceS = wx.TextCtrl(infoDGWin, -1, "",wx.Point(w2-50,28),wx.Size(30,18),wx.TE_READONLY) 142 143 #nomVC = self.fenetreMedite.planTravail.getVersionCible() 144 nomVC = self.planTravail.getVersionCible() 145 self.textVC = wx.StaticText(infoDGWin, -1, "VC : ",(w2+100, 30)) 146 self.textInfoVersionC= wx.StaticText(infoDGWin, -1, nomVC, (w2+125, 30)) 147 148 #nomFC = self.fenetreMedite.planTravail.getEtatCible() 149 nomFC = self.planTravail.getEtatCible() 150 self.textFC = wx.StaticText(infoDGWin, -1, "FC : ",(w2+300, 30)) 151 self.textInfoEtatC= wx.StaticText(infoDGWin, -1, nomFC, (w2+325, 30)) 152 153 self.indiceC = wx.TextCtrl(infoDGWin, -1, "",wx.Point(w2+20,28),wx.Size(30,18),wx.TE_READONLY) 154 155 infoDGWin.SetAutoLayout(True) 156 self.topWindow = infoDGWin 157 158 # Fenetre avec un noteBook affichant les resultats d'une comparaison 159 # le commentaire, la legende 160 infoResultat = wx.SashLayoutWindow(self, ID_WINDOW_BOTTOM, 161 wx.DefaultPosition, wx.Size(300, 200), 162 wx.NO_BORDER|wx.SW_3D) 163 infoResultat.SetDefaultSize(wx.Size(1000, 200)) 164 infoResultat.SetOrientation(wx.LAYOUT_HORIZONTAL) 165 infoResultat.SetAlignment(wx.LAYOUT_BOTTOM) 166 infoResultat.SetSashVisible(wx.SASH_TOP, True) 167 168 ID_NB = 6545 169 self.nb=wx.Notebook(infoResultat, ID_NB, style=wx.NB_BOTTOM) 170 self.nb.SetBestFittingSize(wx.Size(1000, 200)) 171 # transfo 172 self.transformations=wx.TextCtrl(self.nb, -1, "", wx.DefaultPosition, wx.DefaultSize, 173 wx.TE_MULTILINE|wx.TE_READONLY) 174 self.nb.AddPage(self.transformations,"TRANSFORMATIONS") 175 # comment 176 self.commentaire=wx.TextCtrl(self.nb, -1, "", wx.DefaultPosition, wx.DefaultSize, 177 wx.TE_MULTILINE)#|wx.TE_RICH2) 178 self.nb.AddPage(self.commentaire,"COMMENTAIRE") 179 # legende 180 self.legende = PanelLegende(self.nb, self.fenetreMedite) 181 self.nb.AddPage(self.legende,"LEGENDE") 182 # Parametres 183 self.param = PanelParametres(self.nb, self.fenetreMedite) 184 self.nb.AddPage(self.param,"PARAMETRES") 185 wx.EVT_NOTEBOOK_PAGE_CHANGING(self,ID_NB, self.OnNBPageChanging) 186 187 self.bottomWindow = infoResultat 188 self.bottomWindow.Refresh() 189 190 # Fenetre affichant l'état source 191 winLeft = wx.SashLayoutWindow(self, ID_WINDOW_LEFT, 192 wx.DefaultPosition, wx.Size(200, 30), 193 wx.NO_BORDER|wx.SW_3D) 194 ## w2 correspond a la largeur/2 de la fenetre Medite 195 winLeft.SetDefaultSize(wx.Size(w2, 1000)) 196 winLeft.SetOrientation(wx.LAYOUT_VERTICAL) 197 winLeft.SetAlignment(wx.LAYOUT_LEFT) 198 winLeft.SetSashVisible(wx.SASH_RIGHT, True) 199 winLeft.SetExtraBorderSize(0) 200 self.textWindowLeft = wx.TextCtrl(winLeft, -1, "", wx.DefaultPosition, wx.DefaultSize, 201 wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2) 202 self.textWindowLeft.SetValue(u"état source") 203 wx.EVT_LEFT_DOWN(self.textWindowLeft, self.indiceBlocLeft) 204 # EVT_LEFT_UP(self.textWindowLeft, self.selectBlocLeft) 205 self.leftWindow = winLeft 206 207 # Fenetre affichant l'état cible 208 winRight = wx.SashLayoutWindow(self, ID_WINDOW_RIGHT, 209 wx.DefaultPosition, wx.Size(200, 30), 210 wx.NO_BORDER|wx.SW_3D) 211 winRight.SetDefaultSize(wx.Size(w2, 1000)) 212 winRight.SetOrientation(wx.LAYOUT_VERTICAL) 213 winRight.SetAlignment(wx.LAYOUT_RIGHT) 214 winRight.SetSashVisible(wx.SASH_LEFT, True) 215 winRight.SetExtraBorderSize(0) 216 self.textWindowRight = wx.TextCtrl(winRight, -1, "", wx.DefaultPosition, wx.DefaultSize, 217 wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2) 218 self.textWindowRight.SetValue(u"état cible") 219 wx.EVT_LEFT_DOWN(self.textWindowRight, self.indiceBlocRight) 220 # EVT_LEFT_UP(self.textWindowRight, self.selectBlocRight) 221 self.rightWindow = winRight 222 223 wx.EVT_SASH_DRAGGED_RANGE(self, ID_WINDOW_TOP,ID_WINDOW_BOTTOM, self.OnSashDrag) 224 wx.EVT_SIZE(self, self.OnSize)
225
226 - def getTitre(self):
227 return self.planTravail.getEtatSource()+"-"+self.planTravail.getEtatCible()
228
229 - def setTitre(self, titre):
230 self.SetTitle(titre)
231
232 - def OnSelectFont(self,event):
233 face = self.lbFont.GetStringSelection() 234 font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, face) 235 #self.txt.SetLabel(face) 236 self.textWindowLeft.SetFont(font) 237 self.textWindowRight.SetFont(font) 238 self.transformations.SetFont(font) 239 self.commentaire.SetFont(font)
240
241 - def OnNBPageChanging(self,event):
242 self.legende.bInser.SetBackgroundColour(self.legende.coulInsert) 243 self.legende.bSupp.SetBackgroundColour(self.legende.coulSupp) 244 self.legende.bRemp.SetBackgroundColour(self.legende.coulRemp)
245 246 #Methode qui permet de redimensionner les fenetres des états source et cible
247 - def OnSashDrag(self, event):
248 if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: 249 return 250 eID = event.GetId() 251 if eID == ID_WINDOW_TOP: 252 self.topWindow.SetDefaultSize(wx.Size(1000, event.GetDragRect().height)) 253 elif eID == ID_WINDOW_LEFT: 254 self.leftWindow.SetDefaultSize(wx.Size(event.GetDragRect().width, 1000)) 255 elif eID == ID_WINDOW_RIGHT : 256 self.rightWindow.SetDefaultSize(wx.Size(event.GetDragRect().width, 1000)) 257 elif eID == ID_WINDOW_BOTTOM: 258 self.bottomWindow.SetDefaultSize(wx.Size(1000, event.GetDragRect().height)) 259 260 wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) 261 self.remainingSpace.Refresh()
262 263 # Methode qui redimensionne la fenetre
264 - def OnSize(self, event):
265 wx.LayoutAlgorithm().LayoutWindow(self)#, self.remainingSpace) 266 w,h=event.GetSize() 267 self.size(w)
268 - def sizeF(self):
269 w,h=self.fenetreMedite.GetSize() 270 self.size(w)
271 - def size(self,w):
272 width=w/2 273 self.leftWindow.SetDefaultSize(wx.Size(width, 1000)) 274 self.rightWindow.SetDefaultSize(wx.Size(w-width, 1000))
275 #self.indiceS.SetPosition((width-55,28)) 276 #self.indiceC.SetPosition((width+15,28)) 277 #self.textOeuvre.setPosition((w/4,10)) 278 #self.textInfoOeuvre.SetPosition((w/4+70,10)) 279 280 # Methodes qui gere les clics dans les fenetres source et cible
281 - def indiceBlocRight(self,evt):
282 if self.transformations.GetValue()!='': 283 evt.Skip() 284 wx.CallAfter(self.positionRight, evt)
285
286 - def indiceBlocLeft(self,evt):
287 if self.transformations.GetValue()!='': 288 evt.Skip() 289 wx.CallAfter(self.positionLeft, evt)
290 291 ## Methodes qui gère les correspondances entre blocs et entre déplacements
292 - def positionLeft(self, evt):
293 try: 294 ip = self.textWindowLeft.GetInsertionPoint() 295 transfo = self.resultatTransfoAffichageOnly 296 297 depl = self.indiceSourceToPaireBlocsDepl(ip,transfo) 298 if depl != None: 299 self.textWindowRight.ShowPosition(depl) 300 self.textWindowLeft.ShowPosition(ip) 301 return 302 303 numBloc,posDansBloc = self.numeroBlocsCommunsSource(ip,transfo) 304 if numBloc != None : 305 self.indiceS.SetValue("%s"%(numBloc+1)) 306 self.indiceC.SetValue("%s"%(numBloc+1)) 307 indic = self.numBlocCibleToIndice(numBloc,transfo) 308 309 self.textWindowLeft.ShowPosition(ip) 310 self.textWindowRight.ShowPosition(indic+posDansBloc) 311 # self.textWindowLeft.SetSelection(ip-10,ip+10) 312 # self.textWindowRight.SetSelection(indic+posDansBloc-10,indic+posDansBloc+10) 313 else: 314 self.indiceS.SetValue('') 315 self.indiceC.SetValue('') 316 except Exception,e1: 317 sys.stderr.write(str(e1)) 318 traceback.print_exc() 319 sys.stderr.flush()
320
321 - def positionRight(self, evt):
322 try: 323 ip = self.textWindowRight.GetInsertionPoint() 324 transfo = self.resultatTransfoAffichageOnly 325 depl = self.indiceCibleToPaireBlocsDepl(ip,transfo) 326 if depl != None: 327 self.textWindowLeft.ShowPosition(depl) 328 self.textWindowRight.ShowPosition(ip) 329 return 330 numBloc,posDansBloc = self.numeroBlocsCommunsCible(ip,transfo) 331 if numBloc != None : 332 self.indiceC.SetValue("%s"%(numBloc+1)) 333 self.indiceS.SetValue("%s"%(numBloc+1)) 334 indic = self.numBlocSourceToIndice(numBloc,transfo) 335 336 self.textWindowRight.ShowPosition(ip) 337 self.textWindowLeft.ShowPosition(indic+posDansBloc) 338 # self.textWindowRight.SetSelection(ip-10,ip+10) 339 # self.textWindowLeft.SetSelection(indic+posDansBloc-10,indic+posDansBloc+10) 340 else: 341 self.indiceC.SetValue('') 342 self.indiceS.SetValue('') 343 except Exception,e1: 344 sys.stderr.write(str(e1)) 345 traceback.print_exc() 346 sys.stderr.flush()
347 348 # ## Methodes qui gere les evenements de selection dans l'une des fenetres 349 # def selectBlocLeft(self, evt): 350 # if self.transformations.GetValue()!='': 351 # start, end = self.textWindowLeft.GetSelection() 352 # #transfo = self.fenetreMedite.resultatTransfoAffichageOnly 353 # transfo = self.resultatTransfoAffichageOnly 354 # blocsDepl = transfo.getListeDeplacements() 355 # textes = transfo.getTextesConcatenes() 356 # nbB = len(blocsDepl)/2 357 # selec = textes[start:end] 358 # for X in blocsDepl[nbB:] : 359 # if textes[X[0]:X[1]] == selec: 360 # # print 'selection source faite' 361 # indic = X[0]-transfo.getLgSource() 362 # self.textWindowRight.ShowPosition(indic) 363 # #self.textWindowLeft.ShowPosition(X[0]) 364 # return 365 # 366 # def selectBlocRight(self, evt): 367 # if self.transformations.GetValue()!='': 368 # start, end = self.textWindowRight.GetSelection() 369 # #transfo = self.fenetreMedite.resultatTransfoAffichageOnly 370 # transfo = self.resultatTransfoAffichageOnly 371 # blocsDepl = transfo.getListeDeplacements() 372 # textes = transfo.getTextesConcatenes() 373 # lgTextS = transfo.getLgSource() 374 # nbB = len(blocsDepl)/2 375 # selec = textes[start+lgTextS:end+lgTextS] 376 # lgSelect = len(selec) 377 # s = start+lgTextS 378 # for X in blocsDepl[0:nbB] : 379 # if textes[X[0]:X[1]] == selec: 380 # # print 'selection cible faite' 381 # indic = X[0] 382 # self.textWindowLeft.ShowPosition(indic) 383 # #self.textWindowRight.ShowPosition(X[0]-transfo.getLgSource()) 384 # return 385
386 - def numeroBlocsCommunsSource(self, indice, pTransfo):
387 #sys.stderr.write("indice="+str(indice)+"\n") 388 n = 0 389 tableau = pTransfo.getBlocsCommuns() 390 for cple in tableau[:len(tableau)/2] : 391 #sys.stderr.write("cple="+str(cple)+"\n") 392 if indice>=cple[0] and indice<cple[1]: 393 return n, indice-cple[0]#-indice 394 n+=1 395 return None,None
396
397 - def numeroBlocsCommunsCible(self, indice, pTransfo):
398 # n = 0 399 # for cple in pTransfo.getBlocsCommuns() : 400 # sys.stderr.write("n="+str(n)+" / cple="+str(cple[0])+" "+str(cple[1])+" / lS="+str(pTransfo.getLgSource())+"\n") 401 # sys.stderr.flush() 402 # n+=1 403 n=0 404 indiceC = indice+pTransfo.getLgSource() 405 tableau = pTransfo.getBlocsCommuns() 406 #lgTextS = pTransfo.getLgSource() 407 taille = len(tableau)/2 408 for cple in tableau : 409 if indiceC>=cple[0] and indiceC<cple[1]: 410 return n-taille, indiceC-cple[0]#-lgTextS #-indiceC 411 n+=1 412 return None,None
413
414 - def numBlocSourceToIndice(self, numBloc,pTransfo):
415 blocs = pTransfo.getBlocsCommuns() 416 cple = blocs[numBloc]#-1] 417 return cple[0]
418
419 - def numBlocCibleToIndice(self, numBloc,pTransfo):
420 lgTextS = pTransfo.getLgSource() 421 blocs = pTransfo.getBlocsCommuns() 422 taille = len(blocs)/2 423 i = numBloc+taille #-1 424 425 cple = blocs[i] 426 indice = cple[0]-lgTextS 427 return indice
428
429 - def indiceSourceToPaireBlocsDepl(self, indice, pTransfo):
430 pairesBlocsDepl = pTransfo.getPairesBlocsDeplaces() 431 lgTextS = pTransfo.getLgSource() 432 for b1,b2 in pairesBlocsDepl: 433 if (indice >= b1[0] and indice<b1[1]): 434 return b2[0]-lgTextS
435
436 - def indiceCibleToPaireBlocsDepl(self, indice, pTransfo):
437 pairesBlocsDepl = pTransfo.getPairesBlocsDeplaces() 438 lgTextS = pTransfo.getLgSource() 439 for b1,b2 in pairesBlocsDepl: 440 if (indice+lgTextS >= b2[0] and indice+lgTextS<b2[1]): 441 return b1[0]
442
443 -class ComparaisonPanel(ComparaisonPanel2):
444 - def __init__(self, parent, planTravail):
445 wx.Panel.__init__(self, parent, -1) 446 self.planTravail = planTravail 447 self.initialised = False 448 self.fenetreMedite = parent.GetParent().GetParent() 449 450 self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) 451 self.Bind(wx.wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag, 452 id=ID_WINDOW_TOP, id2=ID_WINDOW_BOTTOM,) 453 self.Bind(wx.wx.EVT_SIZE, self.OnSize) 454 455 w,h = self.fenetreMedite.GetSize() 456 w2 = (w/2)-10 457 ## line = wxStaticLine(self, -1, pos = wx.Point(0,0)) 458 459 # Fenetre d informations du dossier genetique charge 460 infoDGWin = wx.SashLayoutWindow(self, ID_WINDOW_TOP, wx.DefaultPosition, 461 wx.Size(300, 200), wx.NO_BORDER|wx.SW_3DSASH) 462 infoDGWin.SetDefaultSize(wx.Size(1000, 50)) 463 infoDGWin.SetMinimumSizeY(50) 464 infoDGWin.SetOrientation(wx.LAYOUT_HORIZONTAL) 465 infoDGWin.SetAlignment(wx.LAYOUT_TOP) 466 infoDGWin.SetSashVisible(wx.SASH_BOTTOM, True) 467 468 #fe = wx.FontEnumerator() 469 #fe.EnumerateFacenames() 470 #listFont = fe.GetFacenames() 471 #listFont.sort() 472 #s1 = wx.StaticText(self, -1, "Police : ", (150, 10)) 473 #self.lbFont = wx.ListBox(self, -1, (190, 10), (150,100), 474 # listFont, wx.LB_SINGLE) 475 #self.Bind(wx.EVT_LISTBOX, self.OnSelectFont, id=self.lbFont.GetId()) 476 477 btn = wx.Button(infoDGWin, -1, "Police", (200, 6)) 478 self.Bind(wx.wx.EVT_BUTTON, self.OnSelectFont, btn) 479 480 self.textAuteur = wx.StaticText(infoDGWin, -1, "Auteur : ", (10, 10)) 481 #nomAuteur = self.fenetreMedite.planTravail.getAuteur() 482 nomAuteur = self.planTravail.getAuteur() 483 if nomAuteur == '': ecrireA = u"DG Non Charg\xe9" 484 else: ecrireA = nomAuteur 485 ## ecrireA = "DG Non Charg\xe9" 486 self.textInfoAuteur= wx.StaticText(infoDGWin, -1, ecrireA, (70, 10)) 487 488 #nomOeuvre = self.fenetreMedite.planTravail.getOeuvre() 489 nomOeuvre = self.planTravail.getOeuvre() 490 if nomOeuvre == '': ecrireO = u"DG Non Charg\xe9 " 491 else: ecrireO = nomOeuvre 492 ## ecrireO = "DG Non Charg\xe9 " 493 self.textOeuvre = wx.StaticText(infoDGWin, -1, "Oeuvre : ",(w2+100, 10), (90, -1)) 494 self.textInfoOeuvre= wx.StaticText(infoDGWin, -1,ecrireO,(w2+170, 10)) 495 496 #nomVS = self.fenetreMedite.planTravail.getVersionSource() 497 nomVS = self.planTravail.getVersionSource() 498 self.textVS = wx.StaticText(infoDGWin, -1, "VS : ",(10, 30)) 499 self.textInfoVersionS= wx.StaticText(infoDGWin, -1, nomVS, (35, 30)) 500 501 #nomFS = self.fenetreMedite.planTravail.getEtatSource() 502 nomFS = self.planTravail.getEtatSource() 503 self.textFS = wx.StaticText(infoDGWin, -1, "FS : ",(200, 30)) 504 self.textInfoEtatS= wx.StaticText(infoDGWin, -1, nomFS, (225, 30)) 505 506 self.indiceS = wx.TextCtrl(infoDGWin, -1, "",wx.Point(w2-50,28),wx.Size(30,18),wx.TE_READONLY) 507 508 #nomVC = self.fenetreMedite.planTravail.getVersionCible() 509 nomVC = self.planTravail.getVersionCible() 510 self.textVC = wx.StaticText(infoDGWin, -1, "VC : ",(w2+100, 30)) 511 self.textInfoVersionC= wx.StaticText(infoDGWin, -1, nomVC, (w2+125, 30)) 512 513 #nomFC = self.fenetreMedite.planTravail.getEtatCible() 514 nomFC = self.planTravail.getEtatCible() 515 self.textFC = wx.StaticText(infoDGWin, -1, "FC : ",(w2+300, 30)) 516 self.textInfoEtatC= wx.StaticText(infoDGWin, -1, nomFC, (w2+325, 30)) 517 518 self.indiceC = wx.TextCtrl(infoDGWin, -1, "",wx.Point(w2+20,28),wx.Size(30,18),wx.TE_READONLY) 519 520 #infoDGWin.SetAutoLayout(True) 521 self.topWindow = infoDGWin 522 523 # Fenetre avec un noteBook affichant les resultats d'une comparaison 524 # le commentaire, la legende 525 infoResultat = wx.SashLayoutWindow(self, ID_WINDOW_BOTTOM, 526 wx.DefaultPosition, wx.Size(300, 200), 527 wx.NO_BORDER|wx.SW_3D) 528 infoResultat.SetDefaultSize(wx.Size(1000, 200)) 529 infoResultat.SetOrientation(wx.LAYOUT_HORIZONTAL) 530 infoResultat.SetAlignment(wx.LAYOUT_BOTTOM) 531 infoResultat.SetSashVisible(wx.SASH_TOP, True) 532 533 ID_NB = 6545 534 self.nb=wx.Notebook(infoResultat, ID_NB, style=wx.NB_BOTTOM) 535 #self.nb.SetBestFittingSize(wx.Size(1000, 200)) 536 self.nb.SetInitialSize(wx.Size(1000, 200)) 537 # transfo 538 options = wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2 539 if __main__.RTL: options |= wx.TE_RIGHT 540 self.transformations=wx.TextCtrl(self.nb, -1, "", wx.DefaultPosition, wx.DefaultSize, 541 options) 542 self.nb.AddPage(self.transformations,"TRANSFORMATIONS") 543 # comment 544 self.commentaire=wx.TextCtrl(self.nb, -1, "", wx.DefaultPosition, wx.DefaultSize, 545 wx.TE_MULTILINE|wx.TE_RICH2) 546 self.nb.AddPage(self.commentaire,"COMMENTAIRE") 547 # legende 548 self.legende = PanelLegende(self.nb, self.fenetreMedite) 549 self.nb.AddPage(self.legende,"LEGENDE") 550 # Parametres 551 self.param = PanelParametres(self.nb, self.fenetreMedite) 552 self.nb.AddPage(self.param,"PARAMETRES") 553 wx.EVT_NOTEBOOK_PAGE_CHANGING(self,ID_NB, self.OnNBPageChanging) 554 555 self.bottomWindow = infoResultat 556 self.bottomWindow.Refresh() 557 558 # Fenetre affichant l'état source 559 winLeft = wx.SashLayoutWindow(self, ID_WINDOW_LEFT, 560 wx.DefaultPosition, wx.Size(200, 30), 561 wx.NO_BORDER|wx.SW_3D) 562 ## w2 correspond a la largeur/2 de la fenetre Medite 563 winLeft.SetDefaultSize(wx.Size(w2, 1000)) 564 winLeft.SetOrientation(wx.LAYOUT_VERTICAL) 565 winLeft.SetAlignment(wx.LAYOUT_LEFT) 566 winLeft.SetSashVisible(wx.SASH_RIGHT, True) 567 winLeft.SetExtraBorderSize(0) 568 options = wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2 569 if __main__.RTL: options |= wx.TE_RIGHT 570 self.textWindowLeft = wx.TextCtrl(winLeft, -1, "", wx.DefaultPosition, wx.DefaultSize, 571 options) 572 #self.textWindowLeft = wx.stc.StyledTextCtrl(winLeft,-1) 573 #self.textWindowLeft = stylTxt(winLeft,-1) 574 #self.textWindowLeft.SetValue(u"état source") 575 wx.EVT_LEFT_DOWN(self.textWindowLeft, self.indiceBlocLeft) 576 # EVT_LEFT_UP(self.textWindowLeft, self.selectBlocLeft) 577 self.leftWindow = winLeft 578 579 # Fenetre affichant l'état cible 580 winRight = wx.SashLayoutWindow(self, ID_WINDOW_RIGHT, 581 wx.DefaultPosition, wx.Size(200, 30), 582 wx.NO_BORDER|wx.SW_3D) 583 winRight.SetDefaultSize(wx.Size(w2, 1000)) 584 winRight.SetOrientation(wx.LAYOUT_VERTICAL) 585 winRight.SetAlignment(wx.LAYOUT_RIGHT) 586 winRight.SetSashVisible(wx.SASH_LEFT, True) 587 winRight.SetExtraBorderSize(0) 588 self.textWindowRight = wx.TextCtrl(winRight, -1, "", wx.DefaultPosition, wx.DefaultSize, 589 options) 590 #self.textWindowRight = stylTxt(winRight,-1) #wx.stc.StyledTextCtrl(winRight,-1) 591 #self.textWindowRight.SetValue(u"état cible") 592 wx.EVT_LEFT_DOWN(self.textWindowRight, self.indiceBlocRight) 593 # EVT_LEFT_UP(self.textWindowRight, self.selectBlocRight) 594 self.rightWindow = winRight
595
596 - def OnSelectFont(self, evt):
597 data = wx.FontData() 598 data.EnableEffects(True) 599 textAttribute = wx.TextAttr() 600 self.textWindowRight.GetStyle(0, textAttribute) 601 #data.SetInitialFont(textAttribute.GetFont()) 602 data.SetInitialFont(self.textWindowLeft.GetFont()) 603 data.SetColour(textAttribute.GetTextColour()) 604 605 dlg = wx.FontDialog(self, data) 606 if dlg.ShowModal() == wx.ID_OK: 607 data = dlg.GetFontData() 608 font = data.GetChosenFont() 609 colour = data.GetColour() 610 self.textWindowLeft.SetFont(font) 611 self.textWindowRight.SetFont(font) 612 self.transformations.SetFont(font) 613 self.commentaire.SetFont(font) 614 self.fenetreMedite.affichageCouleur() 615 dlg.Destroy()
616
617 -class stylTxt(wx.stc.StyledTextCtrl):
618 - def __init__(self,parent,id):
619 wx.stc.StyledTextCtrl.__init__(self,parent,id) 620 self.SetMarginWidth(0, 0) 621 self.SetMarginWidth(1, 0) 622 self.SetMarginWidth(2, 0) 623 self.StyleSetSpec(0, "bold,underline" ) #dep 624 self.StyleSetSpec(1, "back:#0000FF" ) #ins 625 self.StyleSetSpec(2, "back:#00FF00" ) #ins
626
627 - def GetInsertionPoint(self):
628 return self.GetCurrentPos()
629
630 - def ShowPosition(self,pos):
631 self.GotoPos(pos)
632 - def SetValue(self,texte):
633 self.SetText(texte)
634
635 - def SetStyle(self,deb,fin,style):
636 self.StartStyling(deb, 0x1f) 637 self.SetStyling(fin-deb, style)
638