def generate(self): """Creates the UI""" self.sizer = wx.BoxSizer(wx.VERTICAL) logo = self.get_bmp() if logo is not None: self.bitmap_logo = statbmp.GenStaticBitmap(self, wx.ID_ANY, logo, style=wx.ALIGN_CENTRE, size=(logo.GetWidth(), logo.GetHeight())) if self.url is not None: self.bitmap_logo.SetToolTipString("Visit {0}".format(self.url)) self.bitmap_logo.Bind(wx.EVT_LEFT_DOWN, self.on_click, self.bitmap_logo) self.sizer.Add(self.bitmap_logo, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, ui_defaults.widget_margin) if self.msg is not None: dc = wx.ClientDC(self) if logo is not None: wrap_width = logo.GetWidth() if sys.platform == 'win32': wrap_width *= 1.3 else: wrap_width = self.GetClientSizeTuple()[0] self.msg = wordwrap.wordwrap(textwrap.dedent(self.msg), wrap_width, dc) self.msg_lbl = wx.StaticText(self, wx.ID_ANY, self.msg, pos=wx.DefaultPosition, size=wx.DefaultSize) self.sizer.Add(self.msg_lbl, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) self.SetSizerAndFit(self.sizer) self.Centre()
def display_cover(self, wx_image): """Resize and display cover image Args: wx_image (wx.Image object): local image file turned into a wx.Image object """ if wx_image: self.image = wx_image panel_dimensions = self.GetSize() bitmap = wx.Bitmap(self.image) scaled_bitmap = self.scale_image(bitmap, panel_dimensions) if self.ImgCover: self.ImgCover.Destroy() self.ImgCover = statbmp.GenStaticBitmap(self, wx.ID_ANY, scaled_bitmap) self.ImgCover.Center() else: # Reset info panel when deleting library item if self.ImgCover: self.ImgCover.Destroy()
def __show_exported_parts(self, parts_list=None): self.clear() for part_def in parts_list: fname, part, tt_header, tt_footer = part_def #_log.debug(tt_header) #_log.debug(tt_footer) img = gmGuiHelpers.file2scaled_image(filename=fname, height=30) bmp = wx_genstatbmp.GenStaticBitmap(self, -1, img, style=wx.NO_BORDER) bmp.doc_part = part img = gmGuiHelpers.file2scaled_image(filename=fname, height=150) tip = agw_stt.SuperToolTip('', bodyImage=img, header=tt_header, footer=tt_footer) tip.SetTopGradientColor('white') tip.SetMiddleGradientColor('white') tip.SetBottomGradientColor('white') tip.SetTarget(bmp) bmp.Bind(wx.EVT_LEFT_UP, self._on_bitmap_leftclicked) # FIXME: add context menu for Delete/Clone/Add/Configure self._SZR_soap.Add( bmp, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM | wx.EXPAND, 3) self.__bitmaps.append(bmp) self.GetParent().Layout()
def __init__(self): wx.Frame.__init__(self, None, -1, 'Quad #1:4') bmp14 = AffExpMaps.getbmp14Bitmap() self.Image = statbmp.GenStaticBitmap(self, wx.ID_ANY, bmp14) self.Image.Bind(wx.EVT_LEFT_DOWN, self.OnClick) S = wx.BoxSizer(wx.VERTICAL) S.Add(self.Image, 0) self.SetSizerAndFit(S)
def on_resize(self): bitmap = wx.Bitmap("default.png") dimensions = self.GetSize() bitmap = self.scale_image(bitmap, dimensions) self.Profile = statbmp.GenStaticBitmap(self, wx.ID_ANY, bitmap) self.Profile.Center()
def on_resize(self, event): if self.image: dimensions = event.GetSize() bitmap = wx.Bitmap(self.image) bitmap = self.scale_image(bitmap, dimensions) self.ImgCover = statbmp.GenStaticBitmap(self, wx.ID_ANY, bitmap) self.ImgCover.Center()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) bmp = wx.Bitmap("Images/medtest.jpg") self.Image = statbmp.GenStaticBitmap(self, wx.ID_ANY, bmp) self.Image.Bind(wx.EVT_LEFT_DOWN, self.OnClick) S = wx.BoxSizer(wx.VERTICAL) S.Add(self.Image, 0) self.SetSizerAndFit(S)
def refresh(self, document_folder=None, episodes=None, encounter=None): self.clear() if document_folder is None: self.GetParent().Layout() return soap_docs = document_folder.get_visual_progress_notes( episodes=episodes, encounter=encounter) if len(soap_docs) == 0: self.GetParent().Layout() return for soap_doc in soap_docs: parts = soap_doc.parts if len(parts) == 0: continue parts_str = u'' if len(parts) > 1: parts_str = _(' [part 1 of %s]') % len(parts) part = parts[0] fname = part.export_to_file() if fname is None: continue # create bitmap img = gmGuiHelpers.file2scaled_image(filename=fname, height=30) bmp = wx_genstatbmp.GenStaticBitmap(self, -1, img, style=wx.NO_BORDER) # create tooltip img = gmGuiHelpers.file2scaled_image(filename=fname, height=150) tip = agw_stt.SuperToolTip( u'', bodyImage=img, header=_('Created: %s%s') % (gmDateTime.pydt_strftime( part['date_generated'], '%Y %b %d'), parts_str), footer=gmTools.coalesce(part['doc_comment'], u'').strip()) tip.SetTopGradientColor('white') tip.SetMiddleGradientColor('white') tip.SetBottomGradientColor('white') tip.SetTarget(bmp) bmp.doc_part = part bmp.Bind(wx.EVT_LEFT_UP, self._on_bitmap_leftclicked) # FIXME: add context menu for Delete/Clone/Add/Configure self._SZR_soap.Add( bmp, 0, wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM | wx.EXPAND, 3) self.__bitmaps.append(bmp) self.GetParent().Layout()
def init_ui(self): """Initializes and lays out the UI""" self.sizer = wx.BoxSizer(wx.VERTICAL) self.main_panel = wx.Panel(self) self.main_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) glyph_fn = os.path.join(pathfinder.bitmap_path(), "axis_glyph_sm.png") glyph = wx.Bitmap(glyph_fn, type=wx.BITMAP_TYPE_PNG) glyph_ctrl = statbmp.GenStaticBitmap(self.main_panel, wx.ID_ANY, glyph, style=wx.ALIGN_CENTRE_VERTICAL, size=(glyph.GetWidth(), glyph.GetHeight())) self.main_panel_sizer.Add(glyph_ctrl, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) ctrl_panel = wx.Panel(self.main_panel) ctrl_panel_sizer = wx.BoxSizer(wx.VERTICAL) instructions_txt = '\n'.join(['To continue, please specify a plane in the 3-D data.', 'A plane is defined by an orientation and an index', 'into the data. Orientation determines which direction', 'the slice is made, and the index specifies where in', 'the remaining axis the slice is made.']) instructions_lbl = wx.StaticText(ctrl_panel, wx.ID_ANY, instructions_txt) ctrl_panel_sizer.Add(instructions_lbl, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) orientation_panel = wx.Panel(ctrl_panel) orientation_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) orientation_lbl = wx.StaticText(orientation_panel, wx.ID_ANY, "Orientation") orientation_panel_sizer.Add(orientation_lbl, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) self.plane_choice = wx.Choice(orientation_panel, wx.ID_ANY, choices=self.planes) orientation_panel_sizer.Add(self.plane_choice, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, ui_defaults.widget_margin) orientation_panel.SetSizerAndFit(orientation_panel_sizer) ctrl_panel_sizer.Add(orientation_panel, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, 0) idx_panel = wx.Panel(ctrl_panel) idx_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) idx_lbl = wx.StaticText(idx_panel, wx.ID_ANY, "Index") idx_panel_sizer.Add(idx_lbl, ui_defaults.ctrl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) self.idx_sc = wx.SpinCtrl(idx_panel, wx.ID_ANY) idx_panel_sizer.Add(self.idx_sc, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, ui_defaults.widget_margin) idx_panel.SetSizerAndFit(idx_panel_sizer) self.Bind(wx.EVT_CHOICE, self.on_orientation_change, self.plane_choice) self.plane_choice.SetSelection(0) self.set_index_limits() ctrl_panel_sizer.Add(idx_panel, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, 0) ctrl_panel.SetSizerAndFit(ctrl_panel_sizer) self.main_panel_sizer.Add(ctrl_panel, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, 0) self.main_panel.SetSizer(self.main_panel_sizer) self.sizer.Add(self.main_panel, 1, ui_defaults.sizer_flags, 0) self._generate_std_buttons() self.SetSizerAndFit(self.sizer)
def __init__(self, client, frame, username, call_name, client_manage, fps=15): wx.Frame.__init__(self, None) print("got to show capture in final peula") panel = wx.Panel(self, PANEL) self.client = client self.client_manage = client_manage self.frame = frame self.username = username self.call_name = call_name # create a grid sizer with 5 pix between each cell sizer = wx.GridBagSizer(GRID, GRID) height, width = self.frame.shape[:DIVIDE] self.orig_height = height self.orig_width = width self.bmp = wx.Bitmap.FromBuffer(width, height, self.frame) btn_sizer = wx.BoxSizer(wx.HORIZONTAL) end_btn = wx.Button(panel, -1, 'End Call') end_btn.Bind(wx.EVT_BUTTON, self.end_button) btn_sizer.Add(end_btn, 0) # create image display widgets self.ImgControl = statbmp.GenStaticBitmap(panel, wx.ID_ANY, self.bmp) # add widgets to the sizer grid sizer.Add(btn_sizer, (0, 7), wx.DefaultSpan, wx.EXPAND | wx.CENTER, wx.ALIGN_CENTER) # sizer.Add(self.ImgControl, # (3, 0), (1, 4), wx.EXPAND | wx.CENTER | wx.LEFT | wx.BOTTOM, GRID) sizer.Add(self.ImgControl, (3, 0), (1, 4), wx.EXPAND | wx.CENTER, GRID) # set the sizer and tell the Frame about the best size panel.SetSizer(sizer) sizer.SetSizeHints(self) panel.Layout() panel.SetFocus() self.timer = wx.Timer(self) self.fps = fps self.timer.Start(TIMER/self.fps) # bind timer events to the handler self.Bind(wx.EVT_TIMER, self.next_frame)
def __init__(self, capture, fps=15): wx.Frame.__init__(self, None) panel = wx.Panel(self, -1) #create a grid sizer with 5 pix between each cell sizer = wx.GridBagSizer(5, 5) self.capture = capture ret, frame = self.capture.read() height, width = frame.shape[:2] self.orig_height = height self.orig_width = width frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) self.bmp = wx.BitmapFromBuffer(width, height, frame) #self.dummy_element = wx.TextCtrl(panel, -1, '') #self.dummy_element.Hide() #create image display widgets self.ImgControl = statbmp.GenStaticBitmap(panel, wx.ID_ANY, self.bmp) #add image widgets to the sizer grid sizer.Add(self.ImgControl, (3, 0), (1, 4), wx.EXPAND | wx.CENTER | wx.LEFT | wx.BOTTOM, 5) #set the sizer and tell the Frame about the best size panel.SetSizer(sizer) sizer.SetSizeHints(self) panel.Layout() panel.SetFocus() #start a timer that's handler grabs a new frame and updates the image widgets self.timer = wx.Timer(self) self.fps = fps self.timer.Start(1000. / self.fps) #bind timer events to the handler self.Bind(wx.EVT_TIMER, self.NextFrame)
def __init__(self, capture, title, fps=30): wx.Frame.__init__( self, None, -1, title, size=(1350, 745), style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX)) panel = wx.Panel(self, -1) self.SetBackgroundColour((255, 255, 255)) self.tamanoMatriz = 16 self.sincronizacionAnterior = [[255, 255, 255], [255, 255, 255], [255, 255, 255]] self.capture = capture self.numColores = 8 ret, frame = self.capture.read() height, width = frame.shape[:2] self.orig_height = height self.orig_width = width frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) self.bmp = wx.Bitmap.FromBuffer(width, height, frame) self.tramasRecibidas = np.array([], dtype=int) self.cargaUtil = [] self.datos = np.array([], dtype=int) self.frames = [] self.cont = 0 #create image display widgets self.ImgControl = statbmp.GenStaticBitmap(panel, wx.ID_ANY, self.bmp) self.timer = wx.Timer(self) self.fps = fps self.timer.Start(1000. / self.fps) segundos = 5 hilo = threading.Thread(target=self.NextFrame, args=(segundos, )) #self.Bind(wx.EVT_TIMER, hilo.start()) hilo.start() patrones_segundo = [ ComboBoxGeneral(15, "15"), ComboBoxGeneral(30, "30") ] dimensiones = [ ComboBoxGeneral(8, "8"), ComboBoxGeneral(10, "10"), ComboBoxGeneral(12, "12"), ComboBoxGeneral(14, "14"), ComboBoxGeneral(16, "16") ] colores = [ ComboBoxGeneral(2, "2"), ComboBoxGeneral(4, "4"), ComboBoxGeneral(8, "8") ] sampleList = [] font = wx.Font(12, wx.ROMAN, wx.NORMAL, wx.NORMAL) # Textos de combobox lbl = wx.StaticText(panel, -1, style=wx.ALIGN_CENTER) txt1 = "Número de patrones por segundo" lb2 = wx.StaticText(panel, -1, style=wx.ALIGN_CENTER) txt2 = "Tamaño" lb3 = wx.StaticText(panel, -1, style=wx.ALIGN_CENTER) txt3 = "Número de colores" button = wx.Button(panel, wx.ID_ANY, 'Comenzar captura', (20, 400)) #bind timer events to the handler button.Bind(wx.EVT_BUTTON, Camara.onButton) button1 = wx.Button(panel, wx.ID_ANY, 'Parar captura', (150, 400)) button1.Bind(wx.EVT_BUTTON, Camara.onButton) lbl.SetFont(font) lbl.SetLabel(txt1) lb2.SetFont(font) lb2.SetLabel(txt2) lb3.SetFont(font) lb3.SetLabel(txt3) self.cb = wx.ComboBox(panel, -1, size=(150, 100), choices=sampleList) self.cb1 = wx.ComboBox(panel, -1, size=(150, 100), choices=sampleList) self.cb2 = wx.ComboBox(panel, -1, size=(150, 100), choices=sampleList) self.widgetMaker(self.cb, patrones_segundo, self.onSelectFrecuencia) self.widgetMaker(self.cb1, dimensiones, self.onSelectTamano) self.widgetMaker(self.cb2, colores, self.onSelectColores) sizer2 = wx.BoxSizer(wx.HORIZONTAL) #add image widgets to the sizer grid sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(lbl, 0, wx.ALIGN_LEFT | wx.LEFT, 25) sizer.Add(self.cb, 0, wx.LEFT | wx.ALIGN_LEFT, 20) sizer.Add(lb2, 0, wx.ALIGN_LEFT | wx.LEFT, 25) sizer.Add(self.cb1, 0, wx.LEFT | wx.ALIGN_LEFT, 20) sizer.Add(lb3, 0, wx.ALIGN_LEFT | wx.LEFT, 25) sizer.Add(self.cb2, 0, wx.LEFT | wx.ALIGN_LEFT, 20) sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(self.ImgControl, 0, wx.LEFT | wx.ALIGN_RIGHT, 100) sizer3 = wx.BoxSizer(wx.VERTICAL) lb4 = wx.StaticText(panel, -1, style=wx.ALIGN_CENTER) txt4 = "FER" lb5 = wx.StaticText(panel, -1, style=wx.ALIGN_CENTER) txt5 = "BER" lb4.SetFont(font) lb4.SetLabel(txt4) lb5.SetFont(font) lb5.SetLabel(txt5) sizer3.Add(lb4, 0, wx.ALIGN_LEFT | wx.LEFT, 25) sizer3.Add(lb5, 0, wx.ALIGN_LEFT | wx.LEFT, 25) sizer2.Add(sizer, 0, wx.EXPAND) sizer2.Add(sizer1, 0, wx.EXPAND) sizer2.Add(sizer3, 0, wx.EXPAND) panel.SetSizer(sizer2)
def __init__(self, capture, fps=15): wx.Frame.__init__(self, None) panel = wx.Panel(self, -1) # create a grid sizer with 5 pix between each cell sizer = wx.GridBagSizer(5, 5) self.capture = capture ret, frame = self.capture.read() height, width = frame.shape[:2] self.orig_height = height self.orig_width = width frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) self.bmp = wx.BitmapFromBuffer(width, height, frame) self.dummy_element = wx.TextCtrl(panel, -1, '') self.dummy_element.Hide() # create SpinCtrl widgets, these have vertical up/down buttons and a TextCtrl that increments with up/down press self.roi_x = wx.SpinCtrl(panel, -1, "ROI X", style=wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS, min=0, max=width, initial=0, size=(60, -1)) self.roi_y = wx.SpinCtrl(panel, -1, "ROI Y", style=wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS, min=0, max=height, initial=0, size=(60, -1)) self.roi_width = wx.SpinCtrl(panel, -1, "ROI W", style=wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS, min=0, max=width, initial=width, size=(60, -1)) self.roi_height = wx.SpinCtrl(panel, -1, "ROI H", style=wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS, min=0, max=height, initial=height, size=(60, -1)) save_bmp_path = os.path.join(os.path.dirname(__file__), 'icons', 'ic_action_save.png') if os.path.isfile(save_bmp_path): save_bmp = wx.Image(save_bmp_path).ConvertToBitmap() save_button = wx.BitmapButton(panel, wx.ID_ANY, bitmap=save_bmp, style=wx.NO_BORDER, size=(32, 32)) # ) else: save_button = wx.Button(panel, -1, 'Save') settings_bmp_path = os.path.join(os.path.dirname(__file__), 'icons', 'ic_action_settings.png') if os.path.isfile(settings_bmp_path): settings_bmp = wx.Image(settings_bmp_path).ConvertToBitmap() settings_button = wx.BitmapButton(panel, wx.ID_ANY, bitmap=settings_bmp, style=wx.NO_BORDER, size=(32, 32)) # ) else: settings_button = wx.Button(panel, -1, 'Settings') # create image display widgets self.ImgControl = statbmp.GenStaticBitmap(panel, wx.ID_ANY, self.bmp) self.ImgControl2 = statbmp.GenStaticBitmap(panel, wx.ID_ANY, self.bmp) # add text to the sizer grid sizer.Add(wx.StaticText(panel, -1, 'ROI'), (0, 0), (1, 2), wx.ALL, 5) sizer.Add(wx.StaticText(panel, -1, 'X'), (1, 0), wx.DefaultSpan, wx.ALL, 5) sizer.Add(wx.StaticText(panel, -1, 'Y'), (2, 0), wx.DefaultSpan, wx.ALL, 5) sizer.Add(wx.StaticText(panel, -1, 'width,'), (1, 2), wx.DefaultSpan, wx.ALL, 5) sizer.Add(wx.StaticText(panel, -1, 'height'), (2, 2), wx.DefaultSpan, wx.ALL, 5) sizer.Add(wx.StaticText(panel, -1, 'Right-click image to reset ROI'), (2, 4), wx.DefaultSpan, wx.ALL, 5) tool_button_sizer = wx.BoxSizer(wx.HORIZONTAL) tool_button_sizer.Add(save_button, 0) tool_button_sizer.Add(settings_button, 0) # sizer.Add(, (0, 6), wx.DefaultSpan, wx.ALIGN_RIGHT)#, wx.ALL, 5) sizer.Add(tool_button_sizer, (0, 7), wx.DefaultSpan, wx.ALIGN_RIGHT) # , wx.ALL, 5) # add SpinCtrl widgets to the sizer grid sizer.Add(self.roi_x, (1, 1), wx.DefaultSpan, wx.ALL, 5) sizer.Add(self.roi_y, (2, 1), wx.DefaultSpan, wx.ALL, 5) sizer.Add(self.roi_width, (1, 3), wx.DefaultSpan, wx.ALL, 5) sizer.Add(self.roi_height, (2, 3), wx.DefaultSpan, wx.ALL, 5) # add image widgets to the sizer grid sizer.Add(self.ImgControl, (3, 0), (1, 4), wx.EXPAND | wx.CENTER | wx.LEFT | wx.BOTTOM, 5) sizer.Add(self.ImgControl2, (3, 4), (1, 4), wx.EXPAND | wx.CENTER | wx.RIGHT | wx.BOTTOM, 5) # set the sizer and tell the Frame about the best size panel.SetSizer(sizer) sizer.SetSizeHints(self) panel.Layout() panel.SetFocus() # start a timer that's handler grabs a new frame and updates the image widgets self.timer = wx.Timer(self) self.fps = fps self.timer.Start(1000. / self.fps) # bind timer events to the handler self.Bind(wx.EVT_TIMER, self.NextFrame) # bind events to ROI image widget self.ImgControl2.Bind(wx.EVT_LEFT_DOWN, self.On_ROI_Click) self.ImgControl2.Bind(wx.EVT_LEFT_UP, self.On_ROI_ClickRelease) self.ImgControl2.Bind(wx.EVT_RIGHT_DOWN, self.On_ROI_RightClick) self.ImgControl2.Bind(wx.EVT_MOTION, self.On_ROI_Hover) self.ImgControl2.Bind(wx.EVT_ENTER_WINDOW, self.On_ROI_mouse_enter) self.ImgControl2.Bind(wx.EVT_LEAVE_WINDOW, self.On_ROI_mouse_leave) # bind save button save_button.Bind(wx.EVT_BUTTON, self.on_save_click) save_button.Bind(wx.EVT_RIGHT_DOWN, self.on_quick_save) # bind settings button settings_button.Bind(wx.EVT_BUTTON, self.on_settings_click) settings_button.Bind(wx.EVT_LEFT_UP, self.on_settings_click_release)
def __init__(self): """ Create the main frame, deriving from a baseline object which has all the panels, buttons, etc. already defined. """ # initialise the underlying object ROVguiBaseClasses.mainFrame.__init__(self, None) # set-up own fields self.freqArduino = 100 # default refresh rate for the Arduino in Hz # video feed self.freqVideo = 15 # frame rate update frquency self.HUDcolour = (0, 255, 0) # RGB colour of the overlay on the HUD self.feedOn = False # switch indicating whether the video feed is on or off self.cameraIndex = 1 # index of the potential candidates for OpenCV capture object to actually use self.cameraCapture = 0 # this will hold the OpenCV VideocameraCapture object once it gets initialised # serial communication self.portOpen = False # indicates if the serial communication port is open self.currentPort = 'None' # currently chosen port self.arduinoSerialConnection = 0 # holds the serial connecion object once it has been initialised self.freqSensorReadings = 5 self.freqControlInputs = 5 # create the internal bitmap object by using an empty bitmap, this will be projected onto the panel self.bmp = wx.EmptyBitmap(400, 300) self.videoFeed = statbmp.GenStaticBitmap(self.videoFeedPanel, wx.ID_ANY, self.bmp) # add to the panel and resize to fit everything self.videoFeedPanel.GetSizer().Add( self.videoFeed, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.videoFeedPanel.Layout() self.videoFeedPanel.SetFocus() # initialise the timing functions - will send and receive the data to/from Arduino at a specific interval self.frameTimer.Start(int(1.0 / self.freqVideo * 1000.0)) self.sensorReadingsTimer.Start( int(1.0 / self.freqSensorReadings * 1000.0)) self.controlInputTimer.Start(int(1.0 / self.freqControlInputs * 1000.0)) # initialise throttle indicators self.throttleDial_portHor = throttleDial.Throttle( self.throttleDial_portHor, -1, sizeTuple=(40, 115)) self.throttleDial_portVer = throttleDial.Throttle( self.throttleDial_portVer, -1, sizeTuple=(40, 115)) self.throttleDial_stbdHor = throttleDial.Throttle( self.throttleDial_stbdHor, -1, sizeTuple=(40, 115)) self.throttleDial_stbdVer = throttleDial.Throttle( self.throttleDial_stbdVer, -1, sizeTuple=(40, 115)) # update the ports available at start-up self.updatePorts() self.portChoice.SetSelection(0) # keeps the names and values of all control parameters self.controlParameters = { 'refreshRate': int(1000. / self.freqArduino ), # delay needed after each loop() pass in ROVmain.ino 'motorPortVer': 0, # throttle of the port vert motor <-100,100> 'motorPortHor': 0, 'motorStbdVer': 0, 'motorStbdHor': 0, 'forwardLED': False, # forward illumination LED on/off [True,False] } # names and values of sensor readings # need to call this for sensor readings to be sent self.sensorReadingsRequestObject = {'sendSensorReadings': 1} self.sensorParameters = { 'depthReading': 0, # depth reading [m] } # this needs to be called for the modules to be armed self.armModulesCommand = {'armModules': 1}
def __init__(self, parent): wx.Panel.__init__(self, parent) self.Bind(wx.EVT_PAINT, self.OnPaint) self.im1 = wx.Image('images\\b_musc1.png').ConvertToBitmap() self.im2 = wx.Image('images\\b_musc2.png').ConvertToBitmap() self.im3 = wx.Image('images\\b_musc3.png').ConvertToBitmap() self.im4 = wx.Image('images\\b_musc4.png').ConvertToBitmap() self.im5 = wx.Image('images\\b_navbar0.png').ConvertToBitmap() self.im6 = wx.Image('images\\b_navbar.png').ConvertToBitmap() self.im7 = wx.Image('images\\b_logo.png').ConvertToBitmap() self.img64 = cv2.imread('images\c1.png') self.img65 = cv2.imread('images\c2.png') self.img66 = cv2.imread('images\c3.png') self.f1 = cv2.imread('images\log.png') img64 = resize_c(self.f1, 300, 240) height, width = img64.shape[:2] self.bmp2 = wx.BitmapFromBuffer(width, height, img64) self.ImgControl2 = statbmp.GenStaticBitmap(self, wx.ID_ANY, self.bmp2, pos=(880, 130)) img46 = resize_c(frame0, 200, 200) height, width = img46.shape[:2] self.orig_height = height self.orig_width = width self.bmp = wx.BitmapFromBuffer(width, height, img46) self.ImgControl = statbmp.GenStaticBitmap(self, wx.ID_ANY, self.bmp, pos=(900, 150)) img64 = resize_c(self.img66, 30, 100) height, width = img64.shape[:2] self.orig_height1 = height self.orig_width1 = width self.bmp1 = wx.BitmapFromBuffer(width, height, img64) self.ImgControl1 = statbmp.GenStaticBitmap(self, wx.ID_ANY, self.bmp1, pos=(950, 370)) nouveau = wx.BitmapButton(self, bitmap=self.im1, size=(120, 80), pos=(10, 10)) nouveau.Bind(wx.EVT_BUTTON, self.nouveau_def) charger = wx.BitmapButton(self, bitmap=self.im2, size=(120, 80), pos=(140, 10)) charger.Bind(wx.EVT_BUTTON, self.charger_def) information = wx.BitmapButton(self, bitmap=self.im3, size=(120, 80), pos=(270, 10)) information.Bind(wx.EVT_BUTTON, self.information_def) # prix = wx.BitmapButton(self,bitmap=self.im4 , size=(120, 80), pos=(430, 10)) # prix.Bind(wx.EVT_BUTTON, self.prix_def) #start a timer that's handler grabs a new frame and updates the image widgets self.timer = wx.Timer(self) self.timer.Start(1000.0 / 25) #bind timer events to the handler self.Bind(wx.EVT_TIMER, self.NextFrame)