def __init__(self, parent, size=(770, 460), title=_('About GRASS GIS'), **kwargs): wx.Frame.__init__(self, parent=parent, id=wx.ID_ANY, title=title, size=size, **kwargs) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # icon self.SetIcon( wx.Icon(os.path.join(globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) # notebook self.aboutNotebook = FormNotebook(self.panel, style=wx.BK_LEFT) for title, win in ((_("Info"), self._pageInfo()), (_("Copyright"), self._pageCopyright()), (_("License"), self._pageLicense()), (_("Citation"), self._pageCitation()), (_("Authors"), self._pageCredit()), (_("Contributors"), self._pageContributors()), (_("Extra contributors"), self._pageContributors(extra=True)), (_("Translators"), self._pageTranslators()), (_("Translation status"), self._pageStats())): self.aboutNotebook.AddPage(page=win, text=title) wx.CallAfter(self.aboutNotebook.SetSelection, 0) wx.CallAfter(self.aboutNotebook.Refresh) # buttons self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE) self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow) self._doLayout()
def __init__(self, parent, group=None, subgroup=None, title=_("Select imagery group"), id=wx.ID_ANY): """ Does post init and layout. :param parent: gui parent :param title: dialog window title :param id: wx id """ SimpleDialog.__init__(self, parent, title) self.use_subg = True self.groupSelect = gselect.Select( parent=self.panel, type='group', mapsets=[ grass.gisenv()['MAPSET']], size=globalvar.DIALOG_GSELECT_SIZE, validator=SimpleValidator( callback=self.ValidatorCallback)) # TODO use when subgroup will be optional # self.subg_chbox = wx.CheckBox(parent = self.panel, id = wx.ID_ANY, # label = _("Use subgroup")) self.subGroupSelect = gselect.SubGroupSelect(parent=self.panel) self.groupSelect.SetFocus() if group: self.groupSelect.SetValue(group) self.GroupSelected() if subgroup: self.subGroupSelect.SetValue(subgroup) self.editGroup = Button(parent=self.panel, id=wx.ID_ANY, label=_("Create/edit group...")) self.editGroup.Bind(wx.EVT_BUTTON, self.OnEditGroup) self.groupSelect.GetTextCtrl().Bind( wx.EVT_TEXT, lambda event: wx.CallAfter( self.GroupSelected)) self.warning = _("Name of imagery group is missing.") self._layout() self.SetMinSize(self.GetSize())
def __init__(self, parent, giface, id=wx.ID_ANY, simpleEditorHandler=None, **kwargs): self.parent = parent self.giface = giface wx.Panel.__init__(self, parent=parent, id=id, **kwargs) self.intro = _("Welcome to wxGUI Interactive Python Shell %s") % VERSION + "\n\n" + \ _("Type %s for more GRASS scripting related information.") % "\"help(gs)\"" + "\n" + \ _("Type %s to add raster or vector to the layer tree.") % "\"AddLayer()\"" + "\n\n" shellargs = dict( parent=self, id=wx.ID_ANY, introText=self.intro, locals={ "gs": grass, "AddLayer": self.AddLayer }, ) # useStockId (available since wxPython 4.0.2) should be False on macOS if sys.platform == "darwin" and CheckWxVersion([4, 0, 2]): shellargs["useStockId"] = False self.shell = PyShell(**shellargs) sys.displayhook = self._displayhook self.btnClear = ClearButton(self) self.btnClear.Bind(wx.EVT_BUTTON, self.OnClear) self.btnClear.SetToolTip(_("Delete all text from the shell")) self.simpleEditorHandler = simpleEditorHandler if simpleEditorHandler: self.btnSimpleEditor = Button(self, id=wx.ID_ANY, label=_("Simple &editor")) self.btnSimpleEditor.Bind(wx.EVT_BUTTON, simpleEditorHandler) self.btnSimpleEditor.SetToolTip( _("Open a simple Python code editor")) self._layout()
def __init__( self, parent, giface=None, id=wx.ID_ANY, title=_("GRASS" " GIS 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 CreateDialog(self, createButton=True): """Create dialog :param createButton: True to add 'create new map' button """ if self._dialog: return self._dialog = VectorSelectDialog(parent=self.parent) self._dialog.Bind(wx.EVT_CLOSE, self.OnCloseDialog) if createButton: createMap = Button(self._dialog, wx.ID_ANY, _("Create a new map")) createMap.Bind(wx.EVT_BUTTON, self.OnExportMap) self._dialog.AddWidget(createMap, proportion=0.1) self.slist = VectorSelectList(self._dialog) self.slist.Bind(wx.EVT_LIST_KEY_DOWN, self.OnDelete) self.slist.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnDeleteRow) self._dialog.AddWidget(self.slist) self.onCloseDialog = Signal('VectorSelectBase.onCloseDialog')
def __init__(self, parent, giface=None, title=_("Data Catalog")): wx.Frame.__init__(self, parent=parent, title=title) self.SetName("DataCatalog") self.SetIcon( wx.Icon(os.path.join(ICONDIR, "grass.ico"), wx.BITMAP_TYPE_ICO)) self._giface = giface self.panel = wx.Panel(self) self.catalogpanel = DataCatalog(self.panel, giface=giface) # buttons self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE) self.btnClose.SetToolTip(_("Close GRASS GIS Data Catalog")) self.btnClose.SetDefault() # events self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close()) self._layout() self.catalogpanel.LoadItems()
def _doLayout(self, modeChoices): """Do dialog layout""" SQLBuilder._doLayout(self, modeChoices) self.text_sql.SetValue("SELECT * FROM %s" % self.tablename) self.text_sql.SetToolTip( _("Example: %s") % "SELECT * FROM roadsmajor WHERE MULTILANE = 'no' OR OBJECTID < 10") self.btn_verify = Button(parent=self.panel, id=wx.ID_ANY, label=_("Verify")) self.btn_verify.SetToolTip(_("Verify SQL statement")) self.buttonsizer.Insert(1, self.btn_verify) self.text_sql.Bind(wx.EVT_TEXT, self.OnText) self.btn_verify.Bind(wx.EVT_BUTTON, self.OnVerify) self.text_sql.SetInsertionPoint(self.text_sql.GetLastPosition()) self.statusbar.SetStatusText(_("SQL statement not verified"), 0)
def __init__(self, parent, giface=None): wx.Frame.__init__(self, parent=parent, title=_('GRASS GIS Data Catalog')) self.SetName("DataCatalog") self.SetIcon( wx.Icon( os.path.join( ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self._giface = giface self.panel = wx.Panel(self) self.toolbar = DataCatalogToolbar(parent=self) # workaround for http://trac.wxwidgets.org/ticket/13888 if sys.platform != 'darwin': self.SetToolBar(self.toolbar) # tree self.tree = DataCatalogTree(parent=self.panel, giface=self._giface) self.tree.InitTreeItems() self.tree.ExpandCurrentMapset() self.tree.changeMapset.connect(lambda mapset: self.ChangeLocationMapset(location=None, mapset=mapset)) self.tree.changeLocation.connect(lambda mapset, location: self.ChangeLocationMapset(location=location, mapset=mapset)) # buttons self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE) self.btnClose.SetToolTip(_("Close GRASS GIS Data Catalog")) self.btnClose.SetDefault() # events self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self._layout()
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 __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 _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, 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, data, title=_("List of duplicates"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, pos=wx.DefaultPosition): """Show duplicated feature ids """ wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style, pos=pos) self.parent = parent # map window instance self.data = data self.winList = [] # panel = wx.Panel(parent=self, id=wx.ID_ANY) # notebook self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) id = 1 for key in self.data.keys(): panel = wx.Panel(parent=self.notebook, id=wx.ID_ANY) self.notebook.AddPage(page=panel, text=" %d " % (id)) # notebook body border = wx.BoxSizer(wx.VERTICAL) win = CheckListFeature(parent=panel, data=list(self.data[key])) self.winList.append(win.GetId()) border.Add(win, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) panel.SetSizer(border) id += 1 # 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(self.notebook, 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) self.SetAutoLayout(True) # set min size for dialog self.SetMinSize((250, 180))
def _doLayout(self, modeChoices): """Do dialog layout""" SQLBuilder._doLayout(self, modeChoices) self.initText = "UPDATE %s SET" % self.tablename if self.column: self.initText += " %s = " % self.column self.text_sql.SetValue(self.initText) self.btn_arithmetic = {'eq': ['=', ], 'brac': ['()', ], 'plus': ['+', ], 'minus': ['-', ], 'divide': ['/', ], 'multiply': ['*', ]} self.btn_arithmeticpanel = wx.Panel(parent=self.panel, id=wx.ID_ANY) for key, value in six.iteritems(self.btn_arithmetic): btn = Button(parent=self.btn_arithmeticpanel, id=wx.ID_ANY, label=value[0]) self.btn_arithmetic[key].append(btn.GetId()) btn_arithmeticsizer = wx.GridBagSizer(hgap=5, vgap=5) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['eq'][1]), pos=( 0, 0)) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['brac'][1]), pos=( 1, 0)) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['plus'][1]), pos=( 0, 1)) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['minus'][1]), pos=( 1, 1)) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['divide'][1]), pos=( 0, 2)) btn_arithmeticsizer.Add( self.FindWindowById( self.btn_arithmetic['multiply'][1]), pos=( 1, 2)) self.btn_arithmeticpanel.SetSizer(btn_arithmeticsizer) self.pagesizer.Insert(3, self.btn_arithmeticpanel, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.funcpanel = wx.Panel(parent=self.panel, id=wx.ID_ANY) self._initSqlFunctions() funcsbox = StaticBox(parent=self.funcpanel, id=wx.ID_ANY, label=" %s " % _("Functions")) funcsizer = wx.StaticBoxSizer(funcsbox, wx.VERTICAL) self.list_func = wx.ListBox(parent=self.funcpanel, id=wx.ID_ANY, choices=self.sqlFuncs['sqlite'].keys(), style=wx.LB_SORT) funcsizer.Add(self.list_func, proportion=1, flag=wx.EXPAND) self.funcpanel.SetSizer(funcsizer) self.hsizer.Insert(2, self.funcpanel, proportion=1, flag=wx.EXPAND) self.list_func.Bind(wx.EVT_LISTBOX, self.OnAddFunc) for key, value in six.iteritems(self.btn_arithmetic): self.FindWindowById(value[1]).Bind(wx.EVT_BUTTON, self.OnAddMark) self.mode.SetSelection(0) self.OnMode(None) self.text_sql.SetInsertionPoint(self.text_sql.GetLastPosition())
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 _advancedSettsPage(self): """Create advanced settings page """ # TODO parse maxcol, maxrow, settings from d.wms module? # TODO OnEarth driver - add selection of time adv_setts_panel = ScrolledPanel(parent=self, id=wx.ID_ANY, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER) self.notebook.AddPage(page=adv_setts_panel, text=_('Advanced request settings'), name='adv_req_setts') labels = {} self.l_odrder_list = None if 'WMS' in self.ws: labels['l_order'] = StaticBox( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Order of layers in raster")) self.l_odrder_list = wx.ListBox( adv_setts_panel, id=wx.ID_ANY, choices=[], style=wx.LB_SINGLE | wx.LB_NEEDED_SB) self.btnUp = Button( adv_setts_panel, id=wx.ID_ANY, label=_("Up")) self.btnDown = Button( adv_setts_panel, id=wx.ID_ANY, label=_("Down")) self.btnUp.Bind(wx.EVT_BUTTON, self.OnUp) self.btnDown.Bind(wx.EVT_BUTTON, self.OnDown) labels['method'] = StaticText(parent=adv_setts_panel, id=wx.ID_ANY, label=_("Reprojection method:")) self.reproj_methods = ['nearest', 'linear', 'cubic', 'cubicspline'] self.params['method'] = wx.Choice( parent=adv_setts_panel, id=wx.ID_ANY, choices=[ _('Nearest neighbor'), _('Linear interpolation'), _('Cubic interpolation'), _('Cubic spline interpolation')]) labels['maxcols'] = StaticText( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Maximum columns to request from server at time:")) self.params['maxcols'] = SpinCtrl( parent=adv_setts_panel, id=wx.ID_ANY, size=(100, -1)) labels['maxrows'] = StaticText( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Maximum rows to request from server at time:")) self.params['maxrows'] = SpinCtrl( parent=adv_setts_panel, id=wx.ID_ANY, size=(100, -1)) min = 100 max = 10000 self.params['maxcols'].SetRange(min, max) self.params['maxrows'].SetRange(min, max) val = 500 self.params['maxcols'].SetValue(val) self.params['maxrows'].SetValue(val) self.flags['o'] = self.params['bgcolor'] = None if 'o' not in self.drv_props['ignored_flags']: self.flags['o'] = wx.CheckBox( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Do not request transparent data")) self.flags['o'].Bind(wx.EVT_CHECKBOX, self.OnTransparent) labels['bgcolor'] = StaticText( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Background color:")) self.params['bgcolor'] = csel.ColourSelect( parent=adv_setts_panel, id=wx.ID_ANY, colour=( 255, 255, 255), size=globalvar.DIALOG_COLOR_SIZE) self.params['bgcolor'].Enable(False) self.params['urlparams'] = None if self.params['urlparams'] not in self.drv_props['ignored_params']: labels['urlparams'] = StaticText( parent=adv_setts_panel, id=wx.ID_ANY, label=_("Additional query parameters for server:")) self.params['urlparams'] = TextCtrl( parent=adv_setts_panel, id=wx.ID_ANY) # layout border = wx.BoxSizer(wx.VERTICAL) if 'WMS' in self.ws: boxSizer = wx.StaticBoxSizer(labels['l_order'], wx.VERTICAL) gridSizer = wx.GridBagSizer(hgap=3, vgap=3) gridSizer.Add(self.l_odrder_list, pos=(0, 0), span=(4, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=0) gridSizer.Add(self.btnUp, pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL, border=0) gridSizer.Add(self.btnDown, pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL, border=0) gridSizer.AddGrowableCol(0) boxSizer.Add(gridSizer, flag=wx.EXPAND | wx.ALL, border=5) border.Add(boxSizer, flag=wx.LEFT | wx.RIGHT | wx.UP | wx.EXPAND, border=5) gridSizer = wx.GridBagSizer(hgap=3, vgap=3) row = 0 for k in ['method', 'maxcols', 'maxrows', 'o', 'bgcolor']: if k in self.params: param = self.params[k] elif k in self.flags: param = self.flags[k] if param is None: continue if k in labels or k == 'o': if k != 'o': label = labels[k] else: label = param gridSizer.Add(label, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)) if k != 'o': gridSizer.Add(param, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)) row += 1 gridSizer.AddGrowableCol(0) border.Add(gridSizer, flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=5) if self.params['urlparams']: gridSizer = wx.GridBagSizer(hgap=3, vgap=3) row = 0 gridSizer.Add(labels['urlparams'], flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)) gridSizer.Add(self.params['urlparams'], flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos=(row, 1)) gridSizer.AddGrowableCol(1) border.Add(gridSizer, flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=5) adv_setts_panel.SetSizer(border) adv_setts_panel.SetAutoLayout(True) adv_setts_panel.SetupScrolling()
def __init__(self, parent, id=wx.ID_ANY, title=None, vectorName=None, item=None, log=None, selection=None, **kwargs): """GRASS Attribute Table Manager window :param parent: parent window :param id: window id :param title: window title or None for default title :param vectorName: name of vector map :param item: item from Layer Tree :param log: log window :param selection: name of page to be selected :param kwagrs: other wx.Frame's arguments """ self.parent = parent try: mapdisplay = self.parent.GetMapDisplay() except: mapdisplay = None DbMgrBase.__init__(self, id=id, mapdisplay=mapdisplay, vectorName=vectorName, item=item, log=log, statusbar=self, **kwargs) wx.Frame.__init__(self, parent, id, *kwargs) # title if not title: title = "%s" % _("GRASS GIS Attribute Table Manager - ") if not self.dbMgrData['editable']: title += _("READONLY - ") title += "<%s>" % (self.dbMgrData['vectName']) self.SetTitle(title) # icon self.SetIcon( wx.Icon(os.path.join(globalvar.ICONDIR, 'grass_sql.ico'), wx.BITMAP_TYPE_ICO)) self.panel = wx.Panel(parent=self, id=wx.ID_ANY) if len(self.dbMgrData['mapDBInfo'].layers.keys()) == 0: GMessage(parent=self.parent, message=_("Database connection for vector map <%s> " "is not defined in DB file. " "You can define new connection in " "'Manage layers' tab.") % self.dbMgrData['vectName']) busy = wx.BusyInfo(_("Please wait, loading attribute data..."), parent=self.parent) wx.SafeYield() self.CreateStatusBar(number=1) self.notebook = GNotebook(self.panel, style=globalvar.FNPageDStyle) self.CreateDbMgrPage(parent=self, pageName='browse') self.notebook.AddPage(page=self.pages['browse'], text=_("Browse data"), name='browse') self.pages['browse'].SetTabAreaColour(globalvar.FNPageColor) self.CreateDbMgrPage(parent=self, pageName='manageTable') self.notebook.AddPage(page=self.pages['manageTable'], text=_("Manage tables"), name='table') self.pages['manageTable'].SetTabAreaColour(globalvar.FNPageColor) self.CreateDbMgrPage(parent=self, pageName='manageLayer') self.notebook.AddPage(page=self.pages['manageLayer'], text=_("Manage layers"), name='layers') del busy if selection: wx.CallAfter(self.notebook.SetSelectionByName, selection) else: wx.CallAfter(self.notebook.SetSelection, 0) # select browse tab # buttons self.btnClose = CloseButton(parent=self.panel) self.btnClose.SetToolTip(_("Close Attribute Table Manager")) self.btnReload = Button(parent=self.panel, id=wx.ID_REFRESH) self.btnReload.SetToolTip( _("Reload currently selected attribute data")) self.btnReset = ClearButton(parent=self.panel) self.btnReset.SetToolTip( _("Reload all attribute data (drop current selection)")) # bind closing to ESC self.Bind(wx.EVT_MENU, self.OnCloseWindow, id=wx.ID_CANCEL) accelTableList = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CANCEL)] accelTable = wx.AcceleratorTable(accelTableList) self.SetAcceleratorTable(accelTable) # events self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow) self.btnReload.Bind(wx.EVT_BUTTON, self.OnReloadData) self.btnReset.Bind(wx.EVT_BUTTON, self.OnReloadDataAll) self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) # do layout self._layout() # self.SetMinSize(self.GetBestSize()) self.SetSize((700, 550)) # FIXME hard-coded size self.SetMinSize(self.GetSize())
def __init__(self, parent, data=None): wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=_("Query results"), size=(420, 400), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) # send query output to console self.redirectOutput = Signal('QueryDialog.redirectOutput') self.data = data self.panel = wx.Panel(self, id=wx.ID_ANY) self.mainSizer = wx.BoxSizer(wx.VERTICAL) helpText = StaticText( self.panel, wx.ID_ANY, label=_("Right click to copy selected values to clipboard.")) helpText.SetForegroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) self.mainSizer.Add(helpText, proportion=0, flag=wx.ALL, border=5) self._colNames = [_("Feature"), _("Value")] self._model = QueryTreeBuilder(self.data, column=self._colNames[1]) self.tree = TreeListView(model=self._model, parent=self.panel, columns=self._colNames, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_MULTIPLE) self.tree.SetColumnWidth(0, 220) self.tree.SetColumnWidth(1, 1000) self.tree.ExpandAll(self._model.root) self.tree.RefreshItems() self.tree.contextMenu.connect(self.ShowContextMenu) self.mainSizer.Add(self.tree, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) close = Button(self.panel, id=wx.ID_CLOSE) close.Bind(wx.EVT_BUTTON, lambda event: self.Close()) copy = Button(self.panel, id=wx.ID_ANY, label=_("Copy all to clipboard")) copy.Bind(wx.EVT_BUTTON, self.Copy) self.Bind(wx.EVT_CLOSE, self.OnClose) self.redirect = wx.CheckBox(self.panel, label=_("Redirect to console")) self.redirect.SetValue(False) self.redirect.Bind(wx.EVT_CHECKBOX, lambda evt: self._onRedirect(evt.IsChecked())) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.redirect, proportion=0, flag=wx.EXPAND | wx.RIGHT, border=5) hbox.AddStretchSpacer(1) hbox.Add(copy, proportion=0, flag=wx.EXPAND | wx.RIGHT, border=5) hbox.Add(close, proportion=0, flag=wx.EXPAND | wx.ALL, border=0) self.mainSizer.Add(hbox, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) self.panel.SetSizer(self.mainSizer) self.mainSizer.Fit(self.panel) # for Windows self.SendSizeEvent()
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, title, data, keyEditable=(-1, True), id=wx.ID_ANY, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): """Dialog for inserting/updating table record :param data: a list: [(column, value)] :param keyEditable: (id, editable?) indicates if textarea for key column is editable(True) or not """ # parent -> VDigitWindow wx.Dialog.__init__(self, parent, id, title, style=style) self.CenterOnParent() self.keyId = keyEditable[0] box = StaticBox(parent=self, id=wx.ID_ANY) box.Hide() self.dataPanel = scrolled.ScrolledPanel(parent=self, id=wx.ID_ANY, style=wx.TAB_TRAVERSAL) self.dataPanel.SetupScrolling(scroll_x=False) # buttons self.btnCancel = Button(self, wx.ID_CANCEL) self.btnSubmit = Button(self, wx.ID_OK, _("&Submit")) self.btnSubmit.SetDefault() # data area self.widgets = [] cId = 0 self.usebox = False self.cat = None winFocus = False for column, ctype, ctypeStr, value in data: if self.keyId == cId: self.cat = int(value) if not keyEditable[1]: self.usebox = True box.SetLabel(" %s %d " % (_("Category"), self.cat)) box.Show() self.boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) cId += 1 continue else: valueWin = SpinCtrl(parent=self.dataPanel, id=wx.ID_ANY, value=value, min=-1e9, max=1e9, size=(250, -1)) else: valueWin = TextCtrl(parent=self.dataPanel, id=wx.ID_ANY, value=value, size=(250, -1)) if ctype == int: valueWin.SetValidator(IntegerValidator()) elif ctype == float: valueWin.SetValidator(FloatValidator()) if not winFocus: wx.CallAfter(valueWin.SetFocus) winFocus = True label = StaticText(parent=self.dataPanel, id=wx.ID_ANY, label=column) ctype = StaticText(parent=self.dataPanel, id=wx.ID_ANY, label="[%s]:" % ctypeStr.lower()) self.widgets.append( (label.GetId(), ctype.GetId(), valueWin.GetId())) cId += 1 self._layout()
def __init__(self, parent, map, query=None, cats=None, line=None, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, pos=wx.DefaultPosition, action="add", ignoreError=False): """Standard dialog used to add/update/display attributes linked to the vector map. Attribute data can be selected based on layer and category number or coordinates. :param parent: :param map: vector map :param query: query coordinates and distance (used for v.edit) :param cats: {layer: cats} :param line: feature id (requested for cats) :param style: :param pos: :param action: (add, update, display) :param ignoreError: True to ignore errors """ self.parent = parent # mapdisplay.BufferedWindow self.map = map self.action = action # ids/cats of selected features # fid : {layer : cats} self.cats = {} self.fid = -1 # feature id # get layer/table/column information self.mapDBInfo = VectorDBInfo(self.map) layers = self.mapDBInfo.layers.keys() # get available layers # check if db connection / layer exists if len(layers) <= 0: if not ignoreError: dlg = wx.MessageDialog( parent=self.parent, message=_("No attribute table found.\n\n" "Do you want to create a new attribute table " "and defined a link to vector map <%s>?") % self.map, caption=_("Create table?"), style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: lmgr = self.parent.lmgr lmgr.OnShowAttributeTable(event=None, selection='layers') dlg.Destroy() self.mapDBInfo = None wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY, title="", style=style, pos=pos) # dialog body mainSizer = wx.BoxSizer(wx.VERTICAL) # notebook self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT) self.closeDialog = wx.CheckBox(parent=self, id=wx.ID_ANY, label=_("Close dialog on submit")) self.closeDialog.SetValue(True) if self.action == 'display': self.closeDialog.Enable(False) # feature id (text/choice for duplicates) 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) self.noFoundMsg = StaticText(parent=self, id=wx.ID_ANY, label=_("No attributes found")) self.UpdateDialog(query=query, cats=cats) # set title if self.action == "update": self.SetTitle(_("Update attributes")) elif self.action == "add": self.SetTitle(_("Define attributes")) else: self.SetTitle(_("Display attributes")) # buttons btnCancel = Button(self, wx.ID_CANCEL) btnReset = Button(self, wx.ID_UNDO, _("&Reload")) btnSubmit = Button(self, wx.ID_OK, _("&Submit")) if self.action == 'display': btnSubmit.Enable(False) btnSizer = wx.StdDialogButtonSizer() btnSizer.AddButton(btnCancel) btnSizer.AddButton(btnReset) btnSizer.SetNegativeButton(btnReset) btnSubmit.SetDefault() btnSizer.AddButton(btnSubmit) btnSizer.Realize() mainSizer.Add(self.noFoundMsg, proportion=0, flag=wx.EXPAND | wx.ALL, border=5) mainSizer.Add(self.notebook, proportion=1, flag=wx.EXPAND | wx.ALL, 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.LEFT | wx.RIGHT, border=5) mainSizer.Add(self.closeDialog, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) mainSizer.Add(btnSizer, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5) # bindigs btnReset.Bind(wx.EVT_BUTTON, self.OnReset) btnSubmit.Bind(wx.EVT_BUTTON, self.OnSubmit) btnCancel.Bind(wx.EVT_BUTTON, self.OnClose) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetSizer(mainSizer) mainSizer.Fit(self) # set min size for dialog w, h = self.GetBestSize() w += 50 if h < 200: self.SetMinSize((w, 200)) else: self.SetMinSize((w, h)) if self.notebook.GetPageCount() == 0: Debug.msg(2, "DisplayAttributesDialog(): Nothing found!")
def _doLayout(self, modeChoices, showDbInfo=False): """Do dialog layout""" self.pagesizer = wx.BoxSizer(wx.VERTICAL) # dbInfo if showDbInfo: databasebox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Database connection")) databaseboxsizer = wx.StaticBoxSizer(databasebox, wx.VERTICAL) databaseboxsizer.Add( CreateDbInfoDesc( self.panel, self.dbInfo, layer=self.layer), proportion=1, flag=wx.EXPAND | wx.ALL, border=3) # # text areas # # sql box sqlbox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Query")) sqlboxsizer = wx.StaticBoxSizer(sqlbox, wx.VERTICAL) self.text_sql = TextCtrl(parent=self.panel, id=wx.ID_ANY, value='', size=(-1, 50), style=wx.TE_MULTILINE) self.text_sql.SetInsertionPointEnd() wx.CallAfter(self.text_sql.SetFocus) sqlboxsizer.Add(self.text_sql, flag=wx.EXPAND) # # buttons # self.btn_clear = Button(parent=self.panel, id=wx.ID_CLEAR) self.btn_clear.SetToolTip(_("Set SQL statement to default")) self.btn_apply = Button(parent=self.panel, id=wx.ID_APPLY) self.btn_apply.SetToolTip(_("Apply SQL statement")) self.btn_close = Button(parent=self.panel, id=wx.ID_CLOSE) self.btn_close.SetToolTip(_("Close the dialog")) self.btn_logic = {'is': ['=', ], 'isnot': ['!=', ], 'like': ['LIKE', ], 'gt': ['>', ], 'ge': ['>=', ], 'lt': ['<', ], 'le': ['<=', ], 'or': ['OR', ], 'not': ['NOT', ], 'and': ['AND', ], 'brac': ['()', ], 'prc': ['%', ]} self.btn_logicpanel = wx.Panel(parent=self.panel, id=wx.ID_ANY) for key, value in six.iteritems(self.btn_logic): btn = Button(parent=self.btn_logicpanel, id=wx.ID_ANY, label=value[0]) self.btn_logic[key].append(btn.GetId()) self.buttonsizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5) self.buttonsizer.Add(self.btn_clear) self.buttonsizer.Add(self.btn_apply) self.buttonsizer.Add(self.btn_close) btn_logicsizer = wx.GridBagSizer(5, 5) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['is'][1]), pos=( 0, 0)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['isnot'][1]), pos=( 1, 0)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['like'][1]), pos=( 2, 0)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['gt'][1]), pos=( 0, 1)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['ge'][1]), pos=( 1, 1)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['or'][1]), pos=( 2, 1)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['lt'][1]), pos=( 0, 2)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['le'][1]), pos=( 1, 2)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['not'][1]), pos=( 2, 2)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['brac'][1]), pos=( 0, 3)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['prc'][1]), pos=( 1, 3)) btn_logicsizer.Add( self.FindWindowById( self.btn_logic['and'][1]), pos=( 2, 3)) self.btn_logicpanel.SetSizer(btn_logicsizer) # # list boxes (columns, values) # self.hsizer = wx.BoxSizer(wx.HORIZONTAL) columnsbox = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Columns")) columnsizer = wx.StaticBoxSizer(columnsbox, wx.VERTICAL) self.list_columns = wx.ListBox( parent=self.panel, id=wx.ID_ANY, choices=self.dbInfo.GetColumns( self.tablename), style=wx.LB_MULTIPLE) columnsizer.Add(self.list_columns, proportion=1, flag=wx.EXPAND) if modeChoices: modesizer = wx.BoxSizer(wx.VERTICAL) self.mode = wx.RadioBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Interactive insertion"), choices=modeChoices, style=wx.RA_SPECIFY_COLS, majorDimension=1) self.mode.SetSelection(1) # default 'values' modesizer.Add(self.mode, proportion=1, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND, border=5) # self.list_columns.SetMinSize((-1,130)) # self.list_values.SetMinSize((-1,100)) self.valuespanel = wx.Panel(parent=self.panel, id=wx.ID_ANY) valuesbox = StaticBox(parent=self.valuespanel, id=wx.ID_ANY, label=" %s " % _("Values")) valuesizer = wx.StaticBoxSizer(valuesbox, wx.VERTICAL) self.list_values = wx.ListBox(parent=self.valuespanel, id=wx.ID_ANY, choices=self.colvalues, style=wx.LB_MULTIPLE) valuesizer.Add(self.list_values, proportion=1, flag=wx.EXPAND) self.valuespanel.SetSizer(valuesizer) self.btn_unique = Button(parent=self.valuespanel, id=wx.ID_ANY, label=_("Get all values")) self.btn_unique.Enable(False) self.btn_uniquesample = Button( parent=self.valuespanel, id=wx.ID_ANY, label=_("Get sample")) self.btn_uniquesample.SetToolTip( _("Get first 256 unique values as sample")) self.btn_uniquesample.Enable(False) buttonsizer3 = wx.BoxSizer(wx.HORIZONTAL) buttonsizer3.Add(self.btn_uniquesample, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.RIGHT, border=5) buttonsizer3.Add(self.btn_unique, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) valuesizer.Add(buttonsizer3, proportion=0, flag=wx.TOP, border=5) # go to gotosizer = wx.BoxSizer(wx.HORIZONTAL) self.goto = TextCtrl( parent=self.valuespanel, id=wx.ID_ANY, style=wx.TE_PROCESS_ENTER) gotosizer.Add(StaticText(parent=self.valuespanel, id=wx.ID_ANY, label=_("Go to:")), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=5) gotosizer.Add(self.goto, proportion=1, flag=wx.EXPAND) valuesizer.Add(gotosizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) self.hsizer.Add(columnsizer, proportion=1, flag=wx.EXPAND) self.hsizer.Add(self.valuespanel, proportion=1, flag=wx.EXPAND) self.close_onapply = wx.CheckBox(parent=self.panel, id=wx.ID_ANY, label=_("Close dialog on apply")) self.close_onapply.SetValue(True) if showDbInfo: self.pagesizer.Add(databaseboxsizer, flag=wx.ALL | wx.EXPAND, border=5) if modeChoices: self.pagesizer.Add( modesizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) self.pagesizer.Add( self.hsizer, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) # self.pagesizer.Add(self.btn_uniqe,0,wx.ALIGN_LEFT|wx.TOP,border=5) # self.pagesizer.Add(self.btn_uniqesample,0,wx.ALIGN_LEFT|wx.TOP,border=5) self.pagesizer.Add(self.btn_logicpanel, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.pagesizer.Add(sqlboxsizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) self.pagesizer.Add(self.buttonsizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) self.pagesizer.Add( self.close_onapply, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5) # # bindings # if modeChoices: self.mode.Bind(wx.EVT_RADIOBOX, self.OnMode) # self.text_sql.Bind(wx.EVT_ACTIVATE, self.OnTextSqlActivate)TODO self.btn_unique.Bind(wx.EVT_BUTTON, self.OnUniqueValues) self.btn_uniquesample.Bind(wx.EVT_BUTTON, self.OnSampleValues) for key, value in six.iteritems(self.btn_logic): self.FindWindowById(value[1]).Bind(wx.EVT_BUTTON, self.OnAddMark) self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose) self.btn_clear.Bind(wx.EVT_BUTTON, self.OnClear) self.btn_apply.Bind(wx.EVT_BUTTON, self.OnApply) self.list_columns.Bind(wx.EVT_LISTBOX, self.OnAddColumn) self.list_values.Bind(wx.EVT_LISTBOX, self.OnAddValue) self.goto.Bind(wx.EVT_TEXT, self.OnGoTo) self.goto.Bind(wx.EVT_TEXT_ENTER, self.OnAddValue)
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 __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=None, id=wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE): # # GRASS variables # self.gisbase = os.getenv("GISBASE") self.grassrc = sgui.read_gisrc() self.gisdbase = self.GetRCValue("GISDBASE") # # list of locations/mapsets # self.listOfLocations = [] self.listOfMapsets = [] self.listOfMapsetsSelectable = [] wx.Frame.__init__(self, parent=parent, id=id, style=style) self.locale = wx.Locale(language=wx.LANGUAGE_DEFAULT) # scroll panel was used here but not properly and is probably not need # as long as it is not high too much self.panel = wx.Panel(parent=self, id=wx.ID_ANY) # i18N # # graphical elements # # image try: if os.getenv('ISISROOT'): name = os.path.join(globalvar.GUIDIR, "images", "startup_banner_isis.png") else: name = os.path.join(globalvar.GUIDIR, "images", "startup_banner.png") self.hbitmap = wx.StaticBitmap( self.panel, wx.ID_ANY, wx.Bitmap(name=name, type=wx.BITMAP_TYPE_PNG)) except: self.hbitmap = wx.StaticBitmap( self.panel, wx.ID_ANY, BitmapFromImage(wx.EmptyImage(530, 150))) # labels # crashes when LOCATION doesn't exist # get version & revision grassVersion, grassRevisionStr = sgui.GetVersion() self.gisdbase_box = StaticBox( parent=self.panel, id=wx.ID_ANY, label=" %s " % _("1. Select GRASS GIS database directory")) self.location_box = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("2. Select GRASS Location")) self.mapset_box = StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("3. Select GRASS Mapset")) self.lmessage = StaticText(parent=self.panel) # It is not clear if all wx versions supports color, so try-except. # The color itself may not be correct for all platforms/system settings # but in http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.SystemSettings.html # there is no 'warning' color. try: self.lmessage.SetForegroundColour(wx.Colour(255, 0, 0)) except AttributeError: pass self.gisdbase_panel = wx.Panel(parent=self.panel) self.location_panel = wx.Panel(parent=self.panel) self.mapset_panel = wx.Panel(parent=self.panel) self.ldbase = StaticText( parent=self.gisdbase_panel, id=wx.ID_ANY, label=_("GRASS GIS database directory contains Locations.")) self.llocation = StaticWrapText( parent=self.location_panel, id=wx.ID_ANY, label=_("All data in one Location is in the same " " coordinate reference system (projection)." " One Location can be one project." " Location contains Mapsets."), style=wx.ALIGN_LEFT) self.lmapset = StaticWrapText( parent=self.mapset_panel, id=wx.ID_ANY, label=_("Mapset contains GIS data related" " to one project, task within one project," " subregion or user."), style=wx.ALIGN_LEFT) try: for label in [self.ldbase, self.llocation, self.lmapset]: label.SetForegroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) except AttributeError: # for explanation of try-except see above pass # buttons self.bstart = Button(parent=self.panel, id=wx.ID_ANY, label=_("Start &GRASS session")) self.bstart.SetDefault() self.bexit = Button(parent=self.panel, id=wx.ID_EXIT) self.bstart.SetMinSize((180, self.bexit.GetSize()[1])) self.bhelp = Button(parent=self.panel, id=wx.ID_HELP) self.bbrowse = Button(parent=self.gisdbase_panel, id=wx.ID_ANY, label=_("&Browse")) self.bmapset = Button( parent=self.mapset_panel, id=wx.ID_ANY, # GTC New mapset label=_("&New")) self.bmapset.SetToolTip(_("Create a new Mapset in selected Location")) self.bwizard = Button( parent=self.location_panel, id=wx.ID_ANY, # GTC New location label=_("N&ew")) self.bwizard.SetToolTip( _("Create a new location using location wizard." " After location is created successfully," " GRASS session is started.")) self.rename_location_button = Button( parent=self.location_panel, id=wx.ID_ANY, # GTC Rename location label=_("Ren&ame")) self.rename_location_button.SetToolTip(_("Rename selected location")) self.delete_location_button = Button( parent=self.location_panel, id=wx.ID_ANY, # GTC Delete location label=_("De&lete")) self.delete_location_button.SetToolTip(_("Delete selected location")) self.download_location_button = Button(parent=self.location_panel, id=wx.ID_ANY, label=_("Do&wnload")) self.download_location_button.SetToolTip(_("Download sample location")) self.rename_mapset_button = Button( parent=self.mapset_panel, id=wx.ID_ANY, # GTC Rename mapset label=_("&Rename")) self.rename_mapset_button.SetToolTip(_("Rename selected mapset")) self.delete_mapset_button = Button( parent=self.mapset_panel, id=wx.ID_ANY, # GTC Delete mapset label=_("&Delete")) self.delete_mapset_button.SetToolTip(_("Delete selected mapset")) # textinputs self.tgisdbase = TextCtrl(parent=self.gisdbase_panel, id=wx.ID_ANY, value="", size=(300, -1), style=wx.TE_PROCESS_ENTER) # Locations self.lblocations = GListBox(parent=self.location_panel, id=wx.ID_ANY, size=(180, 200), choices=self.listOfLocations) self.lblocations.SetColumnWidth(0, 180) # TODO: sort; but keep PERMANENT on top of list # Mapsets self.lbmapsets = GListBox(parent=self.mapset_panel, id=wx.ID_ANY, size=(180, 200), choices=self.listOfMapsets) self.lbmapsets.SetColumnWidth(0, 180) # layout & properties, first do layout so everything is created self._do_layout() self._set_properties(grassVersion, grassRevisionStr) # events self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse) self.bstart.Bind(wx.EVT_BUTTON, self.OnStart) self.bexit.Bind(wx.EVT_BUTTON, self.OnExit) self.bhelp.Bind(wx.EVT_BUTTON, self.OnHelp) self.bmapset.Bind(wx.EVT_BUTTON, self.OnCreateMapset) self.bwizard.Bind(wx.EVT_BUTTON, self.OnWizard) self.rename_location_button.Bind(wx.EVT_BUTTON, self.RenameLocation) self.delete_location_button.Bind(wx.EVT_BUTTON, self.DeleteLocation) self.download_location_button.Bind(wx.EVT_BUTTON, self.DownloadLocation) self.rename_mapset_button.Bind(wx.EVT_BUTTON, self.RenameMapset) self.delete_mapset_button.Bind(wx.EVT_BUTTON, self.DeleteMapset) self.lblocations.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectLocation) self.lbmapsets.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectMapset) self.lbmapsets.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnStart) self.tgisdbase.Bind(wx.EVT_TEXT_ENTER, self.OnSetDatabase) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def _layout(self): """Creates the main panel with all the controls on it: * mpl canvas * mpl navigation toolbar * Control panel for interaction """ self.panel = wx.Panel(self) # Create the mpl Figure and FigCanvas objects. # 5x4 inches, 100 dots-per-inch # # color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND) self.fig = Figure((5.0, 4.0), facecolor=(1, 1, 1)) self.canvas = FigCanvas(self.panel, wx.ID_ANY, self.fig) # axes are initialized later self.axes2d = None self.axes3d = None # Create the navigation toolbar, tied to the canvas # self.toolbar = NavigationToolbar(self.canvas) # # Layout # self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND) self.vbox.Add(self.toolbar, 0, wx.EXPAND) self.vbox.AddSpacer(10) gridSizer = wx.GridBagSizer(hgap=5, vgap=5) self.datasetSelect = gselect.Select( parent=self.panel, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE, type="stds", multiple=True, ) self.drawButton = Button(self.panel, id=wx.ID_ANY, label=_("Draw")) self.drawButton.Bind(wx.EVT_BUTTON, self.OnRedraw) self.helpButton = Button(self.panel, id=wx.ID_ANY, label=_("Help")) self.helpButton.Bind(wx.EVT_BUTTON, self.OnHelp) self.view3dCheck = wx.CheckBox( self.panel, id=wx.ID_ANY, label=_("3D plot of spatio-temporal extents") ) self.view3dCheck.Bind(wx.EVT_CHECKBOX, self.OnRedraw) if not check_version(1, 0, 0): self.view3dCheck.SetLabel( _("3D plot of spatio-temporal extents " "(matplotlib >= 1.0.0)") ) self.view3dCheck.Disable() gridSizer.Add( StaticText( self.panel, id=wx.ID_ANY, label=_("Select space time dataset(s):") ), pos=(0, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, ) gridSizer.Add(self.datasetSelect, pos=(1, 0), flag=wx.EXPAND) gridSizer.Add(self.drawButton, pos=(1, 1), flag=wx.EXPAND) gridSizer.Add(self.helpButton, pos=(1, 2), flag=wx.EXPAND) gridSizer.Add( self.view3dCheck, pos=(2, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL ) self.vbox.Add(gridSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=10) self.panel.SetSizer(self.vbox) self.vbox.Fit(self)
def __init__(self, parent, id=wx.ID_ANY, size=(800, 600), title=_( "Set default region extent and resolution"), location=None): wx.Dialog.__init__(self, parent, id, title, size=size) panel = wx.Panel(self, id=wx.ID_ANY) self.SetIcon( wx.Icon( os.path.join( globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO)) self.parent = parent self.location = location # # default values # # 2D self.north = 1.0 self.south = 0.0 self.east = 1.0 self.west = 0.0 self.nsres = 1.0 self.ewres = 1.0 # 3D self.top = 1.0 self.bottom = 0.0 # self.nsres3 = 1.0 # self.ewres3 = 1.0 self.tbres = 1.0 # # inputs # # 2D self.tnorth = self.MakeTextCtrl( text=str( self.north), size=( 150, -1), parent=panel) self.tsouth = self.MakeTextCtrl( str(self.south), size=(150, -1), parent=panel) self.twest = self.MakeTextCtrl( str(self.west), size=(150, -1), parent=panel) self.teast = self.MakeTextCtrl( str(self.east), size=(150, -1), parent=panel) self.tnsres = self.MakeTextCtrl( str(self.nsres), size=(150, -1), parent=panel) self.tewres = self.MakeTextCtrl( str(self.ewres), size=(150, -1), parent=panel) # # labels # self.lrows = self.MakeLabel(parent=panel) self.lcols = self.MakeLabel(parent=panel) self.lcells = self.MakeLabel(parent=panel) # # buttons # self.bset = self.MakeButton( text=_("&Set region"), id=wx.ID_OK, parent=panel) self.bcancel = Button(panel, id=wx.ID_CANCEL) self.bset.SetDefault() # # image # self.img = wx.Image(os.path.join(globalvar.IMGDIR, "qgis_world.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap() # # set current working environment to PERMANENT mapset # in selected location in order to set default region (WIND) # envval = {} ret = RunCommand('g.gisenv', read=True) if ret: for line in ret.splitlines(): key, val = line.split('=') envval[key] = val self.currlocation = envval['LOCATION_NAME'].strip("';") self.currmapset = envval['MAPSET'].strip("';") if self.currlocation != self.location or self.currmapset != 'PERMANENT': RunCommand('g.gisenv', set='LOCATION_NAME=%s' % self.location) RunCommand('g.gisenv', set='MAPSET=PERMANENT') else: dlg = wx.MessageBox( parent=self, message=_('Invalid location selected.'), caption=_("Error"), style=wx.ID_OK | wx.ICON_ERROR) return # # get current region settings # region = {} ret = RunCommand('g.region', read=True, flags='gp3') if ret: for line in ret.splitlines(): key, val = line.split('=') region[key] = float(val) else: dlg = wx.MessageBox( parent=self, message=_("Invalid region"), caption=_("Error"), style=wx.ID_OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return # # update values # 2D self.north = float(region['n']) self.south = float(region['s']) self.east = float(region['e']) self.west = float(region['w']) self.nsres = float(region['nsres']) self.ewres = float(region['ewres']) self.rows = int(region['rows']) self.cols = int(region['cols']) self.cells = int(region['cells']) # 3D self.top = float(region['t']) self.bottom = float(region['b']) # self.nsres3 = float(region['nsres3']) # self.ewres3 = float(region['ewres3']) self.tbres = float(region['tbres']) self.depth = int(region['depths']) self.cells3 = int(region['cells3']) # # 3D box collapsable # self.infoCollapseLabelExp = _("Click here to show 3D settings") self.infoCollapseLabelCol = _("Click here to hide 3D settings") self.settings3D = wx.CollapsiblePane(parent=panel, label=self.infoCollapseLabelExp, style=wx.CP_DEFAULT_STYLE | wx.CP_NO_TLW_RESIZE | wx.EXPAND) self.MakeSettings3DPaneContent(self.settings3D.GetPane()) self.settings3D.Collapse(False) # FIXME self.Bind( wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnSettings3DPaneChanged, self.settings3D) # # set current region settings # self.tnorth.SetValue(str(self.north)) self.tsouth.SetValue(str(self.south)) self.twest.SetValue(str(self.west)) self.teast.SetValue(str(self.east)) self.tnsres.SetValue(str(self.nsres)) self.tewres.SetValue(str(self.ewres)) self.ttop.SetValue(str(self.top)) self.tbottom.SetValue(str(self.bottom)) # self.tnsres3.SetValue(str(self.nsres3)) # self.tewres3.SetValue(str(self.ewres3)) self.ttbres.SetValue(str(self.tbres)) self.lrows.SetLabel(_("Rows: %d") % self.rows) self.lcols.SetLabel(_("Cols: %d") % self.cols) self.lcells.SetLabel(_("Cells: %d") % self.cells) # # bindings # self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) self.tnorth.Bind(wx.EVT_TEXT, self.OnValue) self.tsouth.Bind(wx.EVT_TEXT, self.OnValue) self.teast.Bind(wx.EVT_TEXT, self.OnValue) self.twest.Bind(wx.EVT_TEXT, self.OnValue) self.tnsres.Bind(wx.EVT_TEXT, self.OnValue) self.tewres.Bind(wx.EVT_TEXT, self.OnValue) self.ttop.Bind(wx.EVT_TEXT, self.OnValue) self.tbottom.Bind(wx.EVT_TEXT, self.OnValue) # self.tnsres3.Bind(wx.EVT_TEXT, self.OnValue) # self.tewres3.Bind(wx.EVT_TEXT, self.OnValue) self.ttbres.Bind(wx.EVT_TEXT, self.OnValue) self.__DoLayout(panel) self.SetMinSize(self.GetBestSize()) self.minWindowSize = self.GetMinSize() wx.CallAfter(self.settings3D.Collapse, True)
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 __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 __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()