def OnCloseWindow(self, event): """!Cleanup when wxGUI is quit""" if not self.curr_page: self._auimgr.UnInit() self.Destroy() return maptree = self.curr_page.maptree if self.workspaceChanged and \ UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'): if self.workspaceFile: message = _("Do you want to save changes in the workspace?") else: message = _("Do you want to store current settings " "to workspace file?") # ask user to save current settings if maptree.GetCount() > 0: dlg = wx.MessageDialog(self, message=message, caption=_("Quit GRASS GUI"), style=wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE) ret = dlg.ShowModal() if ret == wx.ID_YES: if not self.workspaceFile: self.OnWorkspaceSaveAs() else: self.SaveToWorkspaceFile(self.workspaceFile) elif ret == wx.ID_CANCEL: event.Veto() dlg.Destroy() return dlg.Destroy() # don't ask any more... UserSettings.Set(group='manager', key='askOnQuit', subkey='enabled', value=False) for page in range(self.notebook.GetPageCount()): self.notebook.GetPage(0).maptree.mapdisplay.OnCloseWindow(event) self.notebook.DeleteAllPages() self._auimgr.UnInit() self.Destroy()
def __init__(self, parent=None, id=wx.ID_ANY, title=_("GRASS GIS - Map display"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], tree=None, notebook=None, gismgr=None, page=None, Map=None, auimgr=None, frame=None, flag=False): """ Main map display window with toolbars, statusbar and DrawWindow @param toolbars array of activated toolbars, e.g. ['map', 'digit'] @param tree reference to layer tree @param notebook control book ID in Layer Manager @param mgr Layer Manager @param page notebook page with layer tree @param Map instance of render.Map """ self.gismanager = frame # Layer Manager object self._layerManager = gismgr self.Map = Map # instance of render.Map self.tree = tree # Layer Manager layer tree object self.page = page # Notebook page holding the layer tree self.layerbook = notebook # Layer Manager layer tree notebook self.parent = parent self.frame = frame self.statusFlag = flag self.statusbar = None # # available cursors # self.cursors = { # default: cross # "default" : wx.StockCursor(wx.CURSOR_DEFAULT), "default": wx.StockCursor(wx.CURSOR_ARROW), "cross": wx.StockCursor(wx.CURSOR_CROSS), "hand": wx.StockCursor(wx.CURSOR_HAND), "pencil": wx.StockCursor(wx.CURSOR_PENCIL), "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE) } #wx.Frame.__init__(self, parent, id, title, pos, size, style) wx.Panel.__init__(self, parent, id, pos, size, style) self.SetName("MapWindow") self._mgr = wx.aui.AuiManager(self) self._layerManager = self.frame # # Add toolbars # self.toolbars = { 'map': None, 'vdigit': None, 'georect': None, 'nviz': None } for toolb in toolbars: self.AddToolbar(toolb) # # Add statusbar # if self.statusFlag: self.statusbar = self.frame.CreateStatusBar(number=4, style=0) self.statusbar.SetStatusWidths([-5, -2, -1, -1]) else: self.statusbar = self.frame.GetStatusBar() self.statusbar.SetStatusWidths([-5, -2, -1, -1]) if grassversion.rfind("6.4") == 0: self.autoRender = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY, label=_("Render")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.autoRender) self.autoRender.SetValue( UserSettings.Get(group='display', key='autoRendering', subkey='enabled')) self.autoRender.SetToolTip( wx.ToolTip(_("Enable/disable auto-rendering"))) self.maskInfo = wx.StaticText(parent=self.statusbar, id=wx.ID_ANY, label='') self.maskInfo.SetForegroundColour(wx.Colour(255, 0, 0)) self.toggleStatus = wx.Choice( self.statusbar, wx.ID_ANY, choices=globalvar.MAP_DISPLAY_STATUSBAR_MODE) self.toggleStatus.SetSelection( UserSettings.Get(group='display', key='statusbarMode', subkey='selection')) self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.toggleStatus) self.onRenderGauge = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY, range=0, style=wx.GA_HORIZONTAL) self.onRenderGauge.Hide() self.mapScale = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", style=wx.TE_PROCESS_ENTER, size=(150, -1)) self.mapScale.Hide() self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.mapScale) self.compResolution = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_( "Constrain display resolution to computational settings")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.compResolution) self.compResolution.SetValue( UserSettings.Get(group='display', key='compResolution', subkey='enabled')) self.compResolution.Hide() self.compResolution.SetToolTip( wx.ToolTip( _("Constrain display resolution " "to computational region settings. " "Default value for new map displays can " "be set up in 'User GUI settings' dialog."))) self.showRegion = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY, label=_("Show computational extent")) self.showRegion.SetValue(False) self.showRegion.Hide() self.showRegion.SetToolTip( wx.ToolTip( _("Show/hide computational " "region extent (set with g.region). " "Display region drawn as a blue box inside the " "computational region, " "computational region inside a display region " "as a red box)."))) self.statusbarWin = dict() self.statusbarWin['toggle'] = wx.Choice( self.statusbar, wx.ID_ANY, choices=globalvar.MAP_DISPLAY_STATUSBAR_MODE) self.statusbarWin['toggle'].SetSelection( UserSettings.Get(group='display', key='statusbarMode', subkey='selection')) self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.statusbarWin['toggle']) # auto-rendering checkbox self.statusbarWin['render'] = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY, label=_("Render")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.statusbarWin['render']) self.statusbarWin['render'].SetValue( UserSettings.Get(group='display', key='autoRendering', subkey='enabled')) self.statusbarWin['render'].SetToolTip( wx.ToolTip(_("Enable/disable auto-rendering"))) # show region self.statusbarWin['region'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Show computational extent")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion, self.statusbarWin['region']) self.statusbarWin['region'].SetValue(False) self.statusbarWin['region'].Hide() self.statusbarWin['region'].SetToolTip( wx.ToolTip( _("Show/hide computational " "region extent (set with g.region). " "Display region drawn as a blue box inside the " "computational region, " "computational region inside a display region " "as a red box)."))) # set resolution self.statusbarWin['resolution'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Constrain display resolution to computational settings")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.statusbarWin['resolution']) self.statusbarWin['resolution'].SetValue( UserSettings.Get(group='display', key='compResolution', subkey='enabled')) self.statusbarWin['resolution'].Hide() self.statusbarWin['resolution'].SetToolTip( wx.ToolTip( _("Constrain display resolution " "to computational region settings. " "Default value for new map displays can " "be set up in 'User GUI settings' dialog."))) # map scale self.statusbarWin['mapscale'] = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", style=wx.TE_PROCESS_ENTER, size=(150, -1)) self.statusbarWin['mapscale'].Hide() self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.statusbarWin['mapscale']) # go to self.statusbarWin['goto'] = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", style=wx.TE_PROCESS_ENTER, size=(300, -1)) self.statusbarWin['goto'].Hide() if grassversion.rfind("6.4") != 0: self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.statusbarWin['goto']) # projection self.statusbarWin['projection'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Use defined projection")) self.statusbarWin['projection'].SetValue(False) size = self.statusbarWin['projection'].GetSize() self.statusbarWin['projection'].SetMinSize((size[0] + 150, size[1])) self.statusbarWin['projection'].SetToolTip( wx.ToolTip( _("Reproject coordinates displayed " "in the statusbar. Projection can be " "defined in GUI preferences dialog " "(tab 'Display')"))) self.statusbarWin['projection'].Hide() # mask self.statusbarWin['mask'] = wx.StaticText(parent=self.statusbar, id=wx.ID_ANY, label='') self.statusbarWin['mask'].SetForegroundColour(wx.Colour(255, 0, 0)) # on-render gauge self.statusbarWin['progress'] = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY, range=0, style=wx.GA_HORIZONTAL) self.statusbarWin['progress'].Hide() self.StatusbarReposition() # reposition statusbar self.maskInfo = wx.StaticText(parent=self.statusbar, id=wx.ID_ANY, label='') self.maskInfo.SetForegroundColour(wx.Colour(255, 0, 0)) # # Init map display (buffered DC & set default cursor) # self.gisrc = self.read_gisrc() self.viewInfo = True #to display v/r.info on mapdisplay self.gisdbase = self.gisrc['GISDBASE'] parent1 = self.GetParent() frame = parent1.GetParent() self.lmgr = frame self.maptree = LayerTree(self, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS | wx.TR_LINES_AT_ROOT | wx.TR_HIDE_ROOT, gisdbase=self.gisdbase, Map=self.Map, lmgr=self.gismanager, frame=frame, idx=0, notebook=self.layerbook, auimgr=None, showMapDisplay=True) self.tree = self.maptree if grassversion.rfind("6.4") == 0: self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, gismgr=self.gismanager) else: self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, lmgr=self._layerManager) self.tree.MapWindow = self.MapWindow2D # default is 2D display mode self.MapWindow = self.MapWindow2D # self.MapWindow.Bind(wx.EVT_MOTION, MapWindow.OnMotion) #self.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.OnClick) self.MapWindow.SetCursor(self.cursors["default"]) # used by Nviz (3D display mode) self.MapWindow3D = None # # initialize region values # self.__InitDisplay() # # Bind various events # self.Bind(wx.EVT_ACTIVATE, self.OnFocus) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.Bind(render.EVT_UPDATE_PRGBAR, self.OnUpdateProgress) # # Update fancy gui style # self._mgr.AddPane( self.MapWindow, wx.aui.AuiPaneInfo().CentrePane().Dockable(False).BestSize( (-1, -1)).CloseButton(False).DestroyOnClose(True).Layer(0)) self._mgr.Update() # # Init print module and classes # self.printopt = disp_print.PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # # Init zoom history # self.MapWindow.ZoomHistory(self.Map.region['n'], self.Map.region['s'], self.Map.region['e'], self.Map.region['w']) # # Re-use dialogs # self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays pos = wx.Point(700, 10) self.onRenderGauge = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY, range=0, style=wx.GA_HORIZONTAL) self.compResolution = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Constrain display resolution to computational settings")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.compResolution) self.compResolution.SetValue( UserSettings.Get(group='display', key='compResolution', subkey='enabled')) self.compResolution.Hide() self.compResolution.SetToolTip( wx.ToolTip( _("Constrain display resolution " "to computational region settings. " "Default value for new map displays can " "be set up in 'User GUI settings' dialog."))) self.p = wx.Panel(self) #hb = wx.BoxSizer(wx.HORIZONTAL) self.p.Bind(wx.EVT_PAINT, self.onPaint) self.p.Bind(wx.EVT_LEFT_DOWN, self.OnButtonDClick) self.p.Bind(wx.EVT_MOTION, self.move) self.moveFlag = False self._mgr.AddPane( self.p, wx.aui.AuiPaneInfo().Right().Dockable(True).BestSize( (400, 300)).CloseButton(True).DestroyOnClose(True).Layer( 0).Caption("KeyMap")) self._mgr.AddPane( self.maptree, wx.aui.AuiPaneInfo().Left().Dockable(False).BestSize( (400, 300)).CloseButton(False).DestroyOnClose(True).Layer( 0).Caption("Map Tree")) self.previous = [0, 0] self.current = [0, 0] self._mgr.Update()
def OnLayerContextMenu (self, event): """!Contextual menu for item/layer""" if not self.layer_selected: event.Skip() return self.popupMenu = wx.Menu() item = event.GetItem() if self.IsItemChecked(item) == False: if self.addon == "True": self.Minimal(item) else: if self.addon == "True": self.Minimal(item) ltype = self.GetPyData(self.layer_selected)[0]['type'] Debug.msg (4, "LayerTree.OnContextMenu: layertype=%s" % \ ltype) if not hasattr (self, "popupID1"): self.popupID1 = wx.NewId() self.popupID2 = wx.NewId() self.popupID3 = wx.NewId() self.popupID4 = wx.NewId() self.popupID5 = wx.NewId() self.popupID6 = wx.NewId() self.popupID7 = wx.NewId() self.popupID8 = wx.NewId() self.popupID9 = wx.NewId() self.popupID10 = wx.NewId() self.popupID11 = wx.NewId() # nviz self.popupID12 = wx.NewId() self.popupID13 = wx.NewId() self.popupID14 = wx.NewId() self.popupID15 = wx.NewId() numSelected = len(self.GetSelections()) # general item self.popupMenu.Append(self.popupID1, text=_("Remove from MapTree")) self.Bind(wx.EVT_MENU, self.lmgr.OnDeleteLayer, id=self.popupID1) if ltype != "command": # rename self.popupMenu.Append(self.popupID2, text=_("Rename")) self.Bind(wx.EVT_MENU, self.RenameLayer, id=self.popupID2) if numSelected > 1: self.popupMenu.Enable(self.popupID2, False) # map layer items if ltype != "group" and \ ltype != "command": self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID8, text=_("Change opacity level")) self.Bind(wx.EVT_MENU, self.OnPopupOpacityLevel, id=self.popupID8) self.popupMenu.Append(self.popupID3, text=_("Properties")) self.Bind(wx.EVT_MENU, self.OnPopupProperties, id=self.popupID3) if ltype in ('raster', 'vector', 'raster3d') and self.mapdisplay.toolbars['nviz']: self.popupMenu.Append(self.popupID11, _("3D view properties")) self.Bind (wx.EVT_MENU, self.OnNvizProperties, id=self.popupID11) if ltype in ('raster', 'vector', 'rgb'): self.popupMenu.Append(self.popupID9, text=_("Zoom to selected map(s)")) self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToMap, id=self.popupID9) self.popupMenu.Append(self.popupID10, text=_("Set computational region from selected map(s)")) self.Bind(wx.EVT_MENU, self.OnSetCompRegFromMap, id=self.popupID10) if numSelected > 1: self.popupMenu.Enable(self.popupID8, False) self.popupMenu.Enable(self.popupID3, False) # specific items try: mltype = self.GetPyData(self.layer_selected)[0]['type'] except: mltype = None # # vector layers (specific items) # if mltype and mltype == "vector": self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID4, text=_("Show attribute data")) self.Bind (wx.EVT_MENU, self.lmgr.OnShowAttributeTable, id=self.popupID4) self.popupMenu.Append(self.popupID5, text=_("Start editing")) self.popupMenu.Append(self.popupID6, text=_("Stop editing")) self.popupMenu.Enable(self.popupID6, False) self.Bind (wx.EVT_MENU, self.OnStartEditing, id=self.popupID5) self.Bind (wx.EVT_MENU, self.OnStopEditing, id=self.popupID6) layer = self.GetPyData(self.layer_selected)[0]['maplayer'] # enable editing only for vector map layers available in the current mapset digitToolbar = self.mapdisplay.toolbars['vdigit'] if digitToolbar: # background vector map self.popupMenu.Append(self.popupID14, text=_("Use as background vector map"), kind=wx.ITEM_CHECK) self.Bind(wx.EVT_MENU, self.OnSetBgMap, id=self.popupID14) if UserSettings.Get(group='vdigit', key='bgmap', subkey='value', internal=True) == layer.GetName(): self.popupMenu.Check(self.popupID14, True) if layer.GetMapset() != grass.gisenv()['MAPSET']: # only vector map in current mapset can be edited self.popupMenu.Enable (self.popupID5, False) self.popupMenu.Enable (self.popupID6, False) elif digitToolbar and digitToolbar.GetLayer(): # vector map already edited vdigitLayer = digitToolbar.GetLayer() if vdigitLayer is layer: # disable 'start editing' self.popupMenu.Enable (self.popupID5, False) # enable 'stop editing' self.popupMenu.Enable(self.popupID6, True) # disable 'remove' self.popupMenu.Enable(self.popupID1, False) # disable 'bgmap' self.popupMenu.Enable(self.popupID14, False) else: # disable 'start editing' self.popupMenu.Enable(self.popupID5, False) # disable 'stop editing' self.popupMenu.Enable(self.popupID6, False) # enable 'bgmap' self.popupMenu.Enable(self.popupID14, True) self.popupMenu.Append(self.popupID7, _("Metadata")) self.Bind (wx.EVT_MENU, self.OnMetadata, id=self.popupID7) if numSelected > 1: self.popupMenu.Enable(self.popupID4, False) self.popupMenu.Enable(self.popupID5, False) self.popupMenu.Enable(self.popupID6, False) self.popupMenu.Enable(self.popupID7, False) self.popupMenu.Enable(self.popupID14, False) # # raster layers (specific items) # elif mltype and mltype == "raster": self.popupMenu.Append(self.popupID12, text=_("Zoom to selected map(s) (ignore NULLs)")) self.Bind(wx.EVT_MENU, self.mapdisplay.OnZoomToRaster, id=self.popupID12) self.popupMenu.Append(self.popupID13, text=_("Set computational region from selected map(s) (ignore NULLs)")) self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id=self.popupID13) self.popupMenu.AppendSeparator() self.popupMenu.Append(self.popupID15, _("Set color table")) self.Bind (wx.EVT_MENU, self.OnColorTable, id=self.popupID15) self.popupMenu.Append(self.popupID4, _("Histogram")) self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4) self.popupMenu.Append(self.popupID5, _("Profile")) self.Bind (wx.EVT_MENU, self.OnProfile, id=self.popupID5) self.popupMenu.Append(self.popupID6, _("Metadata")) self.Bind (wx.EVT_MENU, self.OnMetadata, id=self.popupID6) if numSelected > 1: self.popupMenu.Enable(self.popupID12, False) self.popupMenu.Enable(self.popupID13, False) self.popupMenu.Enable(self.popupID15, False) self.popupMenu.Enable(self.popupID4, False) self.popupMenu.Enable(self.popupID5, False) self.popupMenu.Enable(self.popupID6, False) self.popupMenu.Enable(self.popupID11, False) ## self.PopupMenu(self.popupMenu, pos) self.PopupMenu(self.popupMenu) self.popupMenu.Destroy() def ChooseColour(self,event): colourdialog = wx.ColourDialog(self) colourdialog.ShowModal() rgb = colourdialog.GetColourData().GetColour() rgb = str(rgb) self.colour = rgb.replace(',',':') self.colour = self.colour.strip('(') self.colour = self.colour.strip(')') item = event.GetItem() col = colourdialog.GetColourData().GetColour() self.SetHilightFocusColour(col) self.SetItemTextColour(item,col) item = event.GetItem() parent = self.GetItemParent(item) if self.IsItemChecked(parent): self.colour_selected = True self.CheckItem(parent) else: self.CheckItem(parent)
def OnMotion(self, event): """!Mouse moved Track mouse motion and update status bar """ if self.parent.statusbarWin['toggle'].GetSelection( ) == 0: # Coordinates precision = int( UserSettings.Get(group='projection', key='format', subkey='precision')) format = UserSettings.Get(group='projection', key='format', subkey='ll') try: e, n = self.Pixel2Cell(event.GetPositionTuple()) except (TypeError, ValueError): self.parent.statusbar.SetStatusText("", 0) return if self.parent.toolbars['vdigit'] and \ self.parent.toolbars['vdigit'].GetAction() == 'addLine' and \ self.parent.toolbars['vdigit'].GetAction('type') in ('line', 'boundary') and \ len(self.polycoords) > 0: # for linear feature show segment and total length distance_seg = self.Distance(self.polycoords[-1], (e, n), screen=False)[0] distance_tot = distance_seg for idx in range(1, len(self.polycoords)): distance_tot += self.Distance(self.polycoords[idx - 1], self.polycoords[idx], screen=False)[0] self.parent.statusbar.SetStatusText("%.*f, %.*f (seg: %.*f; tot: %.*f)" % \ (precision, e, precision, n, precision, distance_seg, precision, distance_tot), 0) else: if self.parent.statusbarWin['projection'].IsChecked(): if not UserSettings.Get(group='projection', key='statusbar', subkey='proj4'): self.parent.statusbar.SetStatusText( _("Projection not defined (check the settings)"), 0) else: proj, coord = utils.ReprojectCoordinates( coord=(e, n), projOut=UserSettings.Get(group='projection', key='statusbar', subkey='proj4'), flags='d') if coord: e, n = coord if proj in ('ll', 'latlong', 'longlat') and format == 'DMS': self.parent.statusbar.SetStatusText( utils.Deg2DMS(e, n, precision=precision), 0) else: self.parent.statusbar.SetStatusText("%.*f; %.*f" % \ (precision, e, precision, n), 0) else: self.parent.statusbar.SetStatusText( _("Error in projection (check the settings)"), 0) else: if self.parent.Map.projinfo[ 'proj'] == 'll' and format == 'DMS': self.parent.statusbar.SetStatusText( utils.Deg2DMS(e, n, precision=precision), 0) else: self.parent.statusbar.SetStatusText("%.*f; %.*f" % \ (precision, e, precision, n), 0) event.Skip()
def __init__(self, parent=None, id=wx.ID_ANY, title=_("GRASS GIS - Map display"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], tree=None, notebook=None, gismgr=None, page=None, Map=None, auimgr=None): self._layerManager = gismgr self.Map = Map self.gismanager = gismgr # GIS Manager object self.Map = Map # instance of render.Map self.tree = tree # GIS Manager layer tree object self.page = page # Notebook page holding the layer tree self.layerbook = notebook # GIS Manager layer tree notebook self.parent = parent # # available cursors # self.counter = 0 # available cursors # self.cursors = { # default: cross # "default" : wx.StockCursor(wx.CURSOR_DEFAULT), "default": wx.StockCursor(wx.CURSOR_ARROW), "cross": wx.StockCursor(wx.CURSOR_CROSS), "hand": wx.StockCursor(wx.CURSOR_HAND), "pencil": wx.StockCursor(wx.CURSOR_PENCIL), "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE) } wx.Frame.__init__(self, parent, id, title, pos, size, style) self.SetName("MapWindow") # # set the size & system icon # self.SetClientSize(size) self.iconsize = (16, 16) self.SetIcon( wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO)) # # Fancy gui # # self._mgr = auimgr self._mgr = wx.aui.AuiManager(self) # # Add toolbars # self.toolbars = { 'map': None, 'vdigit': None, 'georect': None, 'nviz': None } for toolb in toolbars: self.AddToolbar(toolb) # # Add statusbar # self.statusbar = self.CreateStatusBar(number=4, style=0) self.statusbar.SetStatusWidths([-5, -2, -1, -1]) self.statusbarWin = dict() self.statusbarWin['toggle'] = wx.Choice( self.statusbar, wx.ID_ANY, choices=globalvar.MAP_DISPLAY_STATUSBAR_MODE) self.statusbarWin['toggle'].SetSelection( UserSettings.Get(group='display', key='statusbarMode', subkey='selection')) self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.statusbarWin['toggle']) # auto-rendering checkbox self.statusbarWin['render'] = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY, label=_("Render")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.statusbarWin['render']) self.statusbarWin['render'].SetValue( UserSettings.Get(group='display', key='autoRendering', subkey='enabled')) self.statusbarWin['render'].SetToolTip( wx.ToolTip(_("Enable/disable auto-rendering"))) # show region self.statusbarWin['region'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Show computational extent")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion, self.statusbarWin['region']) self.statusbarWin['region'].SetValue(False) self.statusbarWin['region'].Hide() self.statusbarWin['region'].SetToolTip( wx.ToolTip( _("Show/hide computational " "region extent (set with g.region). " "Display region drawn as a blue box inside the " "computational region, " "computational region inside a display region " "as a red box)."))) # set resolution self.statusbarWin['resolution'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Constrain display resolution to computational settings")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.statusbarWin['resolution']) self.statusbarWin['resolution'].SetValue( UserSettings.Get(group='display', key='compResolution', subkey='enabled')) self.statusbarWin['resolution'].Hide() self.statusbarWin['resolution'].SetToolTip( wx.ToolTip( _("Constrain display resolution " "to computational region settings. " "Default value for new map displays can " "be set up in 'User GUI settings' dialog."))) # map scale self.statusbarWin['mapscale'] = wx.ComboBox(parent=self.statusbar, id=wx.ID_ANY, style=wx.TE_PROCESS_ENTER, size=(150, -1)) self.statusbarWin['mapscale'].SetItems([ '1:1000', '1:5000', '1:10000', '1:25000', '1:50000', '1:100000', '1:1000000' ]) self.statusbarWin['mapscale'].Hide() self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.statusbarWin['mapscale']) self.statusbar.Bind(wx.EVT_COMBOBOX, self.OnChangeMapScale, self.statusbarWin['mapscale']) # go to self.statusbarWin['goto'] = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", style=wx.TE_PROCESS_ENTER, size=(300, -1)) self.statusbarWin['goto'].Hide() # self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.statusbarWin['goto']) # projection self.statusbarWin['projection'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Use defined projection")) self.statusbarWin['projection'].SetValue(False) size = self.statusbarWin['projection'].GetSize() self.statusbarWin['projection'].SetMinSize((size[0] + 150, size[1])) self.statusbarWin['projection'].SetToolTip( wx.ToolTip( _("Reproject coordinates displayed " "in the statusbar. Projection can be " "defined in GUI preferences dialog " "(tab 'Display')"))) self.statusbarWin['projection'].Hide() # mask self.statusbarWin['mask'] = wx.StaticText(parent=self.statusbar, id=wx.ID_ANY, label='') self.statusbarWin['mask'].SetForegroundColour(wx.Colour(255, 0, 0)) # on-render gauge self.statusbarWin['progress'] = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY, range=0, style=wx.GA_HORIZONTAL) self.statusbarWin['progress'].Hide() self.StatusbarReposition() # reposition statusbar # # Init map display (buffered DC & set default cursor) # self.MapWindow2D = BufferedWindow2(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, lmgr=self.gismanager) # default is 2D display mode self.MapWindow = self.MapWindow2D if grassversion.rfind("6.4") != 0: self.Bind(wx.EVT_MOTION, self.MapWindow.OnMotion) # else: # self.Bind(wx.EVT_MOTION, self.MapWindow.OnMotion2) # self.MapWindow.Bind(wx.EVT_MOTION, self.MapWindow.OnMotion) self.MapWindow.SetCursor(self.cursors["default"]) # used by Nviz (3D display mode) self.MapWindow3D = None self.MapWindow.Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDClick) # # initialize region values # self.width, self.height = self.GetClientSize() self.Map.ChangeMapSize(self.GetClientSize()) self.Map.region = self.Map.GetRegion() # # Bind various events # #self.Bind(wx.EVT_ACTIVATE, self.OnFocus) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) # self.Bind(render.EVT_UPDATE_PRGBAR, self.OnUpdateProgress) # # Update fancy gui style # self._mgr.AddPane( self.MapWindow, wx.aui.AuiPaneInfo().CentrePane().Dockable(False).BestSize( (-1, -1)).CloseButton(False).DestroyOnClose(True).Layer(0)) self._mgr.Update() # # Init print module and classes # #self.printopt = disp_print.PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # # Init zoom history # self.MapWindow.ZoomHistory(self.Map.region['n'], self.Map.region['s'], self.Map.region['e'], self.Map.region['w']) # # Re-use dialogs # self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays # # Re-use dialogs # wx.MessageBox( "Currently Works for spearfish data. \nIf you need this to work with other grass data.\ please let me know. I will modify the code and update svn") self.mapname = 'roads@' + grass.gisenv()['MAPSET'] self.cmd = ['d.vect', str("map=" + self.mapname), 'width=1'] self.Map.AddLayer(type='vector', name=self.mapname, command=self.cmd) self.MapWindow.UpdateMap(render=True) self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays #self.Maximize() self.coords = [] self.points = []
def __init__(self, parent=None, id=wx.ID_ANY, title=_("Imagery - wx.class"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], tree=None, notebook=None, gismgr=None, page=None, Map=None, auimgr=None): self._layerManager = gismgr self.Map = Map self.gismanager = gismgr # GIS Manager object self.Map = Map # instance of render.Map self.tree = tree # GIS Manager layer tree object self.page = page # Notebook page holding the layer tree self.layerbook = notebook # GIS Manager layer tree notebook self.parent = parent # # available cursors # self.counter = 0 # available cursors # self.cursors = { # default: cross # "default" : wx.StockCursor(wx.CURSOR_DEFAULT), "default": wx.StockCursor(wx.CURSOR_ARROW), "cross": wx.StockCursor(wx.CURSOR_CROSS), "hand": wx.StockCursor(wx.CURSOR_HAND), "pencil": wx.StockCursor(wx.CURSOR_PENCIL), "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE) } wx.Frame.__init__(self, parent, id, title, pos, size, style) self.SetName("MapWindow") # # set the size & system icon # self.SetClientSize(size) self.iconsize = (16, 16) self.SetIcon( wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO)) # # Fancy gui # # self._mgr = auimgr self._mgr = wx.aui.AuiManager(self) # # Add toolbars # self.toolbars = { 'map': None, 'vdigit': None, 'georect': None, 'nviz': None } # for toolb in toolbars: # self.AddToolbar(toolb) # # Add statusbar # self.statusbar = self.CreateStatusBar(number=4, style=0) self.statusbar.SetStatusWidths([-5, -2, -1, -1]) self.statusbarWin = dict() self.statusbarWin['toggle'] = wx.Choice( self.statusbar, wx.ID_ANY, choices=globalvar.MAP_DISPLAY_STATUSBAR_MODE) self.statusbarWin['toggle'].SetSelection( UserSettings.Get(group='display', key='statusbarMode', subkey='selection')) self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.statusbarWin['toggle']) # auto-rendering checkbox self.statusbarWin['render'] = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY, label=_("Render")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.statusbarWin['render']) self.statusbarWin['render'].SetValue( UserSettings.Get(group='display', key='autoRendering', subkey='enabled')) self.statusbarWin['render'].SetToolTip( wx.ToolTip(_("Enable/disable auto-rendering"))) # show region self.statusbarWin['region'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Show computational extent")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleShowRegion, self.statusbarWin['region']) self.statusbarWin['region'].SetValue(False) self.statusbarWin['region'].Hide() self.statusbarWin['region'].SetToolTip( wx.ToolTip( _("Show/hide computational " "region extent (set with g.region). " "Display region drawn as a blue box inside the " "computational region, " "computational region inside a display region " "as a red box)."))) # set resolution self.statusbarWin['resolution'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Constrain display resolution to computational settings")) self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.statusbarWin['resolution']) self.statusbarWin['resolution'].SetValue( UserSettings.Get(group='display', key='compResolution', subkey='enabled')) self.statusbarWin['resolution'].Hide() self.statusbarWin['resolution'].SetToolTip( wx.ToolTip( _("Constrain display resolution " "to computational region settings. " "Default value for new map displays can " "be set up in 'User GUI settings' dialog."))) # map scale self.statusbarWin['mapscale'] = wx.ComboBox(parent=self.statusbar, id=wx.ID_ANY, style=wx.TE_PROCESS_ENTER, size=(150, -1)) self.statusbarWin['mapscale'].SetItems([ '1:1000', '1:5000', '1:10000', '1:25000', '1:50000', '1:100000', '1:1000000' ]) self.statusbarWin['mapscale'].Hide() self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.statusbarWin['mapscale']) self.statusbar.Bind(wx.EVT_COMBOBOX, self.OnChangeMapScale, self.statusbarWin['mapscale']) # go to self.statusbarWin['goto'] = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", style=wx.TE_PROCESS_ENTER, size=(300, -1)) self.statusbarWin['goto'].Hide() #self.statusbar.Bind(wx.EVT_TEXT_ENTER, MapFrame.OnGoTo, self.statusbarWin['goto']) # projection self.statusbarWin['projection'] = wx.CheckBox( parent=self.statusbar, id=wx.ID_ANY, label=_("Use defined projection")) self.statusbarWin['projection'].SetValue(False) size = self.statusbarWin['projection'].GetSize() self.statusbarWin['projection'].SetMinSize((size[0] + 150, size[1])) self.statusbarWin['projection'].SetToolTip( wx.ToolTip( _("Reproject coordinates displayed " "in the statusbar. Projection can be " "defined in GUI preferences dialog " "(tab 'Display')"))) self.statusbarWin['projection'].Hide() # mask self.statusbarWin['mask'] = wx.StaticText(parent=self.statusbar, id=wx.ID_ANY, label='') self.statusbarWin['mask'].SetForegroundColour(wx.Colour(255, 0, 0)) # on-render gauge self.statusbarWin['progress'] = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY, range=0, style=wx.GA_HORIZONTAL) self.statusbarWin['progress'].Hide() self.StatusbarReposition() # reposition statusbar # # Init map display (buffered DC & set default cursor) # self.MapWindow2D = BufferedWindow2(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, lmgr=self.gismanager) # default is 2D display mode self.MapWindow = self.MapWindow2D #self.MapWindow.Bind(wx.EVT_MOTION, BufferedWindow2.OnMotion) self.MapWindow.SetCursor(self.cursors["default"]) # used by Nviz (3D display mode) self.MapWindow3D = None self.MapWindow.Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDClick) self.MapWindow.Bind(wx.EVT_RIGHT_DCLICK, self.RDClick) # # initialize region values # self.width, self.height = self.GetClientSize() self.Map.ChangeMapSize(self.GetClientSize()) self.Map.region = self.Map.GetRegion() # # Bind various events # #self.Bind(wx.EVT_ACTIVATE, self.OnFocus) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) #self.Bind(render.EVT_UPDATE_PRGBAR, self.OnUpdateProgress) # # Update fancy gui style # self._mgr.AddPane( self.MapWindow, wx.aui.AuiPaneInfo().CentrePane().Dockable(False).BestSize( (-1, -1)).CloseButton(False).DestroyOnClose(True).Layer(0)) self._mgr.Update() # # Init print module and classes # #self.printopt = disp_print.PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # # Init zoom history # # # Re-use dialogs # self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays # # Re-use dialogs # self.coords = [] self.coor = [] self.mapname = 'lsat7_2000_10@' + grass1.gisenv()['MAPSET'] self.cmd = ['d.rast', str("map=" + self.mapname)] self.Map.AddLayer(type='raster', name=self.mapname, command=self.cmd) self.MapWindow.UpdateMap(render=True) self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays #self.Maximize() self.X = [] self.Y = [] self.tempX = [] self.tempY = [] self.npoints = 0 self.VX = [] self.VY = [] self.perimeter_npoints = 0 self.perimeterX = [] self.perimeterY = [] self.Region_perimeter = [] # initialize self.data_type = [] self.inrast = [] self.infd = [] self.Band_sum = [] self.Bandbuf = [] self.Band_histo = [] self.Band_Product = [] self.Band_min = [] self.Band_max = [] self.np = 0 # find map in search path self.name = [ 'lsat7_2000_10', 'lsat7_2000_20', 'lsat7_2000_30', 'lsat7_2000_40', 'lsat7_2000_50', 'lsat7_2000_70' ] # determine the inputmap type (CELL/FCELL/DCELL) */ # for n in range(0,6): # self.data_type = grass.G_raster_map_type(name[n], mapset) # self.infd.append( grass.G_open_cell_old(name[n], mapset)) # determine the inputmap type (CELL/FCELL/DCELL) */ self.mapset = 'landsat' self.mapset = c_char_p(self.mapset).value self.open_band_files() self.vnrows = 0 self.vncols = 0 self.hnrows = 0 self.hncols = 0 self.htop = self.hbottom = self.hleft = self.hright = 0 self.view() self.viewhistogram() self.cellhd = grasslib.Cell_head() if (raster.Rast_get_cellhd('lsat7_2000_10', self.mapset, byref(self.cellhd))) == 0: print "error1" #9400694566 self.Band_cellhd = self.cellhd self.dst = self.adjust_window_to_box(self.cellhd, self.vnrows, self.vncols) self.vcleft = self.vleft + (self.vncols - self.dst.cols) / 2 self.vcright = self.vcleft + self.dst.cols - 1 self.vctop = self.vtop + (self.vnrows - self.dst.rows) / 2 self.vcbottom = self.vctop + self.dst.rows - 1 self.vc_ns_res = self.cellhd.ns_res self.vc_ew_res = self.cellhd.ew_res for b in xrange(6): self.Band_sum.append(0.0) self.Band_histo.append([]) for b2 in xrange(256): self.Band_Product.append([]) self.Band_histo[b].append(0.0) for b2 in xrange(255): self.Band_Product[b].append(0)
def __init__(self, parent, Rinstance, controller, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = parent self.border = 4 # 1. Input data InputBoxSizer = wx.StaticBoxSizer(wx.StaticBox(self, id=wx.ID_ANY, label=_("Input Data")), orient=wx.HORIZONTAL) flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5) flexSizer.AddGrowableCol(1) flexSizer.Add(item=wx.StaticText(self, id=wx.ID_ANY, label=_("Point dataset:")), flag=wx.ALIGN_CENTER_VERTICAL) self.InputDataMap = gselect.VectorSelect(parent=self, ftype='points') self.InputDataMap.SetFocus() flexSizer.Add(item=self.InputDataMap, flag=wx.ALIGN_CENTER_VERTICAL) RefreshButton = wx.Button(self, id=wx.ID_REFRESH) RefreshButton.Bind(wx.EVT_BUTTON, self.OnButtonRefresh) flexSizer.Add(item=RefreshButton, flag=wx.ALIGN_CENTER_VERTICAL) flexSizer.Add(item=wx.StaticText(self, id=wx.ID_ANY, label=_("Numeric column:")), flag=wx.ALIGN_CENTER_VERTICAL) self.InputDataColumn = gselect.ColumnSelect(self, id=wx.ID_ANY) self.InputDataColumn.SetSelection(0) flexSizer.Add(item=self.InputDataColumn) self.InputDataMap.GetChildren()[0].Bind(wx.EVT_TEXT, self.OnInputDataChanged) InputBoxSizer.Add(item=flexSizer) # 2. Kriging. In book pages one for each R package. Includes variogram fit. KrigingSizer = wx.StaticBoxSizer( wx.StaticBox(self, id=wx.ID_ANY, label=_("Kriging")), wx.HORIZONTAL) self.RPackagesBook = FN.FlatNotebook( parent=self, id=wx.ID_ANY, style=FN.FNB_BOTTOM | FN.FNB_NO_NAV_BUTTONS | FN.FNB_FANCY_TABS | FN.FNB_NO_X_BUTTON) for Rpackage in [ "gstat" ]: # , "geoR"]: #@TODO: enable it if/when it'll be implemented. self.CreatePage(package=Rpackage, Rinstance=Rinstance, controller=controller) ## Command output. From menuform module, cmdPanel class self.goutput = goutput.GMConsole( parent=self, margin=False, pageid=self.RPackagesBook.GetPageCount(), notebook=self.RPackagesBook) self.goutputId = self.RPackagesBook.GetPageCount() self.outpage = self.RPackagesBook.AddPage(self.goutput, text=_("Command output")) self.RPackagesBook.SetSelection(0) KrigingSizer.Add(self.RPackagesBook, proportion=1, flag=wx.EXPAND) # 3. Output Parameters. OutputSizer = wx.StaticBoxSizer( wx.StaticBox(self, id=wx.ID_ANY, label=_("Output")), wx.HORIZONTAL) OutputParameters = wx.GridBagSizer(hgap=5, vgap=5) OutputParameters.AddGrowableCol(1) OutputParameters.Add(item=wx.StaticText( self, id=wx.ID_ANY, label=_("Name for the output raster map:")), flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 0)) self.OutputMapName = gselect.Select(parent=self, id=wx.ID_ANY, type='raster', mapsets=[grass.gisenv()['MAPSET']]) OutputParameters.Add(item=self.OutputMapName, flag=wx.EXPAND | wx.ALL, pos=(0, 1)) self.VarianceRasterCheckbox = wx.CheckBox( self, id=wx.ID_ANY, label=_("Export variance map as well: ")) self.VarianceRasterCheckbox.SetValue(state=True) OutputParameters.Add(item=self.VarianceRasterCheckbox, flag=wx.ALIGN_CENTER_VERTICAL, pos=(1, 0)) self.OutputVarianceMapName = gselect.Select( parent=self, id=wx.ID_ANY, type='raster', mapsets=[grass.gisenv()['MAPSET']]) self.VarianceRasterCheckbox.Bind(wx.EVT_CHECKBOX, self.OnVarianceCBChecked) OutputParameters.Add(item=self.OutputVarianceMapName, flag=wx.EXPAND | wx.ALL, pos=(1, 1)) self.OverwriteCheckBox = wx.CheckBox( self, id=wx.ID_ANY, label=_("Allow output files to overwrite existing files")) self.OverwriteCheckBox.SetValue( UserSettings.Get(group='cmd', key='overwrite', subkey='enabled')) OutputParameters.Add(item=self.OverwriteCheckBox, pos=(2, 0), span=(1, 2)) OutputSizer.Add(OutputParameters, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border) # 4. Run Button and Quit Button ButtonSizer = wx.BoxSizer(wx.HORIZONTAL) HelpButton = wx.Button(self, id=wx.ID_HELP) HelpButton.Bind(wx.EVT_BUTTON, self.OnHelpButton) QuitButton = wx.Button(self, id=wx.ID_EXIT) QuitButton.Bind(wx.EVT_BUTTON, self.OnCloseWindow) self.RunButton = wx.Button( self, id=wx.ID_ANY, label=_("&Run")) # no stock ID for Run button.. self.RunButton.Bind(wx.EVT_BUTTON, self.OnRunButton) self.RunButton.Enable( False ) # disable it on loading the interface, as input map is not set ButtonSizer.Add(HelpButton, proportion=0, flag=wx.ALIGN_LEFT | wx.ALL, border=self.border) ButtonSizer.Add(QuitButton, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border) ButtonSizer.Add(self.RunButton, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border) # Main Sizer. Add each child sizer as soon as it is ready. Sizer = wx.BoxSizer(wx.VERTICAL) Sizer.Add(InputBoxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border) Sizer.Add(KrigingSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.border) Sizer.Add(OutputSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=self.border) Sizer.Add(ButtonSizer, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=self.border) self.SetSizerAndFit(Sizer)