浏览代码

wxGUI: SetOpacityDialog cosmetics (missing title)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32486 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 年之前
父节点
当前提交
7e09d1bb5d
共有 3 个文件被更改,包括 33 次插入15 次删除
  1. 27 14
      gui/wxpython/gui_modules/gdialogs.py
  2. 4 0
      gui/wxpython/gui_modules/render.py
  3. 2 1
      gui/wxpython/gui_modules/wxgui_utils.py

+ 27 - 14
gui/wxpython/gui_modules/gdialogs.py

@@ -11,7 +11,8 @@ List of classes:
  - LoadMapLayersDialog
  - LoadMapLayersDialog
  - ImportDxfDialog
  - ImportDxfDialog
  - LayerList (used by ImportDxfMulti) 
  - LayerList (used by ImportDxfMulti) 
- 
+ - SetOpacityDialog
+
 (C) 2008 by the GRASS Development Team
 (C) 2008 by the GRASS Development Team
 
 
 This program is free software under the GNU General Public
 This program is free software under the GNU General Public
@@ -945,52 +946,64 @@ class LayersList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin,
 
 
 class SetOpacityDialog(wx.Dialog):
 class SetOpacityDialog(wx.Dialog):
     """Set opacity of map layers"""
     """Set opacity of map layers"""
-    def __init__(self, parent, id=wx.ID_ANY, title=_("Set Opacity (100=opaque, 0=transparent"),
+    def __init__(self, parent, id=wx.ID_ANY, title=_("Set Map Layer Opacity"),
                  size=wx.DefaultSize, pos=wx.DefaultPosition,
                  size=wx.DefaultSize, pos=wx.DefaultPosition,
                  style=wx.DEFAULT_DIALOG_STYLE, opacity=100):
                  style=wx.DEFAULT_DIALOG_STYLE, opacity=100):
 
 
         self.parent = parent # GMFrame
         self.parent = parent # GMFrame
-        super(SetOpacityDialog, self).__init__(parent, id=id, pos=pos, size=size, style=style)
+        super(SetOpacityDialog, self).__init__(parent, id=id, pos=pos,
+                                               size=size, style=style, title=title)
 
 
         self.panel = wx.Panel(parent=self, id=wx.ID_ANY)
         self.panel = wx.Panel(parent=self, id=wx.ID_ANY)
 
 
-        self.opacity = opacity    # current opacity
+        self.opacity = opacity  # current opacity
         self.parent  = parent  # MapFrame
         self.parent  = parent  # MapFrame
 
 
         sizer = wx.BoxSizer(wx.VERTICAL)
         sizer = wx.BoxSizer(wx.VERTICAL)
 
 
         box = wx.BoxSizer(wx.HORIZONTAL)
         box = wx.BoxSizer(wx.HORIZONTAL)
-        self.spin = wx.SpinCtrl(self, id=wx.ID_ANY, value="",
+        self.spin = wx.SpinCtrl(self.panel, id=wx.ID_ANY, value="",
                                style=wx.SP_ARROW_KEYS, initial=100, min=0, max=100,
                                style=wx.SP_ARROW_KEYS, initial=100, min=0, max=100,
                                name='spinCtrl')
                                name='spinCtrl')
         
         
         #self.Bind(wx.EVT_SPINCTRL, self.OnOpacity, self.spin)
         #self.Bind(wx.EVT_SPINCTRL, self.OnOpacity, self.spin)
         self.spin.SetValue(self.opacity)
         self.spin.SetValue(self.opacity)
-        box.Add(item=self.spin, proportion=0,
-                flag=wx.ALIGN_CENTRE|wx.ALL, border=5)
+        
+        box.Add(item=wx.StaticText(parent=self.panel, id=wx.ID_ANY,
+                                   label=_("Set opacity (100=opaque, 0=transparent):")),
+                proportion=0,
+                flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5)
+        box.Add(item=self.spin, proportion=1,
+                flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5)
+
         sizer.Add(item=box, proportion=0,
         sizer.Add(item=box, proportion=0,
-                  flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
+                  flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
 
 
-        line = wx.StaticLine(parent=self, id=wx.ID_ANY, size=(20,-1), style=wx.LI_HORIZONTAL)
+        line = wx.StaticLine(parent=self.panel, id=wx.ID_ANY,
+                             size=(20,-1), style=wx.LI_HORIZONTAL)
         sizer.Add(item=line, proportion=0,
         sizer.Add(item=line, proportion=0,
-                  flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
+                  flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
 
 
         # buttons
         # buttons
         btnsizer = wx.StdDialogButtonSizer()
         btnsizer = wx.StdDialogButtonSizer()
 
 
-        self.btnOK = wx.Button(parent=self, id=wx.ID_OK)
+        self.btnOK = wx.Button(parent=self.panel, id=wx.ID_OK)
         self.btnOK.SetDefault()
         self.btnOK.SetDefault()
         btnsizer.AddButton(self.btnOK)
         btnsizer.AddButton(self.btnOK)
 
 
-        btnCancel = wx.Button(parent=self, id=wx.ID_CANCEL)
+        btnCancel = wx.Button(parent=self.panel, id=wx.ID_CANCEL)
         btnsizer.AddButton(btnCancel)
         btnsizer.AddButton(btnCancel)
         btnsizer.Realize()
         btnsizer.Realize()
 
 
         sizer.Add(item=btnsizer, proportion=0,
         sizer.Add(item=btnsizer, proportion=0,
                   flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
                   flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
 
 
-        self.SetSizer(sizer)
-        sizer.Fit(self)
+        self.panel.SetSizer(sizer)
+        sizer.Fit(self.panel)
+
+        self.SetSize(self.GetBestSize())
+
+        self.Layout()
 
 
     def GetOpacity(self):
     def GetOpacity(self):
         """Button 'OK' pressed"""
         """Button 'OK' pressed"""

+ 4 - 0
gui/wxpython/gui_modules/render.py

@@ -189,6 +189,10 @@ class Layer(object):
         
         
         return int (self.opacity * 100)
         return int (self.opacity * 100)
 
 
+    def GetName(self):
+        """Get map layer name"""
+        return self.name
+    
     def IsActive(self):
     def IsActive(self):
         """Check if layer is activated for rendering"""
         """Check if layer is activated for rendering"""
         return self.active
         return self.active

+ 2 - 1
gui/wxpython/gui_modules/wxgui_utils.py

@@ -461,7 +461,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         maplayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         current_opacity = maplayer.GetOpacity()
         current_opacity = maplayer.GetOpacity()
         
         
-        dlg = gdialogs.SetOpacityDialog(self, opacity=current_opacity)
+        dlg = gdialogs.SetOpacityDialog(self, opacity=current_opacity,
+                                        title=_("Set opacity <%s>") % maplayer.GetName())
 
 
         if dlg.ShowModal() == wx.ID_OK:
         if dlg.ShowModal() == wx.ID_OK:
             new_opacity = dlg.GetOpacity() # string            
             new_opacity = dlg.GetOpacity() # string