class SaveWMSLayerDialog(wx.Dialog): """Dialog for saving web service layer into GRASS vector/raster layer. .. todo:: Implement saving data in region of map display. """ def __init__(self, parent, layer, giface): wx.Dialog.__init__( self, parent=parent, title=("Save web service layer as raster map"), id=wx.ID_ANY, ) self.layer = layer self._giface = giface self.cmd = self.layer.GetCmd() self.thread = CmdThread(self) self.cmdStdErr = GStderr(self) self._createWidgets() 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 _layout(self): self._border = wx.BoxSizer(wx.VERTICAL) dialogSizer = wx.BoxSizer(wx.VERTICAL) regionSizer = wx.BoxSizer(wx.HORIZONTAL) dialogSizer.Add( self._addSelectSizer(title=self.labels["output"], sel=self.params["output"])) regionSizer = wx.StaticBoxSizer(self.regionStBoxLabel, wx.VERTICAL) regionTypeSizer = wx.BoxSizer(wx.HORIZONTAL) for r_type in self.region_types_order: regionTypeSizer.Add(self.region_types[r_type], flag=wx.RIGHT, border=8) regionSizer.Add(regionTypeSizer) self.named_reg_panel.SetSizer( self._addSelectSizer(title=self.labels["region"], sel=self.params["region"])) regionSizer.Add(self.named_reg_panel) self.named_reg_panel.Hide() dialogSizer.Add(regionSizer, flag=wx.EXPAND) dialogSizer.Add(self.overwrite, flag=wx.TOP, border=10) # buttons self.btnsizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.btnsizer.Add(self.btn_close, proportion=0, flag=wx.ALL | wx.ALIGN_CENTER, border=10) self.btnsizer.Add(self.btn_ok, proportion=0, flag=wx.ALL | wx.ALIGN_CENTER, border=10) dialogSizer.Add(self.btnsizer, proportion=0, flag=wx.ALIGN_CENTER) self._border.Add(dialogSizer, proportion=0, flag=wx.ALL, border=5) self._border.Add(self.statusbar, proportion=0) self.SetSizer(self._border) self.Layout() self.Fit() # bindings self.btn_ok.Bind(wx.EVT_BUTTON, self.OnSave) self.Bind(EVT_CMD_DONE, self.OnCmdDone) self.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput) for r_type in self.region_types_order: self.Bind(wx.EVT_RADIOBUTTON, self.OnRegionType, self.region_types[r_type]) def _addSelectSizer(self, title, sel): """Helper layout function.""" selSizer = wx.BoxSizer(orient=wx.VERTICAL) selTitleSizer = wx.BoxSizer(wx.HORIZONTAL) selTitleSizer.Add(title, proportion=1, flag=wx.LEFT | wx.TOP | wx.EXPAND, border=5) selSizer.Add(selTitleSizer, proportion=0, flag=wx.EXPAND) selSizer.Add( sel, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=5, ) return selSizer def OnRegionType(self, event): selected = event.GetEventObject() if selected == self.region_types["named"]: self.named_reg_panel.Show() else: self.named_reg_panel.Hide() self._border.Layout() self.Fit() def OnSave(self, event): """Import WMS raster data into GRASS as raster layer.""" self.thread.abort(abortall=True) currmapset = grass.gisenv()["MAPSET"] self.output = self.params["output"].GetValue().strip() l_spl = self.output.strip().split("@") # check output layer msg = None if not self.output: msg = _("Missing output raster.") elif len(l_spl) > 1 and l_spl[1] != currmapset: msg = _("Output map can be added only to current mapset.") elif (not self.overwrite.IsChecked() and grass.find_file(self.output, "cell", ".")["fullname"]): msg = _("Output map <%s> already exists" % self.output) if msg: GMessage(parent=self, message=msg) return self.output = l_spl[0] # check region region = self.params["region"].GetValue().strip() reg_spl = region.strip().split("@") reg_mapset = "." if len(reg_spl) > 1: reg_mapset = reg_spl[1] if self.region_types["named"].GetValue(): if not grass.find_file(reg_spl[0], "windows", reg_mapset)["fullname"]: msg = _("Region <%s> does not exist." % self.params["region"].GetValue()) GWarning(parent=self, message=msg) return # create r.in.wms command cmd = ("r.in.wms", deepcopy(self.cmd[1])) if "map" in cmd[1]: del cmd[1]["map"] cmd[1]["output"] = self.output if self.overwrite.IsChecked(): cmd[1]["overwrite"] = True env = os.environ.copy() if self.region_types["named"].GetValue(): cmd[1]["region"] = region elif self.region_types["display"].GetValue(): region = self._giface.GetMapWindow().GetMap().SetRegion() env["GRASS_REGION"] = region cmdList = cmdtuple_to_list(cmd) self.currentPid = self.thread.GetId() self.thread.RunCmd(cmdList, env=env, stderr=self.cmdStdErr) self.statusbar.SetStatusText(_("Downloading data...")) def OnCmdDone(self, event): """When data are fetched.""" if event.pid != self.currentPid: return self._addLayer() self.statusbar.SetStatusText("") def _addLayer(self): """Add layer into layer tree.""" llist = self._giface.GetLayerList() if len(llist.GetLayersByName(self.output)) == 0: cmd = ["d.rast", "map=" + self.output] llist.AddLayer(ltype="raster", name=self.output, cmd=cmd, checked=True) def OnCmdOutput(self, event): """Handle cmd output according to debug level.""" if Debug.GetLevel() == 0: if event.type == "error": msg = _("Unable to fetch data.\n") msg += event.text GWarning(parent=self, message=msg) else: Debug.msg(1, event.text)
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)
class CatalogReprojectionDialog(wx.Dialog): def __init__(self, parent, giface, inputGisdbase, inputLocation, inputMapset, inputLayer, inputEnv, outputGisdbase, outputLocation, outputMapset, outputLayer, etype, outputEnv, callback, id=wx.ID_ANY, title=_("Reprojection"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): self.parent = parent self._giface = giface wx.Dialog.__init__(self, parent, id, title, style=style, name="ReprojectionDialog") self.panel = wx.Panel(parent=self) self.iGisdbase = inputGisdbase self.iLocation = inputLocation self.iMapset = inputMapset self.iLayer = inputLayer self.iEnv = inputEnv self.oGisdbase = outputGisdbase self.oLocation = outputLocation self.oMapset = outputMapset self.oLayer = outputLayer self.etype = etype self.oEnv = outputEnv self.callback = callback self._widgets() self._doLayout() if self.etype == 'raster': self._estimateResampling() self._estimateResolution() def _widgets(self): if self.etype == 'raster': self.resolution = TextCtrl(self.panel, validator=FloatValidator()) self.resampling = wx.Choice(self.panel, size=(200, -1), choices=[ 'nearest', 'bilinear', 'bicubic', 'lanczos', 'bilinear_f', 'bicubic_f', 'lanczos_f' ]) else: self.vsplit = TextCtrl(self.panel, validator=IntegerValidator()) self.vsplit.SetValue('10000') # # buttons # self.btn_close = Button(parent=self.panel, id=wx.ID_CLOSE) self.SetEscapeId(self.btn_close.GetId()) # run self.btn_run = Button(parent=self.panel, id=wx.ID_OK, label=_("Reproject")) if self.etype == 'raster': self.btn_run.SetToolTip(_("Reproject raster")) elif self.etype == 'vector': self.btn_run.SetToolTip(_("Reproject vector")) self.btn_run.SetDefault() self.btn_run.Bind(wx.EVT_BUTTON, self.OnReproject) def _doLayout(self): """Do layout""" dialogSizer = wx.BoxSizer(wx.VERTICAL) optionsSizer = wx.GridBagSizer(5, 5) label = _("Map layer <{ml}> needs to be reprojected.\n" "Please review and modify reprojection parameters:").format( ml=self.iLayer) dialogSizer.Add(StaticText(self.panel, label=label), flag=wx.ALL | wx.EXPAND, border=10) if self.etype == 'raster': optionsSizer.Add(StaticText(self.panel, label=_("Estimated resolution:")), pos=(0, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) optionsSizer.Add(self.resolution, pos=(0, 1), flag=wx.EXPAND) optionsSizer.Add(StaticText(self.panel, label=_("Resampling method:")), pos=(1, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) optionsSizer.Add(self.resampling, pos=(1, 1), flag=wx.EXPAND) else: optionsSizer.Add(StaticText(self.panel, label=_("Maximum segment length:")), pos=(1, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL) optionsSizer.Add(self.vsplit, pos=(1, 1), flag=wx.EXPAND) optionsSizer.AddGrowableCol(1) dialogSizer.Add(optionsSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) helptext = StaticText( self.panel, label="For more reprojection options," " please see {module}".format( module='r.proj' if self.etype == 'raster' else 'v.proj')) dialogSizer.Add(helptext, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) # # buttons # btnStdSizer = wx.StdDialogButtonSizer() btnStdSizer.AddButton(self.btn_run) btnStdSizer.AddButton(self.btn_close) btnStdSizer.Realize() dialogSizer.Add(btnStdSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5) self.panel.SetSizer(dialogSizer) dialogSizer.Fit(self.panel) self.Layout() self.SetSize(self.GetBestSize()) def _estimateResolution(self): output = RunCommand('r.proj', flags='g', quiet=False, read=True, input=self.iLayer, dbase=self.iGisdbase, location=self.iLocation, mapset=self.iMapset, env=self.oEnv).strip() params = parse_key_val(output, vsep=' ') output = RunCommand('g.region', flags='ug', quiet=False, read=True, env=self.oEnv, parse=lambda x: parse_key_val(x, val_type=float), **params) cell_ns = (output['n'] - output['s']) / output['rows'] cell_ew = (output['e'] - output['w']) / output['cols'] estimate = (cell_ew + cell_ns) / 2. self.resolution.SetValue(str(estimate)) self.params = params def _estimateResampling(self): output = RunCommand('r.info', flags='g', quiet=False, read=True, map=self.iLayer, env=self.iEnv, parse=parse_key_val) if output['datatype'] == 'CELL': self.resampling.SetStringSelection('nearest') else: self.resampling.SetStringSelection('bilinear') def OnReproject(self, event): cmd = [] if self.etype == 'raster': cmd.append('r.proj') cmd.append('dbase=' + self.iGisdbase) cmd.append('location=' + self.iLocation) cmd.append('mapset=' + self.iMapset) cmd.append('input=' + self.iLayer) cmd.append('output=' + self.oLayer) cmd.append('method=' + self.resampling.GetStringSelection()) self.oEnv['GRASS_REGION'] = region_env( n=self.params['n'], s=self.params['s'], e=self.params['e'], w=self.params['w'], flags='a', res=float(self.resolution.GetValue()), env=self.oEnv) else: cmd.append('v.proj') cmd.append('dbase=' + self.iGisdbase) cmd.append('location=' + self.iLocation) cmd.append('mapset=' + self.iMapset) cmd.append('input=' + self.iLayer) cmd.append('output=' + self.oLayer) cmd.append('smax=' + self.vsplit.GetValue()) self._giface.RunCmd(cmd, env=self.oEnv, compReg=False, addLayer=False, onDone=self._onDone, userData=None, notification=Notification.MAKE_VISIBLE) event.Skip() def _onDone(self, event): self.callback()
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())