Exemple #1
0
    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))
Exemple #2
0
    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))