def __init__(self, parent, shape, id=wx.ID_ANY, title=_("If-else properties"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs): ModelItemDialog.__init__(self, parent, shape, title, style=style, **kwargs) self.listBoxIf = StaticBox( parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of items in 'if' block")) self.itemListIf = self.itemList self.itemListIf.SetName('IfBlockList') self.listBoxElse = StaticBox( parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of items in 'else' block")) self.itemListElse = ItemCheckListCtrl(parent=self.panel, columns=[_("Label"), _("Command")], shape=shape, frame=parent) self.itemListElse.SetName('ElseBlockList') self.itemListElse.Populate(self.parent.GetModel().GetItems()) self._layout() self.SetMinSize(self.GetSize()) self.SetSize((500, 400))
def __init__(self, parent, shape, id=wx.ID_ANY, title=_("Loop properties"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs): ModelItemDialog.__init__(self, parent, shape, title, style=style, **kwargs) self.listBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of items in loop")) self.btnSeries = Button(parent=self.panel, id=wx.ID_ANY, label=_("Series")) self.btnSeries.SetToolTip( _("Define map series as condition for the loop")) self.btnSeries.Bind(wx.EVT_BUTTON, self.OnSeries) self._layout() self.SetMinSize(self.GetSize()) self.SetSize((500, 400))
def _createCategoryPanel(self, parent): self.catsPanel = wx.Panel(parent=parent) self.cats_list = CategoryListCtrl( parent=self.catsPanel, cats_mgr=self.scatt_mgr.GetCategoriesManager(), sel_cats_in_iscatt=self._selCatInIScatt()) self.catsPanel.SetMinSize((-1, 100)) self.catsPanel.SetInitialSize((-1, 150)) box_capt = StaticBox( parent=self.catsPanel, id=wx.ID_ANY, label=' %s ' % _("Classes"), ) catsSizer = wx.StaticBoxSizer(box_capt, wx.VERTICAL) self.toolbars['categoryToolbar'] = self._createCategoryToolbar( self.catsPanel) catsSizer.Add(self.cats_list, proportion=1, flag=wx.EXPAND | wx.TOP, border=5) if self.toolbars['categoryToolbar']: catsSizer.Add(self.toolbars['categoryToolbar'], proportion=0) self.catsPanel.SetSizer(catsSizer)
def __init__(self, parent, shape, title, id=wx.ID_ANY, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs): self.parent = parent self.shape = shape wx.Dialog.__init__( self, parent, id, title=title, style=style, **kwargs) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) self.condBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Condition")) self.condText = TextCtrl(parent=self.panel, id=wx.ID_ANY, value=shape.GetLabel()) self.itemList = ItemCheckListCtrl(parent=self.panel, columns=[_("Label"), _("Command")], shape=shape, frame=parent) self.itemList.Populate(self.parent.GetModel().GetItems()) self.btnCancel = Button(parent=self.panel, id=wx.ID_CANCEL) self.btnOk = Button(parent=self.panel, id=wx.ID_OK) self.btnOk.SetDefault()
def __init__(self, parent, conf, giface=None, id=wx.ID_ANY, title=_("Modify the configuration file"), style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs): # VARIABLES self.parent = parent self.rlipath = retRLiPath() self.confile = conf self.pathfile = os.path.join(self.rlipath, conf) wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs) self.SetIcon(wx.Icon(os.path.join(globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) self.confilesBox = StaticBox( parent=self.panel, id=wx.ID_ANY, label=_( "View and modify the " "configuration file '{name}'".format( name=self.confile))) self.textCtrl = TextCtrl(parent=self.panel, id=wx.ID_ANY, style=wx.TE_MULTILINE, size=(-1, 75)) self.textCtrl.Bind(wx.EVT_TEXT, self.OnFileText) f = open(self.pathfile) self.textCtrl.SetValue(''.join(f.readlines())) f.close() # BUTTONS #definition self.btn_close = Button(parent=self, id=wx.ID_EXIT) self.btn_ok = Button(parent=self, id=wx.ID_SAVE) self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) self._layout() self.enc = locale.getdefaultlocale()[1]
def __init__( self, parent, id=wx.ID_ANY, title=_("Model properties"), size=(350, 400), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, ): wx.Dialog.__init__(self, parent, id, title, size=size, style=style) self.metaBox = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Metadata")) self.cmdBox = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Commands")) self.name = TextCtrl(parent=self, id=wx.ID_ANY, size=(300, 25)) self.desc = TextCtrl(parent=self, id=wx.ID_ANY, style=wx.TE_MULTILINE, size=(300, 50)) self.author = TextCtrl(parent=self, id=wx.ID_ANY, size=(300, 25)) # commands self.overwrite = wx.CheckBox( parent=self, id=wx.ID_ANY, label=_("Allow output files to overwrite existing files"), ) self.overwrite.SetValue( UserSettings.Get(group="cmd", key="overwrite", subkey="enabled")) # buttons self.btnOk = Button(self, wx.ID_OK) self.btnCancel = Button(self, wx.ID_CANCEL) self.btnOk.SetDefault() self.btnOk.SetToolTip(_("Apply properties")) self.btnOk.SetDefault() self.btnCancel.SetToolTip(_("Close dialog and ignore changes")) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self._layout()
def _createFlyPage(self, notebook): """Create notebook page for view settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=" %s " % _("Fly-through")) pageSizer = wx.BoxSizer(wx.VERTICAL) # fly throuhg mode box = StaticBox( parent=panel, id=wx.ID_ANY, label=" %s " % (_("Fly-through mode")) ) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) # move exag gridSizer.Add( StaticText(parent=panel, id=wx.ID_ANY, label=_("Move exag:")), pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL, ) moveExag = SpinCtrl( panel, id=wx.ID_ANY, min=1, max=20, initial=UserSettings.Get(group="nviz", key="fly", subkey=["exag", "move"]), size=(65, -1), ) self.winId["nviz:fly:exag:move"] = moveExag.GetId() gridSizer.Add(moveExag, pos=(0, 1)) # turn exag gridSizer.Add( StaticText(parent=panel, id=wx.ID_ANY, label=_("Turn exag:")), pos=(1, 0), flag=wx.ALIGN_CENTER_VERTICAL, ) turnExag = SpinCtrl( panel, id=wx.ID_ANY, min=1, max=20, initial=UserSettings.Get(group="nviz", key="fly", subkey=["exag", "turn"]), size=(65, -1), ) self.winId["nviz:fly:exag:turn"] = turnExag.GetId() gridSizer.Add(turnExag, pos=(1, 1)) gridSizer.AddGrowableCol(0) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) panel.SetSizer(pageSizer) return panel
def __init__( self, parent, shape, id=wx.ID_ANY, title=_("Relation properties"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs, ): self.parent = parent self.shape = shape options = self._getOptions() if not options: self.valid = False return self.valid = True wx.Dialog.__init__(self, parent, id, title, style=style, **kwargs) self.SetIcon( wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) self.fromBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("From")) self.toBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("To")) self.option = wx.ComboBox(parent=self.panel, id=wx.ID_ANY, style=wx.CB_READONLY, choices=options) self.option.Bind(wx.EVT_COMBOBOX, self.OnOption) self.btnCancel = Button(self.panel, wx.ID_CANCEL) self.btnOk = Button(self.panel, wx.ID_OK) self.btnOk.Enable(False) self._layout()
def __init__( self, parent, giface=None, id=wx.ID_ANY, title=_("Setup for r.li modules"), style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs, ): # VARIABLES self.parent = parent # self.cmd = "r.li.setup" self.rlipath = retRLiPath() self.listfiles = self.ListFiles() # END VARIABLES # init of frame wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs) self.SetIcon( wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"), wx.BITMAP_TYPE_ICO) ) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # box for select configuration file self.confilesBox = StaticBox( parent=self.panel, id=wx.ID_ANY, label=_("Available sampling area configuration files"), ) self.listfileBox = wx.ListBox( parent=self.panel, id=wx.ID_ANY, choices=self.listfiles ) # BUTTONS #definition self.btn_close = Button(parent=self, id=wx.ID_CLOSE) self.btn_help = Button(parent=self, id=wx.ID_HELP) self.btn_remove = Button(parent=self, id=wx.ID_ANY, label=_("Remove")) self.btn_remove.SetToolTip(_("Remove a configuration file")) self.btn_new = Button(parent=self, id=wx.ID_ANY, label=_("Create")) self.btn_new.SetToolTip(_("Create a new configuration file")) self.btn_rename = Button(parent=self, id=wx.ID_ANY, label=_("Rename")) self.btn_rename.SetToolTip(_("Rename a configuration file")) self.btn_view = Button(parent=self, id=wx.ID_ANY, label=_("View/Edit")) self.btn_view.SetToolTip(_("View and edit a configuration file")) # set action for button self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp) self.btn_remove.Bind(wx.EVT_BUTTON, self.OnRemove) self.btn_new.Bind(wx.EVT_BUTTON, self.OnNew) self.btn_rename.Bind(wx.EVT_BUTTON, self.OnRename) self.btn_view.Bind(wx.EVT_BUTTON, self.OnView) self._layout() # END BUTTONS # SIZE FRAME self.SetMinSize(self.GetBestSize()) # Please check this because without this the size it is not the min self.SetClientSize(self.GetBestSize())
def __init__(self, parent, giface, data, id=wx.ID_ANY, title=_("Reprojection"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): self.parent = parent # GMFrame self._giface = giface # used to add layers wx.Dialog.__init__(self, parent, id, title, style=style, name="MultiImportDialog") self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # list of layers columns = [_('Layer id'), _('Name for output GRASS map')] self.layerBox = StaticBox(parent=self.panel, id=wx.ID_ANY) self.layerSizer = wx.StaticBoxSizer(self.layerBox, wx.HORIZONTAL) self.list = GListCtrl(parent=self.panel) for i in range(len(columns)): self.list.InsertColumn(i, columns[i]) width = (65, 180) for i in range(len(width)): self.list.SetColumnWidth(col=i, width=width[i]) self.list.LoadData(data) self.list.SelectAll(True) self.labelText = StaticText(parent=self.panel, id=wx.ID_ANY, label=_( "Projection of following layers do not match with projection of current location. ")) label = _("Layers to be reprojected") self.layerBox.SetLabel(" %s - %s " % (label, _("right click to (un)select all"))) # # buttons # # cancel self.btn_close = Button(parent=self.panel, id=wx.ID_CANCEL) # run self.btn_run = Button( parent=self.panel, id=wx.ID_OK, label=_("&Import && reproject")) self.btn_run.SetToolTip(_("Reproject selected layers")) self.btn_run.SetDefault() self.doLayout()
def __init__(self, parent, title=_("Class manager"), id=wx.ID_ANY): """ Does post init and layout. :param parent: gui parent :param title: dialog window title :param id: wx id """ wx.Dialog.__init__(self, parent=parent, title=title, id=id) self.parent = parent panel = wx.Panel(parent=self, id=wx.ID_ANY) mainSizer = wx.BoxSizer(wx.VERTICAL) box = StaticBox(panel, id=wx.ID_ANY, label=" %s " % _("Classes")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(hgap=5, vgap=5) self.catList = CategoryListCtrl(panel, mapwindow=parent, stats_data=parent.stats_data) addButton = Button(panel, id=wx.ID_ADD) deleteButton = Button(panel, id=wx.ID_DELETE) gridSizer.Add(self.catList, pos=(0, 0), span=(3, 1), flag=wx.EXPAND) gridSizer.Add(addButton, pos=(0, 1), flag=wx.EXPAND) gridSizer.Add(deleteButton, pos=(1, 1), flag=wx.EXPAND) gridSizer.AddGrowableCol(0) gridSizer.AddGrowableRow(2) sizer.Add(gridSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) btnSizer = wx.BoxSizer(wx.HORIZONTAL) closeButton = Button(panel, id=wx.ID_CLOSE) btnSizer.Add(wx.Size(-1, -1), proportion=1, flag=wx.EXPAND) btnSizer.Add(closeButton, proportion=0, flag=wx.ALIGN_RIGHT) mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) addButton.Bind(wx.EVT_BUTTON, self.OnAddCategory) deleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteCategory) closeButton.Bind(wx.EVT_BUTTON, self.OnClose) self.Bind(wx.EVT_CLOSE, self.OnClose) panel.SetSizer(mainSizer) mainSizer.Fit(self) self.SetSize((400, 250)) self.Layout()
def _createGeneralPage(self, notebook): """Create notebook page for action settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=_("General")) # colors border = wx.BoxSizer(wx.VERTICAL) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Item properties")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(hgap=3, vgap=3) row = 0 gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Disabled:")), flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)) rColor = csel.ColourSelect( parent=panel, id=wx.ID_ANY, colour=self.settings.Get( group='modeler', key='disabled', subkey='color'), size=globalvar.DIALOG_COLOR_SIZE) rColor.SetName('GetColour') self.winId['modeler:disabled:color'] = rColor.GetId() gridSizer.Add(rColor, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)) gridSizer.AddGrowableCol(0) sizer.Add( gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) border.Add(sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3) panel.SetSizer(border) return panel
def __init__( self, parent, id=wx.ID_ANY, title=_("Manage installed GRASS Addons extensions"), **kwargs): self.parent = parent wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs) self.SetIcon( wx.Icon( os.path.join( globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) self.extBox = StaticBox( parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of installed extensions")) self.extList = CheckListExtension(parent=self.panel) # buttons self.btnUninstall = Button( parent=self.panel, id=wx.ID_REMOVE, label=_("Uninstall")) self.btnUninstall.SetToolTip( _("Uninstall selected Addons extensions")) self.btnUpdate = Button( parent=self.panel, id=wx.ID_REFRESH, label=_("Reinstall")) self.btnUpdate.SetToolTip( _("Reinstall selected Addons extensions")) self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE) self.btnUninstall.Bind(wx.EVT_BUTTON, self.OnUninstall) self.btnUpdate.Bind(wx.EVT_BUTTON, self.OnUpdate) self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close()) self._layout()
def _createViewPage(self, notebook): """Create notebook page for view settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=" %s " % _("View")) pageSizer = wx.BoxSizer(wx.VERTICAL) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("View"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) row = 0 # perspective pvals = UserSettings.Get(group='nviz', key='view', subkey='persp') ipvals = UserSettings.Get(group='nviz', key='view', subkey='persp', settings_type='internal') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Perspective:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) pval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=pvals['value'], min=ipvals['min'], max=ipvals['max']) self.winId['nviz:view:persp:value'] = pval.GetId() gridSizer.Add(pval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("step:")), pos=(row, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) pstep = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=pvals['step'], min=ipvals['min'], max=ipvals['max'] - 1) self.winId['nviz:view:persp:step'] = pstep.GetId() gridSizer.Add(pstep, pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL) row += 1 # position posvals = UserSettings.Get(group='nviz', key='view', subkey='position') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Position:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("x:")), pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) px = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=posvals['x'] * 100, min=0, max=100) self.winId['nviz:view:position:x'] = px.GetId() gridSizer.Add(px, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label="y:"), pos=(row, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) py = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=posvals['y'] * 100, min=0, max=100) self.winId['nviz:view:position:y'] = py.GetId() gridSizer.Add(py, pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL) row += 1 # height is computed dynamically # twist tvals = UserSettings.Get(group='nviz', key='view', subkey='twist') itvals = UserSettings.Get(group='nviz', key='view', subkey='twist', settings_type='internal') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Twist:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) tval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=tvals['value'], min=itvals['min'], max=itvals['max']) self.winId['nviz:view:twist:value'] = tval.GetId() gridSizer.Add(tval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL) row += 1 # z-exag zvals = UserSettings.Get(group='nviz', key='view', subkey='z-exag') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Z-exag:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) zval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=zvals['value'], min=-1e6, max=1e6) self.winId['nviz:view:z-exag:value'] = zval.GetId() gridSizer.Add(zval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=3) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Image Appearance"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) # background color gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Background color:")), pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL) color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=UserSettings.Get( group='nviz', key='view', subkey=['background', 'color']), size=globalvar.DIALOG_COLOR_SIZE) color.SetName('GetColour') self.winId['nviz:view:background:color'] = color.GetId() gridSizer.Add(color, pos=(0, 1)) gridSizer.AddGrowableCol(0) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) panel.SetSizer(pageSizer) return panel
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))
def _createWidgets(self): self.labels = {} self.params = {} self.labels["output"] = StaticText( parent=self, id=wx.ID_ANY, label=_("Name for output raster map:")) self.params["output"] = Select( parent=self, type="raster", mapsets=[grass.gisenv()["MAPSET"]], size=globalvar.DIALOG_GSELECT_SIZE, ) self.regionStBoxLabel = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Export region")) self.region_types_order = ["display", "comp", "named"] self.region_types = {} self.region_types["display"] = RadioButton(parent=self, label=_("Map display"), style=wx.RB_GROUP) self.region_types["comp"] = RadioButton( parent=self, label=_("Computational region")) self.region_types["named"] = RadioButton(parent=self, label=_("Named region")) self.region_types["display"].SetToolTip( _("Extent and resolution" " are based on Map Display geometry.")) self.region_types["comp"].SetToolTip( _("Extent and resolution" " are based on computational region.")) self.region_types["named"].SetToolTip( _("Extent and resolution" " are based on named region.")) self.region_types["display"].SetValue( True) # set default as map display self.overwrite = wx.CheckBox(parent=self, id=wx.ID_ANY, label=_("Overwrite existing raster map")) self.named_reg_panel = wx.Panel(parent=self, id=wx.ID_ANY) self.labels["region"] = StaticText(parent=self.named_reg_panel, id=wx.ID_ANY, label=_("Choose named region:")) self.params["region"] = Select( parent=self.named_reg_panel, type="region", size=globalvar.DIALOG_GSELECT_SIZE, ) # buttons self.btn_close = Button(parent=self, id=wx.ID_CLOSE) self.SetEscapeId(self.btn_close.GetId()) self.btn_close.SetToolTip(_("Close dialog")) self.btn_ok = Button(parent=self, label=_("&Save layer")) self.btn_ok.SetToolTip(_("Save web service layer as raster map")) # statusbar self.statusbar = wx.StatusBar(parent=self, id=wx.ID_ANY) self._layout()
def _createWidgets(self): settingsFile = os.path.join(GetSettingsPath(), "wxWS") self.settsManager = WSManageSettingsWidget( parent=self, settingsFile=settingsFile, default_servers=self.default_servers) self.settingsBox = StaticBox(parent=self, id=wx.ID_ANY, label=_(" Server settings ")) self.serverText = StaticText(parent=self, id=wx.ID_ANY, label=_("Server:")) self.server = TextCtrl(parent=self, id=wx.ID_ANY) self.btn_connect = Button(parent=self, id=wx.ID_ANY, label=_("&Connect")) self.btn_connect.SetToolTip(_("Connect to the server")) if not self.server.GetValue(): self.btn_connect.Enable(False) self.infoCollapseLabelExp = _("Show advanced connection settings") self.infoCollapseLabelCol = _("Hide advanced connection settings") self.adv_conn = wx.CollapsiblePane( parent=self, label=self.infoCollapseLabelExp, style=wx.CP_DEFAULT_STYLE | wx.CP_NO_TLW_RESIZE | wx.EXPAND, ) self.MakeAdvConnPane(pane=self.adv_conn.GetPane()) self.adv_conn.Collapse(True) self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnAdvConnPaneChanged, self.adv_conn) self.reqDataPanel = wx.Panel(parent=self, id=wx.ID_ANY) self.layerNameBox = StaticBox(parent=self.reqDataPanel, id=wx.ID_ANY, label=_(" Layer Manager Settings ")) self.layerNameText = StaticText(parent=self.reqDataPanel, id=wx.ID_ANY, label=_("Output layer name:")) self.layerName = TextCtrl(parent=self.reqDataPanel, id=wx.ID_ANY) for ws in six.iterkeys(self.ws_panels): # set class WSPanel argument layerNameTxtCtrl self.ws_panels[ws]["panel"] = WSPanel(parent=self.reqDataPanel, web_service=ws) self.ws_panels[ws]["panel"].capParsed.connect( self.OnPanelCapParsed) self.ws_panels[ws]["panel"].layerSelected.connect( self.OnLayerSelected) # buttons self.btn_close = Button(parent=self, id=wx.ID_CLOSE) self.btn_close.SetToolTip(_("Close dialog")) # statusbar self.statusbar = wx.StatusBar(parent=self, id=wx.ID_ANY) # bindings self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.Bind(wx.EVT_CLOSE, self.OnClose) self.btn_connect.Bind(wx.EVT_BUTTON, self.OnConnect) self.server.Bind(wx.EVT_TEXT, self.OnServer) self.layerName.Bind(wx.EVT_TEXT, self.OnOutputLayerName) self.settsManager.settingsChanged.connect(self.OnSettingsChanged) self.settsManager.settingsSaving.connect(self.OnSettingsSaving)
def __init__( self, parent, giface, gconsole, menuModel=None, margin=False, style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE, gcstyle=GC_EMPTY, **kwargs, ): """ :param parent: gui parent :param gconsole: console logic :param menuModel: tree model of modules (from menu) :param margin: use margin in output pane (GStc) :param style: wx.SplitterWindow style :param gcstyle: GConsole style (GC_EMPTY, GC_PROMPT to show command prompt) """ wx.SplitterWindow.__init__(self, parent, id=wx.ID_ANY, style=style, **kwargs) self.SetName("GConsole") self.panelOutput = wx.Panel(parent=self, id=wx.ID_ANY) self.panelProgress = wx.Panel( parent=self.panelOutput, id=wx.ID_ANY, name="progressPanel" ) self.panelPrompt = wx.Panel(parent=self, id=wx.ID_ANY) # initialize variables self.parent = parent # GMFrame | CmdPanel | ? self._gconsole = gconsole self._menuModel = menuModel self._gcstyle = gcstyle self.lineWidth = 80 # signal which requests showing of a notification self.showNotification = Signal("GConsoleWindow.showNotification") # signal emitted when text appears in the console # parameter 'notification' suggests form of notification (according to # core.giface.Notification) self.contentChanged = Signal("GConsoleWindow.contentChanged") # progress bar self.progressbar = wx.Gauge( parent=self.panelProgress, id=wx.ID_ANY, range=100, pos=(110, 50), size=(-1, 25), style=wx.GA_HORIZONTAL, ) self._gconsole.Bind(EVT_CMD_PROGRESS, self.OnCmdProgress) self._gconsole.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput) self._gconsole.Bind(EVT_CMD_RUN, self.OnCmdRun) self._gconsole.Bind(EVT_CMD_DONE, self.OnCmdDone) self._gconsole.writeLog.connect(self.WriteLog) self._gconsole.writeCmdLog.connect(self.WriteCmdLog) self._gconsole.writeWarning.connect(self.WriteWarning) self._gconsole.writeError.connect(self.WriteError) # text control for command output self.cmdOutput = GStc( parent=self.panelOutput, id=wx.ID_ANY, margin=margin, wrap=None ) # command prompt # move to the if below # search depends on cmd prompt self.cmdPrompt = GPromptSTC( parent=self, giface=giface, menuModel=self._menuModel ) self.cmdPrompt.promptRunCmd.connect( lambda cmd: self._gconsole.RunCmd(command=cmd) ) self.cmdPrompt.showNotification.connect(self.showNotification) if not self._gcstyle & GC_PROMPT: self.cmdPrompt.Hide() if self._gcstyle & GC_PROMPT: cmdLabel = _("Command prompt") self.outputBox = StaticBox( parent=self.panelOutput, id=wx.ID_ANY, label=" %s " % _("Output window") ) self.cmdBox = StaticBox( parent=self.panelOutput, id=wx.ID_ANY, label=" %s " % cmdLabel ) # buttons self.btnOutputClear = ClearButton(parent=self.panelOutput) self.btnOutputClear.SetToolTip(_("Clear output window content")) self.btnCmdClear = ClearButton(parent=self.panelOutput) self.btnCmdClear.SetToolTip(_("Clear command prompt content")) self.btnOutputSave = Button(parent=self.panelOutput, id=wx.ID_SAVE) self.btnOutputSave.SetToolTip(_("Save output window content to the file")) self.btnCmdAbort = Button(parent=self.panelProgress, id=wx.ID_STOP) self.btnCmdAbort.SetToolTip(_("Abort running command")) self.btnCmdProtocol = ToggleButton( parent=self.panelOutput, id=wx.ID_ANY, label=_("&Log file"), size=self.btnCmdClear.GetSize(), ) self.btnCmdProtocol.SetToolTip( _( "Toggle to save list of executed commands into " "a file; content saved when switching off." ) ) self.cmdFileProtocol = None if not self._gcstyle & GC_PROMPT: self.btnCmdClear.Hide() self.btnCmdProtocol.Hide() self.btnCmdClear.Bind(wx.EVT_BUTTON, self.cmdPrompt.OnCmdErase) self.btnOutputClear.Bind(wx.EVT_BUTTON, self.OnOutputClear) self.btnOutputSave.Bind(wx.EVT_BUTTON, self.OnOutputSave) self.btnCmdAbort.Bind(wx.EVT_BUTTON, self._gconsole.OnCmdAbort) self.btnCmdProtocol.Bind(wx.EVT_TOGGLEBUTTON, self.OnCmdProtocol) self._layout()
def __init__(self, parent, title, nselected, style=wx.DEFAULT_DIALOG_STYLE): """Dialog used for Z bulk-labeling tool """ wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style) self.parent = parent # map window class instance # panel = wx.Panel(parent=self, id=wx.ID_ANY) border = wx.BoxSizer(wx.VERTICAL) txt = StaticText(parent=self, label=_("%d lines selected for z bulk-labeling") % nselected) border.Add(txt, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) box = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Set value")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) flexSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5) flexSizer.AddGrowableCol(0) # starting value txt = StaticText(parent=self, label=_("Starting value")) self.value = SpinCtrl(parent=self, id=wx.ID_ANY, size=(150, -1), initial=0, min=-1e6, max=1e6) flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(self.value, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) # step txt = StaticText(parent=self, label=_("Step")) self.step = SpinCtrl(parent=self, id=wx.ID_ANY, size=(150, -1), initial=0, min=0, max=1e6) flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(self.step, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE) sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) border.Add(sizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=0) # buttons btnCancel = Button(self, wx.ID_CANCEL) btnOk = Button(self, wx.ID_OK) btnOk.SetDefault() # sizers btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) btnSizer.AddButton(btnOk) btnSizer.Realize() mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(border, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) self.SetSizer(mainSizer) mainSizer.Fit(self)
def __init__(self, parent, title, vectorName, query=None, cats=None, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs): """Dialog used to display/modify categories of vector objects :param parent: :param title: dialog title :param query: {coordinates, qdist} - used by v.edit/v.what :param cats: directory of lines (layer/categories) - used by vdigit :param style: dialog style """ self.parent = parent # map window class instance self.digit = parent.digit # map name self.vectorName = vectorName # line : {layer: [categories]} self.cats = {} # do not display dialog if no line is found (-> self.cats) if cats is None: if self._getCategories(query[0], query[1]) == 0 or not self.line: Debug.msg(3, "VDigitCategoryDialog(): nothing found!") else: self.cats = cats for line in cats.keys(): for layer in cats[line].keys(): self.cats[line][layer] = list(cats[line][layer]) layers = [] for layer in self.digit.GetLayers(): layers.append(str(layer)) # make copy of cats (used for 'reload') self.cats_orig = copy.deepcopy(self.cats) wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY, title=title, style=style, **kwargs) # list of categories box = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("List of categories - right-click to delete")) listSizer = wx.StaticBoxSizer(box, wx.VERTICAL) self.list = CategoryListCtrl(parent=self, id=wx.ID_ANY, style=wx.LC_REPORT | wx.BORDER_NONE | wx.LC_SORT_ASCENDING | wx.LC_HRULES | wx.LC_VRULES) # sorter self.fid = list(self.cats.keys())[0] self.itemDataMap = self.list.Populate(self.cats[self.fid]) listmix.ColumnSorterMixin.__init__(self, 2) self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY, size=(150, -1)) self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature) self.fidText = StaticText(parent=self, id=wx.ID_ANY) if len(self.cats.keys()) == 1: self.fidMulti.Show(False) self.fidText.SetLabel(str(self.fid)) else: self.fidText.Show(False) choices = [] for fid in self.cats.keys(): choices.append(str(fid)) self.fidMulti.SetItems(choices) self.fidMulti.SetSelection(0) listSizer.Add(self.list, proportion=1, flag=wx.EXPAND) # add new category box = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Add new category")) addSizer = wx.StaticBoxSizer(box, wx.VERTICAL) flexSizer = wx.FlexGridSizer(cols=5, hgap=5, vgap=5) flexSizer.AddGrowableCol(3) layerNewTxt = StaticText(parent=self, id=wx.ID_ANY, label="%s:" % _("Layer")) self.layerNew = wx.Choice(parent=self, id=wx.ID_ANY, size=(75, -1), choices=layers) if len(layers) > 0: self.layerNew.SetSelection(0) catNewTxt = StaticText(parent=self, id=wx.ID_ANY, label="%s:" % _("Category")) try: newCat = max(self.cats[self.fid][1]) + 1 except KeyError: newCat = 1 self.catNew = SpinCtrl(parent=self, id=wx.ID_ANY, size=(75, -1), initial=newCat, min=0, max=1e9) btnAddCat = Button(self, wx.ID_ADD) flexSizer.Add(layerNewTxt, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(self.layerNew, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(catNewTxt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT, border=10) flexSizer.Add(self.catNew, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(btnAddCat, proportion=0, flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE) addSizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) # buttons btnApply = Button(self, wx.ID_APPLY) btnApply.SetToolTip(_("Apply changes")) btnCancel = Button(self, wx.ID_CANCEL) btnCancel.SetToolTip(_("Ignore changes and close dialog")) btnOk = Button(self, wx.ID_OK) btnOk.SetToolTip(_("Apply changes and close dialog")) btnOk.SetDefault() # sizers btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) # btnSizer.AddButton(btnReload) # btnSizer.SetNegativeButton(btnReload) btnSizer.AddButton(btnApply) btnSizer.AddButton(btnOk) btnSizer.Realize() mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(listSizer, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) mainSizer.Add(addSizer, proportion=0, flag=wx.EXPAND | wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) fidSizer = wx.BoxSizer(wx.HORIZONTAL) fidSizer.Add(StaticText(parent=self, id=wx.ID_ANY, label=_("Feature id:")), proportion=0, border=5, flag=wx.ALIGN_CENTER_VERTICAL) fidSizer.Add(self.fidMulti, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) fidSizer.Add(self.fidText, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(fidSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) self.SetSizer(mainSizer) mainSizer.Fit(self) self.SetAutoLayout(True) # set min size for dialog self.SetMinSize(self.GetBestSize()) # bindings btnApply.Bind(wx.EVT_BUTTON, self.OnApply) btnOk.Bind(wx.EVT_BUTTON, self.OnOK) btnAddCat.Bind(wx.EVT_BUTTON, self.OnAddCat) btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel) self.Bind(wx.EVT_CLOSE, lambda evt: self.Hide()) # list self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightUp) # wxMSW self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) # wxGTK self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list) self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEndEdit, self.list) self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)
def __init__( self, parent, data, pointNo, itemCap="Point No.", id=wx.ID_ANY, title=_("Edit point"), style=wx.DEFAULT_DIALOG_STYLE): """Dialog for editing item cells in list""" wx.Dialog.__init__(self, parent, id, title=_(title), style=style) self.parent = parent panel = Panel(parent=self) sizer = wx.BoxSizer(wx.VERTICAL) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s %s " % (_(itemCap), str(pointNo + 1))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) # source coordinates gridSizer = wx.GridBagSizer(vgap=5, hgap=5) self.fields = [] self.data = deepcopy(data) col = 0 row = 0 iField = 0 for cell in self.data: # Select if type(cell[2]).__name__ == "list": self.fields.append(ComboBox(parent=panel, id=wx.ID_ANY, choices=cell[2], style=wx.CB_READONLY, size=(110, -1))) # Text field else: if cell[2] == float: validator = FloatValidator() elif cell[2] == int: validator = IntegerValidator() else: validator = None if validator: self.fields.append( TextCtrl( parent=panel, id=wx.ID_ANY, validator=validator, size=(150, -1))) else: self.fields.append(TextCtrl(parent=panel, id=wx.ID_ANY, size=(150, -1))) value = cell[1] if not isinstance(cell[1], basestring): value = str(cell[1]) self.fields[iField].SetValue(value) label = StaticText( parent=panel, id=wx.ID_ANY, label=_( parent.GetColumn( cell[0]).GetText()) + ":") # name of column) gridSizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col)) col += 1 gridSizer.Add(self.fields[iField], pos=(row, col)) if col % 3 == 0: col = 0 row += 1 else: col += 1 iField += 1 boxSizer.Add(gridSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) sizer.Add(boxSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) # # buttons # self.btnCancel = Button(panel, wx.ID_CANCEL) self.btnOk = Button(panel, wx.ID_OK) self.btnOk.SetDefault() btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(self.btnCancel) btnSizer.AddButton(self.btnOk) btnSizer.Realize() sizer.Add(btnSizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) panel.SetSizer(sizer) sizer.Fit(self)
def __init__( self, parent, id, title, scatt_mgr, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE): """Settings dialog""" wx.Dialog.__init__(self, parent, id, title, pos, size, style) self.scatt_mgr = scatt_mgr maxValue = 1e8 self.parent = parent self.settings = {} settsLabels = {} self.settings["show_ellips"] = wx.CheckBox( parent=self, id=wx.ID_ANY, label=_('Show confidence ellipses')) show_ellips = UserSettings.Get( group='scatt', key="ellipses", subkey="show_ellips") self.settings["show_ellips"].SetValue(show_ellips) self.colorsSetts = { "sel_pol": [ "selection", _("Selection polygon color:")], "sel_pol_vertex": [ "selection", _("Color of selection polygon vertex:")], "sel_area": [ "selection", _("Selected area color:")]} for settKey, sett in six.iteritems(self.colorsSetts): settsLabels[settKey] = StaticText( parent=self, id=wx.ID_ANY, label=sett[1]) col = UserSettings.Get(group='scatt', key=sett[0], subkey=settKey) self.settings[settKey] = csel.ColourSelect( parent=self, id=wx.ID_ANY, colour=wx.Colour( col[0], col[1], col[2], 255)) self.sizeSetts = { "snap_tresh": ["selection", _("Snapping threshold in pixels:")], "sel_area_opacty": ["selection", _("Selected area opacity:")] } for settKey, sett in six.iteritems(self.sizeSetts): settsLabels[settKey] = StaticText( parent=self, id=wx.ID_ANY, label=sett[1]) self.settings[settKey] = SpinCtrl( parent=self, id=wx.ID_ANY, min=0, max=100) size = int( UserSettings.Get( group='scatt', key=sett[0], subkey=settKey)) self.settings[settKey].SetValue(size) # buttons self.btnSave = Button(self, wx.ID_SAVE) self.btnApply = Button(self, wx.ID_APPLY) self.btnClose = Button(self, wx.ID_CLOSE) self.btnApply.SetDefault() # bindings self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply) self.btnApply.SetToolTip( _("Apply changes for the current session")) self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave) self.btnSave.SetToolTip( _("Apply and save changes to user settings file (default for next sessions)")) self.btnClose.Bind(wx.EVT_BUTTON, self.OnClose) self.btnClose.SetToolTip(_("Close dialog")) # Layout # Analysis result style layout self.SetMinSize(self.GetBestSize()) sizer = wx.BoxSizer(wx.VERTICAL) sel_pol_box = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Selection style:")) selPolBoxSizer = wx.StaticBoxSizer(sel_pol_box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=1, hgap=1) row = 0 setts = dict() setts.update(self.colorsSetts) setts.update(self.sizeSetts) settsOrder = ["sel_pol", "sel_pol_vertex", "sel_area", "sel_area_opacty", "snap_tresh"] for settKey in settsOrder: sett = setts[settKey] gridSizer.Add( settsLabels[settKey], flag=wx.ALIGN_CENTER_VERTICAL, pos=( row, 0)) gridSizer.Add(self.settings[settKey], flag=wx.ALIGN_RIGHT | wx.ALL, border=5, pos=(row, 1)) row += 1 gridSizer.AddGrowableCol(1) selPolBoxSizer.Add(gridSizer, flag=wx.EXPAND) ell_box = StaticBox(parent=self, id=wx.ID_ANY, label=" %s " % _("Ellipses settings:")) ellPolBoxSizer = wx.StaticBoxSizer(ell_box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=1, hgap=1) sett = setts[settKey] row = 0 gridSizer.Add(self.settings["show_ellips"], flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)) gridSizer.AddGrowableCol(0) ellPolBoxSizer.Add(gridSizer, flag=wx.EXPAND) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(self.btnApply, flag=wx.LEFT | wx.RIGHT, border=5) btnSizer.Add(self.btnSave, flag=wx.LEFT | wx.RIGHT, border=5) btnSizer.Add(self.btnClose, flag=wx.LEFT | wx.RIGHT, border=5) sizer.Add(selPolBoxSizer, flag=wx.EXPAND | wx.ALL, border=5) sizer.Add(ellPolBoxSizer, flag=wx.EXPAND | wx.ALL, border=5) sizer.Add( btnSizer, flag=wx.EXPAND | wx.ALL, border=5, proportion=0) self.SetSizer(sizer) sizer.Fit(self)
def _createAttributesPage(self, notebook): """Create notebook page for attributes""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=_("Attributes")) border = wx.BoxSizer(wx.VERTICAL) # # add new record # box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Digitize new feature")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) # checkbox self.addRecord = CheckBox(parent=panel, id=wx.ID_ANY, label=_("Add new record into table")) self.addRecord.SetValue( UserSettings.Get(group="vdigit", key="addRecord", subkey="enabled")) sizer.Add(self.addRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) # settings flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3) flexSizer.AddGrowableCol(0) settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"), _("Next to use"))) # layer text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer")) self.layer = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(125, -1), min=1, max=1e3) self.layer.SetValue( int(UserSettings.Get(group="vdigit", key="layer", subkey="value"))) flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(self.layer, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL) # category number text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Category number")) self.category = SpinCtrl( parent=panel, id=wx.ID_ANY, size=(125, -1), initial=UserSettings.Get(group="vdigit", key="category", subkey="value"), min=-1e9, max=1e9, ) if (UserSettings.Get( group="vdigit", key="categoryMode", subkey="selection") != 1): self.category.Enable(False) flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add( self.category, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL, ) # category mode text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode")) self.categoryMode = wx.Choice( parent=panel, id=wx.ID_ANY, size=(125, -1), choices=[_("Next to use"), _("Manual entry"), _("No category")], ) self.categoryMode.SetSelection( UserSettings.Get(group="vdigit", key="categoryMode", subkey="selection")) flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add( self.categoryMode, proportion=0, flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL, ) sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) # # delete existing record # box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Delete existing feature(s)")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) # checkbox self.deleteRecord = CheckBox(parent=panel, id=wx.ID_ANY, label=_("Delete record from table")) self.deleteRecord.SetValue( UserSettings.Get(group="vdigit", key="delRecord", subkey="enabled")) sizer.Add(self.deleteRecord, proportion=0, flag=wx.ALL | wx.EXPAND, border=1) border.Add( sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5, ) # # geometry attributes (currently only length and area are supported) # box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Geometry attributes")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(hgap=3, vgap=3) self.geomAttrb = { "length": { "label": _("length") }, "area": { "label": _("area") }, "perimeter": { "label": _("perimeter") }, } digitToolbar = self.parent.toolbars["vdigit"] try: vectorName = digitToolbar.GetLayer().GetName() except AttributeError: vectorName = None # no vector selected for editing layer = UserSettings.Get(group="vdigit", key="layer", subkey="value") mapLayer = self.parent.toolbars["vdigit"].GetLayer() tree = self.parent.tree if tree: item = tree.FindItemByData("maplayer", mapLayer) else: item = None row = 0 for attrb in ["length", "area", "perimeter"]: # checkbox check = CheckBox(parent=panel, id=wx.ID_ANY, label=self.geomAttrb[attrb]["label"]) # self.deleteRecord.SetValue(UserSettings.Get(group='vdigit', key="delRecord", subkey='enabled')) check.Bind(wx.EVT_CHECKBOX, self.OnGeomAttrb) # column (only numeric) column = ColumnSelect(parent=panel, size=(200, -1)) column.InsertColumns( vector=vectorName, layer=layer, excludeKey=True, type=["integer", "double precision"], ) # units if attrb == "area": choices = Units.GetUnitsList("area") else: choices = Units.GetUnitsList("length") win_units = wx.Choice(parent=panel, id=wx.ID_ANY, choices=choices, size=(120, -1)) # default values check.SetValue(False) if (item and tree.GetLayerInfo(item, key="vdigit") and "geomAttr" in tree.GetLayerInfo(item, key="vdigit") and attrb in tree.GetLayerInfo(item, key="vdigit")["geomAttr"]): check.SetValue(True) column.SetStringSelection( tree.GetLayerInfo( item, key="vdigit")["geomAttr"][attrb]["column"]) if attrb == "area": type = "area" else: type = "length" unitsIdx = Units.GetUnitsIndex( type, tree.GetLayerInfo( item, key="vdigit")["geomAttr"][attrb]["units"], ) win_units.SetSelection(unitsIdx) if not vectorName: check.Enable(False) column.Enable(False) if not check.IsChecked(): column.Enable(False) self.geomAttrb[attrb]["check"] = check.GetId() self.geomAttrb[attrb]["column"] = column.GetId() self.geomAttrb[attrb]["units"] = win_units.GetId() gridSizer.Add(check, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)) gridSizer.Add(column, pos=(row, 1)) gridSizer.Add(win_units, pos=(row, 2)) row += 1 note = "\n".join( textwrap.wrap( _("Note: These settings are stored " "in the workspace not in the vector digitizer " "preferences."), 55, )) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=note), pos=(3, 0), span=(1, 3)) gridSizer.AddGrowableCol(0) sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1) border.Add( sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5, ) # bindings self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord) self.Bind(wx.EVT_CHOICE, self.OnChangeCategoryMode, self.categoryMode) self.Bind(wx.EVT_SPINCTRL, self.OnChangeLayer, self.layer) panel.SetSizer(border) return panel
def _createVectorPage(self, notebook): """Create notebook page for vector settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=" %s " % _("Vector")) pageSizer = wx.BoxSizer(wx.VERTICAL) # vector lines box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Vector lines"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) row = 0 # icon size gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Width:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) iwidth = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=12, min=1, max=100) self.winId['nviz:vector:lines:width'] = iwidth.GetId() iwidth.SetValue( UserSettings.Get(group='nviz', key='vector', subkey=['lines', 'width'])) gridSizer.Add(iwidth, pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL) # icon color gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")), pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL) icolor = csel.ColourSelect(panel, id=wx.ID_ANY, size=globalvar.DIALOG_COLOR_SIZE) icolor.SetName('GetColour') self.winId['nviz:vector:lines:color'] = icolor.GetId() icolor.SetColour( UserSettings.Get(group='nviz', key='vector', subkey=['lines', 'color'])) gridSizer.Add(icolor, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 5)) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) # vector points box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Vector points"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=5) row = 0 # icon size autosize = CheckBox(parent=panel, label=_("Automatic size")) autosize.SetToolTip( _("Icon size is set automatically based on landscape dimensions.")) gridSizer.Add(autosize, pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) self.winId['nviz:vector:points:autosize'] = autosize.GetId() autosize.SetValue( UserSettings.Get(group='nviz', key='vector', subkey=['points', 'autosize'])) row += 1 gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Size:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) isize = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=100, min=1, max=1e6) self.winId['nviz:vector:points:size'] = isize.GetId() isize.SetValue( UserSettings.Get(group='nviz', key='vector', subkey=['points', 'size'])) gridSizer.Add(isize, pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL) # icon symbol row += 1 gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Marker:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) isym = wx.Choice(parent=panel, id=wx.ID_ANY, size=(100, -1), choices=UserSettings.Get(group='nviz', key='vector', subkey=['points', 'marker'], settings_type='internal')) isym.SetName("GetSelection") self.winId['nviz:vector:points:marker'] = isym.GetId() isym.SetSelection( UserSettings.Get(group='nviz', key='vector', subkey=['points', 'marker'])) gridSizer.Add(isym, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)) # icon color row += 1 gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")), pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL) icolor = csel.ColourSelect(panel, id=wx.ID_ANY, size=globalvar.DIALOG_COLOR_SIZE) icolor.SetName('GetColour') self.winId['nviz:vector:points:color'] = icolor.GetId() icolor.SetColour( UserSettings.Get(group='nviz', key='vector', subkey=['points', 'color'])) gridSizer.Add(icolor, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) panel.SetSizer(pageSizer) return panel
def _createSurfacePage(self, notebook): """Create notebook page for surface settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=" %s " % _("Surface")) pageSizer = wx.BoxSizer(wx.VERTICAL) # draw box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Draw"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) # mode gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Mode:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 0)) mode = wx.Choice(parent=panel, id=wx.ID_ANY, size=(-1, -1), choices=[_("coarse"), _("fine"), _("both")]) self.winId['nviz:surface:draw:mode'] = mode.GetId() mode.SetName('GetSelection') mode.SetSelection( UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'mode'])) gridSizer.Add(mode, flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 1)) # fine gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Fine mode:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(1, 0)) res = UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'res-fine']) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("resolution:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(1, 1)) fine = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=res, min=1, max=100) self.winId['nviz:surface:draw:res-fine'] = fine.GetId() gridSizer.Add(fine, flag=wx.ALIGN_CENTER_VERTICAL, pos=(1, 2)) # coarse gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Coarse mode:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(2, 0)) res = UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'res-coarse']) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("resolution:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(2, 1)) coarse = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=res, min=1, max=100) self.winId['nviz:surface:draw:res-coarse'] = coarse.GetId() gridSizer.Add(coarse, flag=wx.ALIGN_CENTER_VERTICAL, pos=(2, 2)) # style gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("style:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(3, 1)) style = wx.Choice(parent=panel, id=wx.ID_ANY, size=(-1, -1), choices=[_("wire"), _("surface")]) self.winId['nviz:surface:draw:style'] = style.GetId() style.SetName('GetSelection') style.SetSelection( UserSettings.Get(group='nviz', key='surface', subkey=['draw', 'style'])) self.winId['nviz:surface:draw:style'] = style.GetId() gridSizer.Add(style, flag=wx.ALIGN_CENTER_VERTICAL, pos=(3, 2)) # wire color gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("wire color:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(4, 1)) color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=UserSettings.Get( group='nviz', key='surface', subkey=['draw', 'wire-color']), size=globalvar.DIALOG_COLOR_SIZE) color.SetName('GetColour') self.winId['nviz:surface:draw:wire-color'] = color.GetId() gridSizer.Add(color, flag=wx.ALIGN_CENTER_VERTICAL, pos=(4, 2)) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5) panel.SetSizer(pageSizer) return panel
def _createLightPage(self, notebook): """Create notebook page for light settings""" panel = wx.Panel(parent=notebook, id=wx.ID_ANY) notebook.AddPage(page=panel, text=" %s " % _("Lighting")) pageSizer = wx.BoxSizer(wx.VERTICAL) box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Light"))) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) gridSizer = wx.GridBagSizer(vgap=3, hgap=3) # position posvals = UserSettings.Get(group='nviz', key='light', subkey='position') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Position:")), pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("x:")), pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) px = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=posvals['x'] * 100, min=-100, max=100) self.winId['nviz:light:position:x'] = px.GetId() gridSizer.Add(px, pos=(0, 2), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label="y:"), pos=(0, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) py = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=posvals['y'] * 100, min=-100, max=100) self.winId['nviz:light:position:y'] = py.GetId() gridSizer.Add(py, pos=(0, 4), flag=wx.ALIGN_CENTER_VERTICAL) gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("z:")), pos=(0, 5), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) pz = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=posvals['z'], min=0, max=100) self.winId['nviz:light:position:z'] = pz.GetId() gridSizer.Add(pz, pos=(0, 6), flag=wx.ALIGN_CENTER_VERTICAL) # brightness brightval = UserSettings.Get(group='nviz', key='light', subkey='bright') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Brightness:")), pos=(1, 0), flag=wx.ALIGN_CENTER_VERTICAL) bright = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=brightval, min=0, max=100) self.winId['nviz:light:bright'] = bright.GetId() gridSizer.Add(bright, pos=(1, 2), flag=wx.ALIGN_CENTER_VERTICAL) # ambient ambval = UserSettings.Get(group='nviz', key='light', subkey='ambient') gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Ambient:")), pos=(2, 0), flag=wx.ALIGN_CENTER_VERTICAL) amb = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1), initial=ambval, min=0, max=100) self.winId['nviz:light:ambient'] = amb.GetId() gridSizer.Add(amb, pos=(2, 2), flag=wx.ALIGN_CENTER_VERTICAL) # light color gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")), pos=(3, 0), flag=wx.ALIGN_CENTER_VERTICAL) color = csel.ColourSelect(panel, id=wx.ID_ANY, colour=UserSettings.Get(group='nviz', key='light', subkey='color'), size=globalvar.DIALOG_COLOR_SIZE) color.SetName('GetColour') self.winId['nviz:light:color'] = color.GetId() gridSizer.Add(color, pos=(3, 2)) boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) panel.SetSizer(pageSizer) return panel
def __init__(self, parent, transforms, title=_("Select datum transformation"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): wx.Dialog.__init__(self, parent, wx.ID_ANY, title, pos, size, style) global transformlist self.CentreOnParent() # default transform number self.transnum = 0 panel = scrolled.ScrolledPanel(self, wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) # # set panel sizer # panel.SetSizer(sizer) panel.SetupScrolling() # # dialog body # bodyBox = StaticBox( parent=panel, id=wx.ID_ANY, label=" %s " % _("Select from list of datum transformations")) bodySizer = wx.StaticBoxSizer(bodyBox) # add no transform option transforms = '---\n\n0\nDo not apply any datum transformations\n\n' + transforms transformlist = transforms.split('---') tlistlen = len(transformlist) # calculate size for transform list height = 0 width = 0 for line in transforms.splitlines(): w, h = self.GetTextExtent(line) height += h width = max(width, w) height = height + 5 if height > 400: height = 400 width = width + 5 if width > 400: width = 400 # # VListBox for displaying and selecting transformations # self.translist = TransList( panel, id=-1, size=(width, height), style=wx.SUNKEN_BORDER) self.translist.SetItemCount(tlistlen) self.translist.SetSelection(2) self.translist.SetFocus() self.Bind(wx.EVT_LISTBOX, self.ClickTrans, self.translist) bodySizer.Add( self.translist, proportion=1, flag=wx.ALIGN_CENTER | wx.ALL | wx.EXPAND) # # buttons # btnsizer = wx.StdDialogButtonSizer() btn = Button(parent=panel, id=wx.ID_OK) btn.SetDefault() btnsizer.AddButton(btn) btn = Button(parent=panel, id=wx.ID_CANCEL) btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(bodySizer, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) sizer.Add(btnsizer, proportion=0, flag=wx.ALL | wx.ALIGN_RIGHT, border=5) sizer.Fit(panel) self.SetSize(self.GetBestSize()) self.Layout()
def __init__( self, parent, giface, id=wx.ID_ANY, title=_("Fetch & install extension from GRASS Addons"), **kwargs, ): self.parent = parent self._giface = giface self.options = dict() # list of options wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs) self.SetIcon( wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # self.repoBox = StaticBox( # parent=self.panel, id=wx.ID_ANY, label=" %s " % # _("Repository (leave empty to use the official one)")) self.treeBox = StaticBox( parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of extensions - double-click to install"), ) # self.repo = TextCtrl(parent=self.panel, id=wx.ID_ANY) # modelBuilder loads data into tree model self.modelBuilder = ExtensionTreeModelBuilder() # tree view displays model data self.tree = CTreeView(parent=self.panel, model=self.modelBuilder.GetModel()) self.search = SearchCtrl(self.panel) self.search.SetDescriptiveText(_("Search")) self.search.ShowCancelButton(True) # load data in different thread self.thread = gThread() self.optionBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Options")) task = gtask.parse_interface("g.extension") ignoreFlags = ["l", "c", "g", "a", "f", "t", "help", "quiet"] if sys.platform == "win32": ignoreFlags.append("d") ignoreFlags.append("i") for f in task.get_options()["flags"]: name = f.get("name", "") desc = f.get("label", "") if not desc: desc = f.get("description", "") if not name and not desc: continue if name in ignoreFlags: continue self.options[name] = wx.CheckBox(parent=self.panel, id=wx.ID_ANY, label=desc) # defaultUrl = '' # default/official one will be used when option empty # self.repo.SetValue( # task.get_param( # value='url').get( # 'default', # defaultUrl)) self.statusbar = self.CreateStatusBar(number=1) # self.btnFetch = Button(parent=self.panel, id=wx.ID_ANY, # label=_("&Fetch")) # self.btnFetch.SetToolTip(_("Fetch list of available modules " # "from GRASS Addons repository")) self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE) self.btnInstall = Button(parent=self.panel, id=wx.ID_ANY, label=_("&Install")) self.btnInstall.SetToolTip(_("Install selected add-ons GRASS module")) self.btnInstall.Enable(False) self.btnHelp = Button(parent=self.panel, id=wx.ID_HELP) self.btnHelp.SetToolTip(_("Show g.extension manual page")) self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close()) # self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch) self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall) self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp) self.search.Bind(wx.EVT_TEXT, lambda evt: self.Filter(evt.GetString())) self.search.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, lambda evt: self.Filter("")) self.tree.selectionChanged.connect(self.OnItemSelected) self.tree.itemActivated.connect(self.OnItemActivated) self.tree.contextMenu.connect(self.OnContextMenu) wx.CallAfter(self._fetch) self._layout()
def _layout(self): border = wx.BoxSizer(wx.VERTICAL) dialogSizer = wx.BoxSizer(wx.VERTICAL) regionSizer = wx.BoxSizer(wx.HORIZONTAL) dialogSizer.Add(self._addSelectSizer(title=self.band_1_label, sel=self.band_1_ch)) dialogSizer.Add(self._addSelectSizer(title=self.band_2_label, sel=self.band_2_ch)) dialogSizer.Add( self.btn_add, proportion=0, flag=wx.TOP | wx.ALIGN_RIGHT, border=5) box = StaticBox( self, id=wx.ID_ANY, label=" %s " % _("Bands of scatter plots to be added (x y):")) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer.Add( self.scattsBox, proportion=1, flag=wx.EXPAND | wx.TOP, border=5) sizer.Add( self.btn_remove, proportion=0, flag=wx.TOP | wx.ALIGN_RIGHT, border=5) dialogSizer.Add( sizer, proportion=1, flag=wx.EXPAND | wx.TOP, border=5) # buttons self.btnsizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.btnsizer.Add(self.btn_close, proportion=0, flag=wx.RIGHT | wx.LEFT | wx.ALIGN_CENTER, border=10) self.btnsizer.Add(self.btn_ok, proportion=0, flag=wx.RIGHT | wx.LEFT | wx.ALIGN_CENTER, border=10) dialogSizer.Add(self.btnsizer, proportion=0, flag=wx.ALIGN_CENTER | wx.TOP, border=5) border.Add(dialogSizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=10) self.SetSizer(border) self.Layout() self.Fit() # bindings self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) self.btn_add.Bind(wx.EVT_BUTTON, self.OnAdd) self.btn_remove.Bind(wx.EVT_BUTTON, self.OnRemoveLayer)
def __init__( self, parent, id=wx.ID_ANY, title=_('Set up vector cleaning tools'), style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs): """ Dialog for interactively defining vector cleaning tools """ wx.Frame.__init__(self, parent, id, title, style=style, **kwargs) self.parent = parent # GMFrame if self.parent: self.log = self.parent.GetLogWindow() else: self.log = None # grass command self.cmd = 'v.clean' # statusbar self.CreateStatusBar() # icon self.SetIcon( wx.Icon( os.path.join( globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # input map to clean self.inmap = '' # cleaned output map self.outmap = '' self.ftype = '' # cleaning tools self.toolslines = {} self.tool_desc_list = [ _('break lines/boundaries'), _('remove duplicates'), _('remove dangles'), _('change boundary dangles to lines'), _('remove bridges'), _('change bridges to lines'), _('snap lines/boundaries'), _('remove duplicate area centroids'), _('break polygons'), _('prune lines/boundaries'), _('remove small areas'), _('remove lines/boundaries of zero length'), _('remove small angles at nodes') ] self.tool_list = [ 'break', 'rmdupl', 'rmdangle', 'chdangle', 'rmbridge', 'chbridge', 'snap', 'rmdac', 'bpol', 'prune', 'rmarea', 'rmline', 'rmsa' ] self.ftype = [ 'point', 'line', 'boundary', 'centroid', 'area', 'face'] self.n_ftypes = len(self.ftype) self.tools_string = '' self.thresh_string = '' self.ftype_string = '' self.SetStatusText(_("Set up vector cleaning tools")) self.elem = 'vector' self.ctlabel = _('Choose cleaning tools and set thresholds') # top controls self.inmaplabel = StaticText(parent=self.panel, id=wx.ID_ANY, label=_('Select input vector map:')) self.selectionInput = Select(parent=self.panel, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE, type='vector') self.ftype_check = {} ftypeBox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=_(' Feature type: ')) self.ftypeSizer = wx.StaticBoxSizer(ftypeBox, wx.HORIZONTAL) self.outmaplabel = StaticText(parent=self.panel, id=wx.ID_ANY, label=_('Select output vector map:')) self.selectionOutput = Select(parent=self.panel, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE, mapsets=[grass.gisenv()['MAPSET'], ], fullyQualified=False, type='vector') self.overwrite = wx.CheckBox( parent=self.panel, id=wx.ID_ANY, label=_('Allow output files to overwrite existing files')) self.overwrite.SetValue( UserSettings.Get( group='cmd', key='overwrite', subkey='enabled')) # cleaning tools self.ct_label = StaticText(parent=self.panel, id=wx.ID_ANY, label=self.ctlabel) self.ct_panel = self._toolsPanel() # buttons to manage cleaning tools self.btn_add = Button(parent=self.panel, id=wx.ID_ADD) self.btn_remove = Button(parent=self.panel, id=wx.ID_REMOVE) self.btn_moveup = Button(parent=self.panel, id=wx.ID_UP) self.btn_movedown = Button(parent=self.panel, id=wx.ID_DOWN) # add one tool as default self.AddTool() self.selected = -1 # Buttons self.btn_close = Button(parent=self.panel, id=wx.ID_CLOSE) self.btn_run = Button( parent=self.panel, id=wx.ID_ANY, label=_("&Run")) self.btn_run.SetDefault() self.btn_clipboard = Button(parent=self.panel, id=wx.ID_COPY) self.btn_clipboard.SetToolTip( _("Copy the current command string to the clipboard (Ctrl+C)")) self.btn_help = Button(parent=self.panel, id=wx.ID_HELP) # bindings self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.btn_run.Bind(wx.EVT_BUTTON, self.OnCleaningRun) self.btn_clipboard.Bind(wx.EVT_BUTTON, self.OnCopy) self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp) self.btn_add.Bind(wx.EVT_BUTTON, self.OnAddTool) self.btn_remove.Bind(wx.EVT_BUTTON, self.OnClearTool) self.btn_moveup.Bind(wx.EVT_BUTTON, self.OnMoveToolUp) self.btn_movedown.Bind(wx.EVT_BUTTON, self.OnMoveToolDown) # layout self._layout() self.SetMinSize(self.GetBestSize()) self.CentreOnScreen()