layout
[iramuteq] / listlex.py
index 2237fcc..9ead606 100644 (file)
@@ -21,7 +21,7 @@ import tempfile
 from functions import exec_rcode, MessageImage
 from chemins import ffr
 from PrintRScript import barplot
-from dialog import SearchDial
+from dialog import SearchDial, message
 #---------------------------------------------------------------------------
 
 #class List(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
@@ -31,12 +31,13 @@ from dialog import SearchDial
 #        listmix.ListCtrlAutoWidthMixin.__init__(self)
 
 class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
-    def __init__(self, parent,gparent, dlist,first):
+    def __init__(self, parent,gparent, dlist, first, menu = True):
         wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
         self.parent=parent
         self.gparent=gparent
         self.dlist=dlist
         self.first = first
+        self.menu = menu
 
         search_id = wx.NewId()
         self.parent.Bind(wx.EVT_MENU, self.onsearch, id = search_id)
@@ -67,7 +68,7 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
         self.SetColumnWidth(0, 180)
 
         for i in range(1,len(first)-1):
-            self.SetColumnWidth(i, len(first[i]) * 10)
+            self.SetColumnWidth(i, self.checkcolumnwidth(len(first[i]) * 10))
         
         self.itemDataMap = dlist
         self.itemIndexMap = dlist.keys()
@@ -88,6 +89,12 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
 
 #-----------------------------------------------------------------------------------------    
         
+    def checkcolumnwidth(self, width) :
+        if width < 80 :
+            return 80
+        else :
+            return width
+
     def OnGetItemText(self, item, col):
         index=self.itemIndexMap[item]
         s = self.itemDataMap[index][col]
@@ -145,28 +152,28 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
         self.dial.Destroy()
     
     def OnRightClick(self, event):
-
-        # only do this part the first time so the events are only bound once
-        if not hasattr(self, "popupID1"):
-            self.popupID1 = wx.NewId()
-            self.popupID2 = wx.NewId()
-            self.popupID3 = wx.NewId()
-            self.popup_Tgen_glob = wx.NewId()
-
-            self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
-            self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
-            self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
-            self.Bind(wx.EVT_MENU, self.OnTgen_glob, id=self.popup_Tgen_glob)
-        # make a menu
-        menu = wx.Menu()
-        # add some items
-        menu.Append(self.popupID1, u"Formes associées")
-        menu.Append(self.popupID2, u"Concordancier")
-        menu.Append(self.popupID3, "Graphique")
-        #menu.Append(self.popup_Tgen_glob, "Tgen global")
-
-        self.PopupMenu(menu)
-        menu.Destroy()
+        if self.menu :
+            # only do this part the first time so the events are only bound once
+            if not hasattr(self, "popupID1"):
+                self.popupID1 = wx.NewId()
+                self.popupID2 = wx.NewId()
+                self.popupID3 = wx.NewId()
+                self.popup_Tgen_glob = wx.NewId()
+
+                self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
+                self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
+                self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
+                self.Bind(wx.EVT_MENU, self.OnTgen_glob, id=self.popup_Tgen_glob)
+            # make a menu
+            menu = wx.Menu()
+            # add some items
+            menu.Append(self.popupID1, u"Formes associées")
+            menu.Append(self.popupID2, u"Concordancier")
+            menu.Append(self.popupID3, "Graphique")
+            #menu.Append(self.popup_Tgen_glob, "Tgen global")
+
+            self.PopupMenu(menu)
+            menu.Destroy()
 
     def getselectedwords(self) :
         words = [self.getColumnText(self.GetFirstSelected(), 0)]
@@ -185,7 +192,7 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
         rep = []
         for forme in lems[word].formes :
              rep.append([corpus.getforme(forme).forme, corpus.getforme(forme).freq])
-        win = message(self, -1, u"Formes associées", size=(300, 200), style=wx.DEFAULT_FRAME_STYLE)
+        win = message(self, u"Formes associées", (300, 200))
         win.html = '<html>\n' + '<br>'.join([' : '.join([str(val) for val in forme]) for forme in rep]) + '\n</html>'
         win.HtmlPage.SetPage(win.html)
         win.Show(True)
@@ -195,7 +202,7 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
         page = self.parent.nb.GetPage(activenotebook)
         item=self.getColumnText(self.GetFirstSelected(), 0)
         corpus = page.corpus
-        win = message(self, -1, u"Concordancier", size=(600, 200),style = wx.DEFAULT_FRAME_STYLE)
+        win = message(self, u"Concordancier", (750, 600))
         avap=60
         listmot = corpus.getlems()[item].formes       
         uce_ok = corpus.getlemuces(item)
@@ -277,38 +284,38 @@ class ListForSpec(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSor
 
 
 
-class message(wx.Frame):
-    def __init__(self, *args, **kwds):
-        # begin wxGlade: MyFrame.__init__
-        kwds["style"] = wx.DEFAULT_FRAME_STYLE
-        wx.Frame.__init__(self, *args, **kwds)
-        #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
-        self.HtmlPage=wx.html.HtmlWindow(self, -1)
-        if "gtk2" in wx.PlatformInfo:
-            self.HtmlPage.SetStandardFonts()
-        self.HtmlPage.SetFonts('Courier','Courier')
-        
-        
-        self.button_1 = wx.Button(self, -1, "Fermer")
-        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
-        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
-        self.__do_layout()
-        # end wxGlade
-
-    def __do_layout(self):
-        # begin wxGlade: MyFrame.__do_layout
-        sizer_1 = wx.BoxSizer(wx.VERTICAL)
-        sizer_2 = wx.BoxSizer(wx.VERTICAL)
-        sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
-        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
-        self.SetAutoLayout(True)
-        self.SetSizer(sizer_1)
-        self.Layout()
-        # end wxGlade
-        
-    def OnCloseMe(self, event):
-        self.Close(True)
-
-    def OnCloseWindow(self, event):
-        self.Destroy()
+#class message(wx.Frame):
+#    def __init__(self, *args, **kwds):
+#        # begin wxGlade: MyFrame.__init__
+#        kwds["style"] = wx.DEFAULT_FRAME_STYLE
+#        wx.Frame.__init__(self, *args, **kwds)
+#        #self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
+#        self.HtmlPage=wx.html.HtmlWindow(self, -1)
+#        if "gtk2" in wx.PlatformInfo:
+#            self.HtmlPage.SetStandardFonts()
+#        self.HtmlPage.SetFonts('Courier','Courier')
+#        
+#        
+#        self.button_1 = wx.Button(self, -1, "Fermer")
+#        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
+#        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+#        self.__do_layout()
+#        # end wxGlade
+#
+#    def __do_layout(self):
+#        # begin wxGlade: MyFrame.__do_layout
+#        sizer_1 = wx.BoxSizer(wx.VERTICAL)
+#        sizer_2 = wx.BoxSizer(wx.VERTICAL)
+#        sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+#        sizer_2.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
+#        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
+#        self.SetAutoLayout(True)
+#        self.SetSizer(sizer_1)
+#        self.Layout()
+#        # end wxGlade
+#        
+#    def OnCloseMe(self, event):
+#        self.Close(True)
+#
+#    def OnCloseWindow(self, event):
+#        self.Destroy()