Procházet zdrojové kódy

wxGUI/lmgr: open simple Python editor from Python tab

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67975 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras před 9 roky
rodič
revize
0d6ae84512
1 změnil soubory, kde provedl 23 přidání a 3 odebrání
  1. 23 3
      gui/wxpython/lmgr/pyshell.py

+ 23 - 3
gui/wxpython/lmgr/pyshell.py

@@ -25,6 +25,8 @@ from wx.py.shell   import Shell as PyShell
 from wx.py.version import VERSION
 
 import grass.script as grass
+from grass.script.utils import try_remove
+
 from core.utils import _
 
 class PyShellWindow(wx.Panel):
@@ -48,7 +50,11 @@ class PyShellWindow(wx.Panel):
         self.btnClear = wx.Button(self, wx.ID_CLEAR)
         self.btnClear.Bind(wx.EVT_BUTTON, self.OnClear)
         self.btnClear.SetToolTipString(_("Delete all text from the shell"))
-                
+
+        self.btnSimpleEditor = wx.Button(self, id=wx.ID_ANY, label=_("Simple &editor"))
+        self.btnSimpleEditor.Bind(wx.EVT_BUTTON, self.OnSimpleEditor)
+        self.btnSimpleEditor.SetToolTipString(_("Open a simple Python code editor"))
+
         self._layout()
         
     def _displayhook(self, value):
@@ -61,10 +67,13 @@ class PyShellWindow(wx.Panel):
                   flag = wx.EXPAND)
         
         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+        btnSizer.Add(item=self.btnSimpleEditor, proportion=0,
+                     flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5)
+        btnSizer.AddStretchSpacer()
         btnSizer.Add(item = self.btnClear, proportion = 0,
-                     flag = wx.EXPAND | wx.RIGHT, border = 5)
+                     flag = wx.EXPAND | wx.ALIGN_RIGHT, border = 5)
         sizer.Add(item = btnSizer, proportion = 0,
-                  flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+                  flag = wx.ALIGN_RIGHT | wx.ALL | wx.EXPAND, border = 5)
         
         sizer.Fit(self)
         sizer.SetSizeHints(self)
@@ -114,3 +123,14 @@ class PyShellWindow(wx.Panel):
         self.shell.clear()
         self.shell.showIntro(self.intro)
         self.shell.prompt()
+
+    def OnSimpleEditor(self, event):
+        # import on demand
+        from gui_core.pyedit import PyEditFrame
+
+        # we don't keep track of them and we don't care about open files
+        # there when closing the main GUI
+        simpleEditor = PyEditFrame(parent=self, giface=self.giface)
+        simpleEditor.SetSize(self.parent.GetSize())
+        simpleEditor.CenterOnParent()
+        simpleEditor.Show()