[GRASS-SVN] r36505 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 28 12:59:18 EDT 2009


Author: cmbarton
Date: 2009-03-28 12:59:17 -0400 (Sat, 28 Mar 2009)
New Revision: 36505

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
Log:
Make text entry box for text overlays expandable so that large text is still visible.

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2009-03-28 14:57:16 UTC (rev 36504)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2009-03-28 16:59:17 UTC (rev 36505)
@@ -451,6 +451,7 @@
                  pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE):
 
         wx.Dialog.__init__(self, parent, wx.ID_ANY, title, pos, size, style)
+        from wx.lib.expando import ExpandoTextCtrl, EVT_ETC_LAYOUT_NEEDED
 
         self.ovlId = ovlId
         self.parent = parent
@@ -468,7 +469,7 @@
             self.currRot = 0.0
             self.currCoords = [10, 10, 10, 10]
 
-        sizer = wx.BoxSizer(wx.VERTICAL)
+        self.sizer = wx.BoxSizer(wx.VERTICAL)
         box = wx.GridBagSizer(vgap=5, hgap=5)
 
         # show/hide
@@ -488,10 +489,13 @@
                 flag=wx.ALIGN_CENTER_VERTICAL,
                 pos=(1, 0))
 
-        self.textentry = wx.TextCtrl(parent=self, id=wx.ID_ANY, value="", size=(300,-1))
+        self.textentry = ExpandoTextCtrl(parent=self, id=wx.ID_ANY, value="", size=(300,-1))
         self.textentry.SetFont(self.currFont)
         self.textentry.SetForegroundColour(self.currClr)
         self.textentry.SetValue(self.currText)
+        # get rid of unneeded scrollbar when text box first opened
+        self.textentry.SetClientSize((300,-1))
+        
         box.Add(item=self.textentry,
                 pos=(1, 1))
 
@@ -514,7 +518,7 @@
                 flag=wx.ALIGN_RIGHT,
                 pos=(3, 1))
 
-        sizer.Add(item=box, proportion=1,
+        self.sizer.Add(item=box, proportion=1,
                   flag=wx.ALL, border=10)
 
         # note
@@ -524,12 +528,12 @@
                                       "to position.\nDouble-click to change options"))
         box.Add(item=label, proportion=0,
                 flag=wx.ALIGN_CENTRE | wx.ALL, border=5)
-        sizer.Add(item=box, proportion=0,
+        self.sizer.Add(item=box, proportion=0,
                   flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER | wx.ALL, border=5)
 
         line = wx.StaticLine(parent=self, id=wx.ID_ANY,
                              size=(20,-1), style=wx.LI_HORIZONTAL)
-        sizer.Add(item=line, proportion=0,
+        self.sizer.Add(item=line, proportion=0,
                   flag=wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border=5)
 
         btnsizer = wx.StdDialogButtonSizer()
@@ -542,17 +546,22 @@
         btnsizer.AddButton(btn)
         btnsizer.Realize()
 
-        sizer.Add(item=btnsizer, proportion=0,
+        self.sizer.Add(item=btnsizer, proportion=0,
                   flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
 
-        self.SetSizer(sizer)
-        sizer.Fit(self)
+        self.SetSizer(self.sizer)
+        self.sizer.Fit(self)
 
         # bindings
+        self.Bind(EVT_ETC_LAYOUT_NEEDED, self.OnRefit, self.textentry)
         self.Bind(wx.EVT_BUTTON,     self.OnSelectFont, fontbtn)
         self.Bind(wx.EVT_TEXT,       self.OnText,       self.textentry)
         self.Bind(wx.EVT_SPINCTRL,   self.OnRotation,   self.rotation)
 
+    def OnRefit(self, event):
+        """Resize text entry to match text"""
+        self.sizer.Fit(self)
+
     def OnText(self, event):
         """Change text string"""
         self.currText = event.GetString()



More information about the grass-commit mailing list