def __init__(self, city, population): self.city = city self.population = population self.app = wx.App(False) self.w = self.city.size + 100 self.h = self.city.size + 120 self.frame_rent = wx.Frame(None, -1, 'Rent Map', size=(self.w, self.h)) self.frame_income = wx.Frame(None, -1, 'Income Map', size=(self.w, self.h)) self.canvas_rent = FloatCanvas(self.frame_rent, -1) self.canvas_income = FloatCanvas(self.frame_income, -1)
def __init__(self, parent, input_image, image_ft, RMS_error): super().__init__(parent, title="Phase View") self._panel = wx.Panel(self) wx_img_real = _np_grey_img_to_wx_image(input_image) wx_img_fourier = _np_grey_img_to_wx_image(image_ft) self._canvas = FloatCanvas(self._panel, size=wx_img_real.GetSize()) self._real_bmp = self._canvas.AddBitmap(wx_img_real, (0, 0), Position="cc") self._fourier_bmp = self._canvas.AddBitmap(wx_img_fourier, (0, 0), Position="cc") # By default, show real and hide the fourier transform. self._fourier_bmp.Hide() save_btn = wx.ToggleButton(self._panel, label="Show Fourier") save_btn.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleFourier) rms_txt = wx.StaticText(self._panel, label="RMS difference: %.05f" % (RMS_error)) panel_sizer = wx.BoxSizer(wx.VERTICAL) panel_sizer.Add(self._canvas) bottom_sizer = wx.BoxSizer(wx.HORIZONTAL) bottom_sizer.Add(save_btn, wx.SizerFlags().Center().Border()) bottom_sizer.Add(rms_txt, wx.SizerFlags().Center().Border()) panel_sizer.Add(bottom_sizer) self._panel.SetSizer(panel_sizer) frame_sizer = wx.BoxSizer(wx.VERTICAL) frame_sizer.Add(self._panel) self.SetSizerAndFit(frame_sizer)
def __init__(self, world): self.world = world self.app = wx.PySimpleApp() self.w = 500 self.h = 500 self.frame = wx.Frame(None, -1, 'Ant Plot', size=(self.w, self.h)) self.canvas = FloatCanvas(self.frame, -1)
def __init__(self, builder=None, brick_size=(0.2, 0.05)): super(Designer, self).__init__(None) # config # self.builder = builder self.brick_size = brick_size # bind # self.Bind(wx.EVT_LISTBOX, self.on_listBox, self.listBox) self.Bind(wx.EVT_BUTTON, self.add_brick, self.button_add) self.Bind(wx.EVT_BUTTON, self.remove_brick, self.button_remove) self.Bind(wx.EVT_BUTTON, self.rotate_brick, self.button_rotate) self.Bind(wx.EVT_BUTTON, self.run, self.button_run) self.Bind(wx.EVT_BUTTON, self.load, self.button_load) self.Bind(wx.EVT_BUTTON, self.save, self.button_save) self.Bind(wx.EVT_TEXT_ENTER, self.update_brick, self.textBox_name) self.Bind(wx.EVT_TEXT_ENTER, self.update_input, self.textBox_X) self.Bind(wx.EVT_TEXT_ENTER, self.update_input, self.textBox_Y) self.Bind(wx.EVT_TEXT_ENTER, self.update_input, self.textBox_R) # Publisher().subscribe(self.on_msg, "update") # canvas # self.canvas = FloatCanvas(self.draw_panel, size=(600, 500), ProjectionFun=None, BackgroundColor="White") self.canvas.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse) self.refresh()
def __init__(self, parent): super(PaintPanel, self).__init__(parent=parent) self.network = Engine.Instance().network szr = wx.BoxSizer() self.canvas = FloatCanvas(parent=self) szr.Add(self.canvas, proportion=1, flag=wx.EXPAND) self.SetSizer(szr) self.Bind(wx.EVT_RIGHT_UP, Engine.Instance().OnRightClick) self.canvas.Bind(wx.EVT_RIGHT_UP, Engine.Instance().OnRightClick) # The following is called a lambda expression: # It allows us to define functions on-the-go. # It is no more than a function without definition. self.canvas.Bind( wx.EVT_LEFT_UP, lambda event, panel=self.canvas: self.OnLeftClick(event)) self.canvas.Bind(wx.EVT_PAINT, self.OnWindowBack)
def __init__(self, parent, input_image: np.ndarray, initial_roi, scale_factor=1) -> None: super().__init__(parent, title="ROI selector") self._panel = wx.Panel(self) self._img = _np_grey_img_to_wx_image(input_image) self._scale_factor = scale_factor # What, if anything, is being dragged. # XXX: When we require Python 3.8, annotate better with # `typing.Literal[None, "xy", "r"]` self._dragging: typing.Optional[str] = None # Canvas self.canvas = FloatCanvas(self._panel, size=self._img.GetSize()) self.canvas.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse) self.bitmap = self.canvas.AddBitmap(self._img, (0, 0), Position="cc") self.circle = self.canvas.AddCircle( self.canvas.PixelToWorld(initial_roi[:2]), initial_roi[2] * 2, LineColor="cyan", LineWidth=2, ) # Save button saveBtn = wx.Button(self._panel, label="Save ROI") saveBtn.Bind(wx.EVT_BUTTON, self.OnSave) panel_sizer = wx.BoxSizer(wx.VERTICAL) panel_sizer.Add(self.canvas) panel_sizer.Add(saveBtn, wx.SizerFlags().Border()) self._panel.SetSizer(panel_sizer) frame_sizer = wx.BoxSizer(wx.VERTICAL) frame_sizer.Add(self._panel) self.SetSizerAndFit(frame_sizer)