def make_gui_mouse(self, parent): """Build the mouse part of the controls part of GUI. parent reference to parent Returns reference to containing sizer object. """ # create objects txt = wx.StaticText(parent, wx.ID_ANY, 'Lon/Lat: ') self.mouse_position = ROTextCtrl(parent, '', size=(150, -1), tooltip=('Shows the mouse ' 'longitude and latitude ' 'on the map')) # lay out the controls sb = AppStaticBox(parent, 'Mouse position') box = wx.StaticBoxSizer(sb, orient=wx.HORIZONTAL) box.Add(txt, border=PackBorder, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT)) box.Add(self.mouse_position, proportion=1, border=PackBorder, flag=wx.RIGHT | wx.TOP | wx.BOTTOM) return box
def make_gui_level(self, parent): """Build the control that shows the level. parent reference to parent Returns reference to containing sizer object. """ # create objects txt = wx.StaticText(parent, wx.ID_ANY, 'Level: ') self.map_level = wx.StaticText(parent, wx.ID_ANY, ' ') # lay out the controls sb = AppStaticBox(parent, 'Map level') box = wx.StaticBoxSizer(sb, orient=wx.HORIZONTAL) box.Add(txt, border=PackBorder, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT)) box.Add(self.map_level, proportion=0, border=PackBorder, flag=wx.RIGHT | wx.TOP) return box
def __init__(self, parent, title, selectable=False, editable=False, **kwargs): """Initialise a LayerControl instance. parent reference to parent object title text to ahow in static box outline selectable True if 'selectable' checkbox is to be displayed editable True if layer can be edited **kwargs keyword args for Panel """ # create and initialise the base panel wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, **kwargs) self.SetBackgroundColour(wx.WHITE) self.selectable = selectable self.editable = editable box = AppStaticBox(self, title) sbs = wx.StaticBoxSizer(box, orient=wx.VERTICAL) gbs = wx.GridBagSizer(vgap=0, hgap=0) self.cbx_onoff = wx.CheckBox(self, wx.ID_ANY, label='Add layer') gbs.Add(self.cbx_onoff, (0, 0), span=(1, 4), border=PackBorder) self.cbx_show = wx.CheckBox(self, wx.ID_ANY, label='Show') gbs.Add(self.cbx_show, (1, 1), border=PackBorder) self.cbx_show.Disable() if selectable: self.cbx_select = wx.CheckBox(self, wx.ID_ANY, label='Select') gbs.Add(self.cbx_select, (1, 2), border=PackBorder) self.cbx_select.Disable() if editable: self.cbx_edit = wx.CheckBox(self, wx.ID_ANY, label='Edit') gbs.Add(self.cbx_edit, (1, 3), border=PackBorder) self.cbx_edit.Disable() sbs.Add(gbs) self.SetSizer(sbs) sbs.Fit(self) # tie handlers to change events self.cbx_onoff.Bind(wx.EVT_CHECKBOX, self.onChangeOnOff) self.cbx_show.Bind(wx.EVT_CHECKBOX, self.onChangeShowOnOff) if selectable: self.cbx_select.Bind(wx.EVT_CHECKBOX, self.onChangeSelectOnOff)
def make_gui_view(self, parent): """Build the map view widget parent reference to the widget parent Returns the static box sizer. """ # create gui objects sb = AppStaticBox(parent, '') self.pyslip = pyslip.pySlip(parent, tile_src=self.tile_source) # lay out objects box = wx.StaticBoxSizer(sb, orient=wx.HORIZONTAL) box.Add(self.pyslip, proportion=1, border=0, flag=wx.EXPAND) return box
def make_gui_level(self, parent): """Build the control that shows the level. parent reference to parent Returns reference to containing sizer object. """ # create objects txt = wx.StaticText(parent, wx.ID_ANY, 'Level: ') self.map_level = ROTextCtrl(parent, '', size=(30,-1), tooltip='Shows map zoom level') # lay out the controls sb = AppStaticBox(parent, 'Map level') box = wx.StaticBoxSizer(sb, orient=wx.HORIZONTAL) box.Add(txt, flag=(wx.ALIGN_CENTER_VERTICAL |wx.LEFT)) box.Add(self.map_level, proportion=0, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) return box
def __init__(self, parent, title, text='', font=DefaultFont, fontsize=DefaultFontSize, textcolour=DefaultTextColour, pointradius=DefaultPointRadius, pointcolour=DefaultPointColour, placement=DefaultPlacement, x=0, y=0, offset_x=0, offset_y=0, **kwargs): """Initialise a LayerControl instance. parent reference to parent object title text to show in static box outline around control text text to show font font of text fontsize size of text font textcolour colour of text pointradius radius of text point (not drawn if 0) pointcolour colour of text point placement placement string for text x, y X and Y coords offset_x X offset of text offset_y Y offset of text **kwargs keyword args for Panel """ # save parameters self.v_text = text self.v_font = font self.v_fontsize = str(fontsize) self.v_textcolour = textcolour self.v_pointradius = str(pointradius) self.v_pointcolour = pointcolour self.v_placement = placement self.v_x = x self.v_y = y self.v_offset_x = offset_x self.v_offset_y = offset_y # create and initialise the base panel wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, **kwargs) self.SetBackgroundColour(wx.WHITE) # create the widget box = AppStaticBox(self, title) sbs = wx.StaticBoxSizer(box, orient=wx.VERTICAL) gbs = wx.GridBagSizer(vgap=2, hgap=2) # row 0 row = 0 gbs.Add(1, 3, (row, 0)) label = wx.StaticText(self, wx.ID_ANY, 'text: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.text = wx.TextCtrl(self, value=self.v_text) gbs.Add(self.text, (row, 2), span=(1, 3), border=0, flag=wx.EXPAND) gbs.Add(1, 3, (row, 5)) # row 1 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'font: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) style = wx.CB_DROPDOWN | wx.CB_READONLY self.font = wx.ComboBox(self, value=self.v_font, choices=FontChoices, style=style) gbs.Add(self.font, (row, 2), span=(1, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) # row 2 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'font size: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) style = wx.CB_DROPDOWN | wx.CB_READONLY self.fontsize = wx.ComboBox(self, value=self.v_fontsize, choices=FontsizeChoices, style=style) gbs.Add(self.fontsize, (row, 2), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) label = wx.StaticText(self, wx.ID_ANY, 'text colour: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.textcolour = wx.Button(self, label='') self.textcolour.SetBackgroundColour(self.v_textcolour) gbs.Add(self.textcolour, (row, 4), border=0, flag=wx.EXPAND) # row 3 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'point radius: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) style = wx.CB_DROPDOWN | wx.CB_READONLY self.pointradius = wx.ComboBox(self, value=self.v_pointradius, choices=PointRadiusChoices, style=style) gbs.Add(self.pointradius, (row, 2), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) label = wx.StaticText(self, wx.ID_ANY, 'point colour: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.pointcolour = wx.Button(self, label='') self.pointcolour.SetBackgroundColour(self.v_pointcolour) gbs.Add(self.pointcolour, (row, 4), border=0, flag=wx.EXPAND) # row 4 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'placement: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) choices = [ 'nw', 'cn', 'ne', 'ce', 'se', 'cs', 'sw', 'cw', 'cc', 'none' ] style = wx.CB_DROPDOWN | wx.CB_READONLY self.placement = wx.ComboBox(self, value=self.v_placement, choices=choices, style=style) gbs.Add(self.placement, (row, 2), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) # row 5 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'x: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.x = wx.TextCtrl(self, value=str(self.v_x)) gbs.Add(self.x, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, 'y: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.y = wx.TextCtrl(self, value=str(self.v_y)) gbs.Add(self.y, (row, 4), border=0, flag=wx.EXPAND) # row 6 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'offset_x: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_x = wx.TextCtrl(self, value=str(self.v_offset_x)) gbs.Add(self.offset_x, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, ' offset_y: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_y = wx.TextCtrl(self, value=str(self.v_offset_y)) gbs.Add(self.offset_y, (row, 4), border=0, flag=wx.EXPAND) # row 7 row += 1 delete_button = wx.Button(self, label='Remove') gbs.Add(delete_button, (row, 2), border=10, flag=wx.EXPAND) update_button = wx.Button(self, label='Update') gbs.Add(update_button, (row, 4), border=10, flag=wx.EXPAND) sbs.Add(gbs) self.SetSizer(sbs) sbs.Fit(self) self.textcolour.Bind(wx.EVT_BUTTON, self.onTextColour) self.pointcolour.Bind(wx.EVT_BUTTON, self.onPointColour) delete_button.Bind(wx.EVT_BUTTON, self.onDelete) update_button.Bind(wx.EVT_BUTTON, self.onUpdate) # row 8 - spacer row += 1 gbs.Add(3, 1, (row, 0))
def __init__(self, parent, title, filename='', placement=DefaultPlacement, pointradius=DefaultPointRadius, pointcolour=DefaultPointColour, x=0, y=0, offset_x=0, offset_y=0, **kwargs): """Initialise a LayerControl instance. parent reference to parent object title text to show in static box outline filename filename of image to show placement placement string for image pointradius radius of the image point pointcolour colour of the image point x, y X and Y coords offset_x X offset of image offset_y Y offset of image **kwargs keyword args for Panel """ # create and initialise the base panel wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, **kwargs) self.SetBackgroundColour(wx.WHITE) self.v_filename = filename self.v_placement = placement self.v_pointradius = str(pointradius) self.v_pointcolour = pointcolour self.v_x = x self.v_y = y self.v_offset_x = offset_x self.v_offset_y = offset_y box = AppStaticBox(self, title) sbs = wx.StaticBoxSizer(box, orient=wx.VERTICAL) gbs = wx.GridBagSizer(vgap=10, hgap=10) # row 0 row = 0 gbs.Add(3, 1, (row, 0)) label = wx.StaticText(self, wx.ID_ANY, 'filename: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.filename = ROTextCtrl(self, self.v_filename) gbs.Add(self.filename, (row, 2), span=(1, 3), border=0, flag=wx.EXPAND) gbs.Add(3, 1, (row, 5)) # row 1 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'placement: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) choices = [ 'nw', 'cn', 'ne', 'ce', 'se', 'cs', 'sw', 'cw', 'cc', 'none' ] style = wx.CB_DROPDOWN | wx.CB_READONLY self.placement = wx.ComboBox(self, value=self.v_placement, choices=choices, style=style) gbs.Add(self.placement, (row, 2), border=0) # row 2 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'point radius: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) style = wx.CB_DROPDOWN | wx.CB_READONLY self.pointradius = wx.ComboBox(self, value=self.v_pointradius, choices=PointRadiusChoices, style=style) gbs.Add(self.pointradius, (row, 2), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) label = wx.StaticText(self, wx.ID_ANY, 'point colour: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.pointcolour = wx.Button(self, label='') self.pointcolour.SetBackgroundColour(self.v_pointcolour) gbs.Add(self.pointcolour, (row, 4), border=0, flag=wx.EXPAND) # row 3 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'x: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.x = wx.TextCtrl(self, value=str(self.v_x)) gbs.Add(self.x, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, 'y: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.y = wx.TextCtrl(self, value=str(self.v_y)) gbs.Add(self.y, (row, 4), border=0, flag=wx.EXPAND) # row 4 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'offset_x: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_x = wx.TextCtrl(self, value=str(self.v_offset_x)) gbs.Add(self.offset_x, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, ' offset_y: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_y = wx.TextCtrl(self, value=str(self.v_offset_y)) gbs.Add(self.offset_y, (row, 4), border=0, flag=wx.EXPAND) # row 5 row += 1 delete_button = wx.Button(self, label='Remove') gbs.Add(delete_button, (row, 2), border=10, flag=wx.EXPAND) update_button = wx.Button(self, label='Update') gbs.Add(update_button, (row, 4), border=10, flag=wx.EXPAND) sbs.Add(gbs) self.SetSizer(sbs) sbs.Fit(self) # row 6 (just a spacer) row += 1 gbs.Add(1, 3, (row, 0)) # bind events to handlers self.filename.Bind(wx.EVT_LEFT_UP, self.onFilename) self.pointcolour.Bind(wx.EVT_BUTTON, self.onPointColour) delete_button.Bind(wx.EVT_BUTTON, self.onDelete) update_button.Bind(wx.EVT_BUTTON, self.onUpdate)
def __init__(self, parent, title, placement=DefaultPlacement, width=DefaultWidth, closed=DefaultClosed, filled=DefaultFilled, colour=DefaultColour, fillcolour=DefaultFillColour, offset_x=0, offset_y=0, **kwargs): """Initialise a LayerControl instance. parent reference to parent object title text to show in static box outline around control placement placement string for object width width in pixels of the drawn polygon colour sets the colour of the polygon outline closed True if the polygon is to be forcibly closed filled True if the polygon is to be filled fillcolour the colour to fill the polygon with (if filled is True) offset_x X offset of object offset_y Y offset of object **kwargs keyword args for Panel """ # save parameters self.v_placement = placement self.v_width = width self.v_colour = colour self.v_closed = closed self.v_filled = filled self.v_fillcolour = fillcolour self.v_offset_x = offset_x self.v_offset_y = offset_y # create and initialise the base panel wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, **kwargs) self.SetBackgroundColour(wx.WHITE) # create the widget box = AppStaticBox(self, title) sbs = wx.StaticBoxSizer(box, orient=wx.VERTICAL) gbs = wx.GridBagSizer(vgap=2, hgap=2) # row 0 row = 0 gbs.Add(3, 1, (row, 0)) label = wx.StaticText(self, wx.ID_ANY, 'placement: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) choices = [ 'nw', 'cn', 'ne', 'ce', 'se', 'cs', 'sw', 'cw', 'cc', 'none' ] style = wx.CB_DROPDOWN | wx.CB_READONLY self.placement = wx.ComboBox(self, value=self.v_placement, choices=choices, style=style) gbs.Add(self.placement, (row, 2), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) label = wx.StaticText(self, wx.ID_ANY, 'width: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) choices = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] style = wx.CB_DROPDOWN | wx.CB_READONLY self.width = wx.ComboBox(self, value=self.v_width, choices=choices, style=style) gbs.Add(self.width, (row, 4), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)) gbs.Add(3, 1, (row, 5)) # row 1 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'colour: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.polycolour = wx.Button(self, label='') self.polycolour.SetBackgroundColour(self.v_colour) gbs.Add(self.polycolour, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, 'fillcolour: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.fillcolour = wx.Button(self, label='') self.fillcolour.SetBackgroundColour(self.v_fillcolour) gbs.Add(self.fillcolour, (row, 4), border=0, flag=wx.EXPAND) # row 2 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'closed: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.closed = wx.CheckBox(self, label='') self.closed.SetValue(self.v_closed) gbs.Add(self.closed, (row, 2), border=0) label = wx.StaticText(self, wx.ID_ANY, 'filled: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.filled = wx.CheckBox(self, label='') self.filled.SetValue(self.v_filled) gbs.Add(self.filled, (row, 4), border=0) # row 3 row += 1 label = wx.StaticText(self, wx.ID_ANY, 'offset_x: ') gbs.Add(label, (row, 1), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_x = wx.TextCtrl(self, value=str(self.v_offset_x)) gbs.Add(self.offset_x, (row, 2), border=0, flag=wx.EXPAND) label = wx.StaticText(self, wx.ID_ANY, ' offset_y: ') gbs.Add(label, (row, 3), border=0, flag=(wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)) self.offset_y = wx.TextCtrl(self, value=str(self.v_offset_y)) gbs.Add(self.offset_y, (row, 4), border=0, flag=wx.EXPAND) # row 4 row += 1 delete_button = wx.Button(self, label='Remove') gbs.Add(delete_button, (row, 2), border=10, flag=wx.EXPAND) update_button = wx.Button(self, label='Update') gbs.Add(update_button, (row, 4), border=10, flag=wx.EXPAND) sbs.Add(gbs) self.SetSizer(sbs) sbs.Fit(self) self.polycolour.Bind(wx.EVT_BUTTON, self.onPolyColour) self.fillcolour.Bind(wx.EVT_BUTTON, self.onFillColour) delete_button.Bind(wx.EVT_BUTTON, self.onDelete) update_button.Bind(wx.EVT_BUTTON, self.onUpdate) # row 5 - spacer row += 1 gbs.Add(1, 3, (row, 0))