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
| #!/usr/bin/python
# -*- coding: iso-8859-15 -*-
# Ce ci est un script qui permet de charger une sequence fasta,
# l'afficher dans la zone de text et l'enregistrer dans un fichier txt.
#importation de la bibliotheque wx
import wx
import wx.lib.agw.genericmessagedialog as GMD
import wx.lib.inspection
import os
import sys
#Creation de la fenetre d'accueil
class Accueil(wx.Frame) :
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title) #Garder une trace des parents pour le cas des objets imbriques
self.parent = parent
self.Bind(wx.EVT_ENTER_WINDOW, self.focusFollowsMouse())
self.Centre()
self.creation_widgets() #Intitialise la fenetre et ses widgets(composes) afin de l'afficher une fois creer
def creation_widgets(self):
#Gestion des positions dans la fenetre
sizer = wx.GridBagSizer()
#@@@@@@@@@@ Creation de statut barre @@@@@@@@@@@
self.CreateStatusBar()
self.SetStatusText("This is ATTN SEQUENCES ANALYSIS PROGRAM EVRY VAL D'ESSONNE UNIVERSITY 2010-2011")
#@@@@@@@@@@ Creation de la barre de menu @@@@@@@@@@@
menuFichier = wx.Menu()
menuFichier.Append(wx.ID_OPEN, "&Ouvrir\tCTRL+o")
menuFichier.Append(wx.ID_CLOSE, "&Fermer\tCTRL+f")
menuFichier.AppendSeparator()
menuFichier.Append(wx.ID_EXIT, "&Quitter\tCTRL+q")
menuBarre = wx.MenuBar()
menuBarre.Append(menuFichier, "&Fichier")
self.SetMenuBar(menuBarre)
#LABEL_TITRE
self.label = wx.StaticText(self,1,label=u'ALIGNEMENT DE SEQUENCE',style = wx.ALIGN_CENTER)
self.label.SetBackgroundColour(wx.WHITE)
self.label.SetForegroundColour(wx.BLUE)
sizer.Add(self.label, (0,4),(1,2), wx.EXPAND )
#LABEL TEXT 1 : sequence soit introduite par l'utilisateur soit telecharger
self.label = wx.StaticText(self,2,label=u'SEQUENCE 1 !')
self.label.SetForegroundColour(wx.BLUE)
sizer.Add( self.label, (1,1),(1,1), wx.EXPAND )
#zone de text pour la premiere sequence
self.sequence1 = wx.TextCtrl(self,3,value=u"Telecharger la premiere sequence a aligner",size=wx.Size(350, -1))
sizer.Add(self.sequence1,(2,2),(1,1),wx.EXPAND)
self.sequence1.Bind(wx.EVT_LEFT_DCLICK, self.DblClickLeft1)
self.sequence1.Bind(wx.EVT_SET_FOCUS, self.SetFocus)
#self.sequence1.Bind(wx.EVT_TEXT,self.On_Text_Change )
#Bouton telecharger la sequence 1
button_lod_sq1 = wx.Button(self,4,label="Load Sequence1")
sizer.Add(button_lod_sq1, (2,5))
self.Bind(wx.EVT_BUTTON, self.OpenS1, button_lod_sq1)
#LABEL TEXT2
self.label = wx.StaticText(self,6,label=u'SEQUENCE 2 !')
self.label.SetForegroundColour(wx.BLUE)
sizer.Add(self.label, (3,1),(1,1), wx.EXPAND)
#zone de text pour la DEUXIEME sequence
self.sequence2 = wx.TextCtrl(self,7,value=u"Telecharger la deuxieme sequence a aligner",size=wx.Size(350, -1))
sizer.Add(self.sequence2,(4,2),(1,1),wx.EXPAND)
self.sequence2.Bind(wx.EVT_LEFT_DCLICK, self.DblClickLeft2)
#Bouton telecharger la sequence 2
button_lod_sq2 = wx.Button(self,8,label="Load Sequence2")
sizer.Add(button_lod_sq2, (4,5))
self.Bind(wx.EVT_BUTTON, self.Open, button_lod_sq2)
#Bouton ANALYSER les sequences
button_anlys = wx.Button(self,10,label="ANALYSER",style = wx.ALIGN_CENTER)
sizer.Add(button_anlys, (7,5))
#Ajuster le fenetre
sizer.AddGrowableCol(0)
self.SetSizerAndFit(sizer)
self.Show(True)
#*************************************************************************************************** **EVENENMENT**** ***************************
##GESTION DES EVENENENTS BOUTON__
def OpenS1(self,event):
""" Open a file"""
self.dirname = ''
dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.filename = dlg.GetFilename()
self.dirname = dlg.GetDirectory()
f = open(os.path.join(self.dirname, self.filename), 'r')
self.sequence1.SetValue(f.read())
f.close()
dlg.Destroy()
def Open(self,event):
""" Open a file"""
self.dirname = ''
dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.filename = dlg.GetFilename()
self.dirname = dlg.GetDirectory()
f = open(os.path.join(self.dirname, self.filename), 'r')
self.sequence2.SetValue(f.read())
f.close()
dlg.Destroy()
##GESTION DES EVENENENTS ZONE DE TEXT__
def focusFollowsMouse(event):
wx.MessageBox('BIENVENUE DANS ATTN Sequences Analysis Program','Hello')
def SetFocus(self,event):
wx.MessageBox('1/ Double click pour saisir la sequence\n2/ Clicker sur le bouton Load sequence\n Puis appuyez sur entree ', 'Pour analyser les sequences:')
def DblClickLeft1(self,event):
self.sequence1.Clear()
def DblClickLeft2(self,event):
self.sequence2.Clear()
#******************************************************************************************* ******AFFICHAGE *** ************************
# Chaque application wxWidgets doit avoir une classe dérivée de wx.App
class MainApp(wx.App):
def OnInit(self):
frame = Accueil(None,-1,'ATTN_SEQUENCES_ALIGN') #NOne:il n'a pas de parent, -1: id python, 'titre'
self.SetTopWindow(frame)
frame.Show(True)
return True
#creation de l' executable
if __name__ == '__main__':
app = MainApp(0) # créer une nouvelle instance de l'application
app.MainLoop() |
Partager