def __init__( self, parent, id=wx.ID_ANY, title="GConsole Test Frame", style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, **kwargs, ): wx.Frame.__init__(self, parent=parent, id=id, title=title, style=style) panel = wx.Panel(self, id=wx.ID_ANY) from lmgr.menudata import LayerManagerMenuData menuTreeBuilder = LayerManagerMenuData() self.gconsole = GConsole(guiparent=self) self.goutput = GConsoleWindow( parent=panel, gconsole=self.gconsole, menuModel=menuTreeBuilder.GetModel(), gcstyle=GC_PROMPT, ) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.goutput, proportion=1, flag=wx.EXPAND, border=0) panel.SetSizer(mainSizer) mainSizer.Fit(panel) self.SetMinSize((550, 500))
def main(argv=None): if argv is None: argv = sys.argv if len(argv) > 1 and argv[1] == "-d": printDiff = True else: printDiff = False if len(argv) > 1 and argv[1] == "-h": print(sys.stderr, __doc__, file=sys.stderr) return 1 nuldev = open(os.devnull, "w+") grass.info("Step 1: running make...") grass.call(["make"], stderr=nuldev) grass.info("Step 2: parsing modules...") modules = dict() modules = parseModules() grass.info("Step 3: reading menu data...") data = LayerManagerMenuData() grass.info("Step 4: updating menu data...") updateData(data, modules) if printDiff: tempFile = tempfile.NamedTemporaryFile() grass.info("Step 5: diff menu data...") writeData(data, tempFile.name) grass.call( ["diff", "-u", os.path.join("xml", "menudata.xml"), tempFile.name], stderr=nuldev, ) else: grass.info("Step 5: writing menu data (menudata.xml)...") writeData(data) return 0
def main(argv=None): if argv is None: argv = sys.argv if len(argv) > 1 and argv[1] == '-d': printDiff = True else: printDiff = False if len(argv) > 1 and argv[1] == '-h': print(sys.stderr, __doc__, file=sys.stderr) return 1 nuldev = file(os.devnull, 'w+') grass.info("Step 1: running make...") grass.call(['make'], stderr=nuldev) grass.info("Step 2: parsing modules...") modules = dict() modules = parseModules() grass.info("Step 3: reading menu data...") data = LayerManagerMenuData() grass.info("Step 4: updating menu data...") updateData(data, modules) if printDiff: tempFile = tempfile.NamedTemporaryFile() grass.info("Step 5: diff menu data...") writeData(data, tempFile.name) grass.call(['diff', '-u', os.path.join('xml', 'menudata.xml'), tempFile.name], stderr=nuldev) else: grass.info("Step 5: writing menu data (menudata.xml)...") writeData(data) return 0
action = 'strings' menu = 'manager' for arg in sys.argv: if arg in ('strings', 'tree', 'commands', 'dump'): action = arg elif arg in ('manager', 'module_tree', 'modeler', 'psmap'): menu = arg # FIXME: cross-dependencies if menu == 'manager': from lmgr.menudata import LayerManagerMenuData from core.globalvar import WXGUIDIR filename = os.path.join(WXGUIDIR, 'xml', 'menudata.xml') menudata = LayerManagerMenuData(filename) # FIXME: since module descriptions are used again we have now the third # copy of the same string (one is in modules) elif menu == 'module_tree': from lmgr.menudata import LayerManagerModuleTree from core.globalvar import WXGUIDIR filename = os.path.join(WXGUIDIR, 'xml', 'module_tree_menudata.xml') menudata = LayerManagerModuleTree(filename) elif menu == 'modeler': from gmodeler.menudata import ModelerMenuData menudata = ModelerMenuData() elif menu == 'psmap': from psmap.menudata import PsMapMenuData menudata = PsMapMenuData() else: import grass.script.core as gscore
def __init__(self, parent, title=_("Add GRASS command to the model"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs): """Graphical modeler module search window :param parent: parent window :param id: window id :param title: window title :param kwargs: wx.Dialogs' arguments """ self.parent = parent wx.Dialog.__init__( self, parent=parent, id=wx.ID_ANY, title=title, **kwargs) self.SetName("ModelerDialog") self.SetIcon( wx.Icon( os.path.join( globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self._command = None self.panel = wx.Panel(parent=self, id=wx.ID_ANY) self.cmdBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Command")) self.labelBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Label and comment")) # menu data for search widget and prompt menuModel = LayerManagerMenuData() self.cmd_prompt = GPromptSTC( parent=self, menuModel=menuModel.GetModel()) self.cmd_prompt.promptRunCmd.connect(self.OnCommand) self.cmd_prompt.commandSelected.connect( lambda command: self.label.SetValue(command)) self.search = SearchModuleWidget(parent=self.panel, model=menuModel.GetModel(), showTip=True) self.search.moduleSelected.connect( lambda name: self.cmd_prompt.SetTextAndFocus(name + ' ')) wx.CallAfter(self.cmd_prompt.SetFocus) self.label = TextCtrl(parent=self.panel, id=wx.ID_ANY) self.comment = TextCtrl( parent=self.panel, id=wx.ID_ANY, style=wx.TE_MULTILINE) self.btnCancel = Button(self.panel, wx.ID_CANCEL) self.btnOk = Button(self.panel, wx.ID_OK) self.btnOk.SetDefault() self.Bind(wx.EVT_BUTTON, self.OnOk, self.btnOk) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.btnCancel) self._layout() self.SetSize((500, -1))