From db5a9978f585f997ec3c714e66b5b554b0783986 Mon Sep 17 00:00:00 2001 From: Pierre Ratinaud Date: Fri, 24 Oct 2014 18:06:16 +0200 Subject: [PATCH] ... --- dialog.py | 19 ++++++++++++++++++- guifunct.py | 19 ++++++++++++++++++- layout.py | 48 ++++++++++++++++++++++++++++++++++++------------ listlex.py | 3 ++- tabsimi.py | 2 +- tabsplitvar.py | 2 +- tree.py | 1 + 7 files changed, 77 insertions(+), 17 deletions(-) diff --git a/dialog.py b/dialog.py index 64b993a..ac022b2 100755 --- a/dialog.py +++ b/dialog.py @@ -1852,6 +1852,21 @@ class PrefDendro ( wx.Dialog ): self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 ) + + self.text_format_image = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) + self.text_format_image.Wrap( -1 ) + fgSizer1.Add( self.text_format_image, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + + self.choice_format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['png', 'svg'], 0 ) + self.choice_format.SetSelection( 0 ) + fgSizer1.Add( self.choice_format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 ) + + self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline31, 0, wx.EXPAND |wx.ALL, 5 ) + + self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 ) + self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText5.Wrap( -1 ) @@ -1916,6 +1931,7 @@ class PrefDendro ( wx.Dialog ): self.m_radioBox1.SetSelection(self.param['color_nb']) self.m_checkBox1.SetValue(self.param['taille_classe']) self.m_radioBox2.SetSelection(self.param['type_tclasse']) + self.choice_format.SetSelection(self.param['svg']) def __del__( self ): pass @@ -2571,7 +2587,7 @@ class message(wx.Frame): self.uceids = uceids self.ira = wx.GetApp().GetTopWindow() self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) - + self.items = items self.html = "" #self.HtmlPage=wx.html.HtmlWindow(self, -1) self.HtmlPage = ConcordList(self, items) @@ -2615,6 +2631,7 @@ class message(wx.Frame): ) dlg.SetFilterIndex(2) dlg.CenterOnParent() + self.html = '
'.join([self.items[i] for i in range(0,len(self.items))]) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() with open(path, 'w') as f : diff --git a/guifunct.py b/guifunct.py index 2dcc3da..1641795 100644 --- a/guifunct.py +++ b/guifunct.py @@ -169,7 +169,16 @@ class PrefSimi ( wx.Dialog ): if wordlist is not None : self.listcol = ListForSpec(self, self, wordlist, ['eff']) self.listcol.SetMinSize( wx.Size( 270,-1 ) ) - bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 ) + listsizer = wx.BoxSizer( wx.VERTICAL ) + countsizer = wx.BoxSizer( wx.HORIZONTAL ) + self.butcount = wx.Button(self, -1, "count") + self.textcount = wx.TextCtrl(self, -1, "", wx.DefaultPosition, wx.Size( 100,-1 ), wx.TE_READONLY ) + countsizer.Add(self.butcount, 0, wx.ALL, 5) + countsizer.Add(self.textcount, 0, wx.ALL, 5 ) + listsizer.Add(countsizer, 0, wx.ALL, 5) + listsizer.Add(self.listcol, 2, wx.ALL|wx.EXPAND, 5 ) + #bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 ) + bSizer16.Add( listsizer, 0, wx.ALL|wx.EXPAND, 5) if selected is None : for row in xrange(self.listcol.GetItemCount()): self.listcol.Select(row) @@ -725,6 +734,11 @@ class PrefSimi ( wx.Dialog ): self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki ) self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex ) self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size ) + self.listcol.Bind( wx.EVT_LIST_ITEM_SELECTED, self.ChangeCount) + self.listcol.Bind( wx.EVT_LIST_ITEM_DESELECTED, self.ChangeCount) + self.butcount.Bind( wx.EVT_BUTTON, self.ChangeCount) + self.ChangeCount(wx.EVT_BUTTON) + def __set_properties(self): self.choice1.SetSelection(self.paramsimi['coeff']) @@ -772,6 +786,9 @@ class PrefSimi ( wx.Dialog ): self.comcheck.SetValue(self.paramsimi['com']) self.choix_com.SetSelection(self.paramsimi['communities']) self.halo.SetValue(self.paramsimi['halo']) + + def ChangeCount(self, evt) : + self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount()) def OnCheck_s_size(self, evt): if self.check_s_size.GetValue() : diff --git a/layout.py b/layout.py index 7014f3a..0e41fe4 100644 --- a/layout.py +++ b/layout.py @@ -164,7 +164,10 @@ class GraphPanelAfc(wx.Panel): else : svg = 1 typegraph = dial.choicetype.GetSelection() - typefile = '.png' + if svg : + typefile = '.svg' + else : + typefile = '.png' if self.clnb <= 3 and typegraph == 1 : typegraph = 2 if typegraph == 2: @@ -658,8 +661,12 @@ class TgenLayout : ira = wx.GetApp().GetTopWindow() self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t") tgentab = False + gparent = None for i in range(page.GetPageCount()) : tab = page.GetPage(i) + if 'gparent' in dir(tab) : + if tab.gparent is not None : + gparent = tab.gparent if 'tgen' in dir(tab) : if tab.tgen : tgentab = tab @@ -668,7 +675,7 @@ class TgenLayout : self.page.tgentab.RefreshData(self.page.tgens) self.page.SetSelection(i) else : - self.page.tgentab = ListForSpec(ira, None, self.page.tgens, etoiles[1:]) + self.page.tgentab = ListForSpec(ira, gparent, self.page.tgens, etoiles[1:]) self.page.tgentab.tgen = True self.page.AddPage(self.page.tgentab, u'Tgens Specificities') self.page.SetSelection(self.page.GetPageCount() - 1) @@ -705,7 +712,7 @@ class dolexlayout : self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles) self.ListPanEffType = ListForSpec(ira, self, self.DictEffType, self.etoiles) self.ListPanEffRelForme = ListForSpec(ira, self, self.DictEffRelForme, self.etoiles) - self.ListPanEffRelType = ListForSpec(ira, self.parent, self.DictEffRelType, self.etoiles) + self.ListPanEffRelType = ListForSpec(ira, self, self.DictEffRelType, self.etoiles) self.TabStat.AddPage(self.ListPan, u'formes') if os.path.exists(self.pathout['banalites.csv']) : @@ -800,7 +807,11 @@ class GraphPanelDendro(wx.Panel): for i in range(0,len(list_graph)): if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) : - self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) + filename, ext = os.path.splitext(list_graph[i][0]) + if ext == '.svg' : + self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0]))) + else : + self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY))) self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1])) self.__set_properties() @@ -819,7 +830,8 @@ class GraphPanelDendro(wx.Panel): 'type_dendro': 0, 'color_nb': 0, 'taille_classe' : True, - 'type_tclasse' : 0 + 'type_tclasse' : 0, + 'svg' : 0 } self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ] @@ -847,11 +859,16 @@ class GraphPanelDendro(wx.Panel): self.param['color_nb'] = dial.m_radioBox1.GetSelection() self.param['taille_classe'] = dial.m_checkBox1.GetValue() self.param['type_tclasse'] = dial.m_radioBox2.GetSelection() + self.param['svg'] = dial.choice_format.GetSelection() def make_dendro(self, dendro = 'simple') : - while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+'.png')) : + if self.param['svg'] : + typefile = '.svg' + else : + typefile = '.png' + while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+typefile)) : self.graphnb += 1 - fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+'.png')) + fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+typefile)) width = self.param['width'] height = self.param['height'] type_dendro = self.type_dendro[self.param['type_dendro']] @@ -867,6 +884,10 @@ class GraphPanelDendro(wx.Panel): histo='FALSE' else : histo = 'TRUE' + if self.param['svg'] : + svg = 'TRUE' + else : + svg = 'FALSE' dendro_path = self.dictpathout['Rdendro'] classe_path = self.dictpathout['uce'] txt = """ @@ -886,17 +907,17 @@ class GraphPanelDendro(wx.Panel): load("%s") source("%s") chistable <- chistabletot[1:(debsup-1),] - open_file_graph("%s", width=%i, height=%i) + open_file_graph("%s", width=%i, height=%i, svg = %s) plot.dendro.prof(tree.cut1$tree.cl, classes, chistable, nbbycl = 60, type.dendro="%s", bw=%s, lab=NULL) - """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw) + """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw) elif dendro == 'cloud' : txt += """ load("%s") source("%s") chistable <- chistabletot[1:(debsup-1),] - open_file_graph("%s", width=%i, height=%i) + open_file_graph("%s", width=%i, height=%i, svg=%s) plot.dendro.cloud(tree.cut1$tree.cl, classes, chistable, nbbycl = 300, type.dendro="%s", bw=%s, lab=NULL) - """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw) + """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw) tmpfile = tempfile.mktemp() @@ -906,7 +927,10 @@ class GraphPanelDendro(wx.Panel): check_Rresult(self.ira, error) self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro]) print_liste(self.dictpathout['liste_graph_chd'], self.list_graph) - self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + if self.param['svg'] : + self.sizer_3.Add(hl.HyperLinkCtrl(self.panel_1, -1, fileout, URL=fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) + else : + self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) self.sizer_3.Fit(self.panel_1) self.Layout() diff --git a/listlex.py b/listlex.py index 9244869..ef36372 100644 --- a/listlex.py +++ b/listlex.py @@ -207,7 +207,8 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor self.Bind(wx.EVT_MENU, self.onstcaract, id = nid) menu.AppendMenu(-1, u"Segments de texte caractéristiques", menu_stcaract) #menu.Append(self.popup_Tgen_glob, "Tgen global") - menu.Append(self.onmaketgen, "Make Tgen") + if not self.tgen : + menu.Append(self.onmaketgen, "Make Tgen") self.PopupMenu(menu) menu.Destroy() diff --git a/tabsimi.py b/tabsimi.py index 8b7c070..700999d 100644 --- a/tabsimi.py +++ b/tabsimi.py @@ -101,7 +101,7 @@ class DoSimi(AnalyseMatrix): res = wx.ID_OK if res == wx.ID_OK : if not self.actives : - self.tableau.selected_col = dialcol.list_box_1.GetSelections() + self.tableau.selected_col = dialcol.m_listBox1.GetSelections() actives = self.tableau.getactlistfromselection(self.tableau.selected_col) else : actives = self.actives diff --git a/tabsplitvar.py b/tabsplitvar.py index f3e4513..4deea43 100644 --- a/tabsplitvar.py +++ b/tabsplitvar.py @@ -23,7 +23,7 @@ class SplitMatrixFromVar(AnalyseMatrix): dial.CenterOnParent() val = dial.ShowModal() if val == wx.ID_OK : - self.parametres['colsel'] = dial.list_box_1.GetSelections() + self.parametres['colsel'] = dial.m_listBox1.GetSelections() self.parametres['header'] = dial.header else : self.parametres = None diff --git a/tree.py b/tree.py index 708e0dc..aa4d00d 100644 --- a/tree.py +++ b/tree.py @@ -125,6 +125,7 @@ class LeftTree(CT.CustomTreeCtrl): self.ild['chi2'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'chi2.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) self.ild['reinertmatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'reinertmatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) self.ild['simimatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simimatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) + self.ild['proto'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'proto.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap()) self.SetImageList(self.il) self.count = 0 -- 2.7.4