def __init__(self, parent, state): wx.PyScrolledWindow.__init__(self, parent) self.state = state self.img = None self.redraw_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer) self.Bind(wx.EVT_SET_FOCUS, self.on_focus) self.redraw_timer.Start(200) self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.mainSizer) # panel for the main image self.imagePanel = mp_widgets.ImagePanel(self, wx.EmptyImage(state.width,state.height)) self.mainSizer.Add(self.imagePanel, flag=wx.TOP|wx.LEFT|wx.GROW, border=5) for ev in state._events: self.imagePanel.Bind(ev, self.on_event) self.redraw() state.frame.Fit() self.SetScrollbars(1, 1, 100, 100)
def __init__(self, parent, state): wx.Panel.__init__(self, parent) self.state = state self.img = None self.map_img = None self.redraw_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer) self.Bind(wx.EVT_SET_FOCUS, self.on_focus) self.redraw_timer.Start(200) self.mouse_pos = None self.mouse_down = None self.click_pos = None self.last_click_pos = None if state.elevation: self.ElevationMap = mp_elevation.ElevationModel() self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.mainSizer) # start off with no follow checkbox self.follow_checkbox = None # display for lat/lon/elevation self.position = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY) if os.name == 'nt': self.position.SetValue("line 1\nline 2\n") size = self.position.GetBestSize() self.position.SetMinSize(size) self.position.SetValue("") else: textsize = tuple( self.position.GetFullTextExtent('line 1\nline 2\n')[0:2]) self.position.SetMinSize(textsize) self.mainSizer.AddSpacer(2) self.mainSizer.Add(self.position, flag=wx.LEFT | wx.BOTTOM | wx.GROW, border=0) self.position.Bind(wx.EVT_SET_FOCUS, self.on_focus) # a place to put control flags self.controls = wx.BoxSizer(wx.HORIZONTAL) self.mainSizer.Add(self.controls, 0, flag=wx.ALIGN_LEFT | wx.TOP | wx.GROW) self.mainSizer.AddSpacer(2) # a place to put information like image details self.information = wx.BoxSizer(wx.HORIZONTAL) self.mainSizer.Add(self.information, 0, flag=wx.ALIGN_LEFT | wx.TOP | wx.GROW) self.mainSizer.AddSpacer(2) # panel for the main map image self.imagePanel = mp_widgets.ImagePanel( self, wx.EmptyImage(state.width, state.height)) self.mainSizer.Add(self.imagePanel, flag=wx.GROW, border=5) self.imagePanel.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse) self.imagePanel.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self.imagePanel.Bind(wx.EVT_MOUSEWHEEL, self.on_mouse_wheel) # a function to convert from (lat,lon) to (px,py) on the map self.pixmapper = functools.partial(self.pixel_coords) self.last_view = None self.redraw_map() state.frame.Fit()
def draw(self, parent, box): '''redraw the image''' if self.imgpanel is None: self.imgpanel = mp_widgets.ImagePanel(parent, self.img()) box.Add(self.imgpanel, flag=wx.LEFT, border=0) box.Layout()