def _create_window(self): # Setup the spectrum plot frequencies = linspace(0., float(SAMPLING_RATE)/2, num=NUM_SAMPLES/2) self.spectrum_data = ArrayPlotData(frequency=frequencies) empty_amplitude = zeros(NUM_SAMPLES/2) self.spectrum_data.set_data('amplitude', empty_amplitude) self.spectrum_plot = Plot(self.spectrum_data) self.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color="red") self.spectrum_plot.padding = 50 self.spectrum_plot.title = "Spectrum" spec_range = self.spectrum_plot.plots.values()[0][0].value_mapper.range spec_range.low = 0.0 spec_range.high = 5.0 self.spectrum_plot.index_axis.title = 'Frequency (hz)' self.spectrum_plot.value_axis.title = 'Amplitude' # Time Series plot times = linspace(0., float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES) self.time_data = ArrayPlotData(time=times) empty_amplitude = y_values = zeros(NUM_SAMPLES) self.time_data.set_data('amplitude', empty_amplitude) self.time_plot = Plot(self.time_data) self.time_plot.plot(("time", "amplitude"), name="Time", color="blue") self.time_plot.padding = 50 self.time_plot.title = "Time" self.time_plot.index_axis.title = 'Time (seconds)' self.time_plot.value_axis.title = 'Amplitude' time_range = self.time_plot.plots.values()[0][0].value_mapper.range time_range.low = -0.2 time_range.high = 0.2 # Spectrogram plot spectrogram_data = zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH)) self.spectrogram_plotdata = ArrayPlotData() self.spectrogram_plotdata.set_data('imagedata', spectrogram_data) spectrogram_plot = Plot(self.spectrogram_plotdata) spectrogram_time = linspace(0., float(SPECTROGRAM_LENGTH*NUM_SAMPLES)/float(SAMPLING_RATE), num=SPECTROGRAM_LENGTH) spectrogram_freq = linspace(0., float(SAMPLING_RATE/2), num=NUM_SAMPLES/2) spectrogram_plot.img_plot('imagedata', name='Spectrogram', xbounds=spectrogram_time, ybounds=spectrogram_freq, colormap=jet, ) range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range range_obj.high = 5 range_obj.low = 0.0 spectrogram_plot.title = 'Spectrogram' self.spectrogram_plot = spectrogram_plot container = HPlotContainer() container.add(self.spectrum_plot) container.add(self.time_plot) container.add(spectrogram_plot) # Set the timer to generate events to us timerId = wx.NewId() self.timer = wx.Timer(self, timerId) self.Bind(wx.EVT_TIMER, self.onTimer, id=timerId) self.timer.Start(2500.0, wx.TIMER_CONTINUOUS) return Window(self, -1, component=container)
def __init__(self, parent, parent2, tbstyle, windowstyle, closingstyle, scrollType=TB_SCR_TYPE_DU): """ Default class constructor. Used internally. Do not call directly this class in your application! :param `parent`: the window parent; :param `parent2`: the :class:`ToasterBox` calling this window; :param `tbstyle`: the :class:`ToasterBoxWindow` main style. Can be one of the following bits: ====================== ======= ================================ `ToasterBox` Style Value Description ====================== ======= ================================ ``TB_SIMPLE`` 0x1 A simple :class:`ToasterBox`, with background image and text customization can be created ``TB_COMPLEX`` 0x2 `ToasterBoxes` with different degree of complexity can be created. You can add as many controls as you want, provided that you call the :meth:`~ToasterBoxWindow.AddPanel` method and pass to it a dummy frame and a :class:`Panel`. ====================== ======= ================================ :param `windowstyle`: this parameter influences the visual appearance of :class:`ToasterBoxWindow`, and can be one of the following styles: ====================== ========== ================================ Window Style Hex Value Description ====================== ========== ================================ ``TB_DEFAULT_STYLE`` 0x2008002 Default window style for :class:`ToasterBox`, with no caption nor close box. ``TB_CAPTION`` 0x22009806 :class:`ToasterBox` will have a caption, with the possibility to set a title for the :class:`ToasterBox` frame, and a close box. ====================== ========== ================================ :param `closingstyle`: the closing style for :class:`ToasterBoxWindow`. Can be one of the following bits: ==================== =========== ================================================== Closing Styles Hex Value Description ==================== =========== ================================================== ``TB_ONTIME`` 0x1 :class:`ToasterBox` will close after a specified amount of time. ``TB_ONCLICK`` 0x2 :class:`ToasterBox` can be closed by clicking anywhere on the :class:`ToasterBox` frame. ==================== =========== ================================================== :param `scrollType`: the scrolling direction for :class:`ToasterBoxWindow`. Can be one of the following bits: ==================== =========== ================================================== Scroll Styles Hex Value Description ==================== =========== ================================================== ``TB_SCR_TYPE_UD`` 0x1 :class:`ToasterBox` will scroll from up to down ``TB_SCR_TYPE_DU`` 0x2 :class:`ToasterBox` will scroll from down to up ``TB_SCR_TYPE_FADE`` 0x4 :class:`ToasterBox` will fade in/out (without scrolling). ==================== =========== ================================================== """ wx.Frame.__init__(self, parent, wx.ID_ANY, "window", wx.DefaultPosition, wx.DefaultSize, style=windowstyle | wx.CLIP_CHILDREN) self._starttime = int(time.time()) self._parent2 = parent2 self._parent = parent self._sleeptime = 10 self._step = 4 self._pausetime = 1700 self._textcolour = wx.BLACK self._popuptext = "Change Me!" # the size we want the dialog to be framesize = wx.Size(150, 170) self._count = 1 self._tbstyle = tbstyle self._windowstyle = windowstyle self._closingstyle = closingstyle self._backgroundcolour = wx.WHITE if tbstyle == TB_COMPLEX: self.sizer = wx.BoxSizer(wx.VERTICAL) else: self._staticbitmap = None if self._windowstyle == TB_CAPTION: self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetTitle("") if scrollType == TB_SCR_TYPE_FADE and not self.CanSetTransparent(): import warnings warnings.warn( "The style ``TB_SCR_TYPE_FADE`` is not supported on this platform." ) scrollType = TB_SCR_TYPE_DU self._scrollType = scrollType if self._closingstyle & TB_ONCLICK and self._windowstyle != TB_CAPTION: self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self._bottomright = wx.Point(wx.GetDisplaySize().GetWidth(), wx.GetDisplaySize().GetHeight()) self.SetSize(self._bottomright.x, self._bottomright.y, framesize.GetWidth(), framesize.GetHeight()) self._scrollTimer = wx.Timer(self, -1) self._alphaTimer = wx.Timer(self, -1) self.Bind(wx.EVT_TIMER, self.OnScrollTimer, self._scrollTimer) self.Bind(wx.EVT_TIMER, self.AlphaCycle, self._alphaTimer) if not self._tbstyle & TB_COMPLEX: self.Bind(wx.EVT_PAINT, self.OnPaint) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
def __init__(self, parent=None, id=wx.ID_ANY, h5in=None, eiger_host="192.168.163.204", eiger_api_ver="1.6.1", bl="BL32XU", monitor_interval=5.): wx.Frame.__init__(self, parent=parent, id=id, title="Adxv launcher for Eiger", size=(500, 500)) self.adxv_proc = None # subprocess object self.h5file = h5in self.n_images = -1 self.adxv = adxv.Adxv() self.last_monitor_image = None self.bl = bl vbox = wx.BoxSizer(wx.VERTICAL) notebook = wx.Notebook(self, wx.ID_ANY) panel1 = wx.Panel(notebook, wx.ID_ANY) panel2 = wx.Panel(notebook, wx.ID_ANY) # panel1 vbox0 = wx.BoxSizer(wx.VERTICAL) hbox00 = wx.BoxSizer(wx.HORIZONTAL) hbox00.Add(wx.StaticText(panel1, wx.ID_ANY, "File: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.cmbInfile = wx.ComboBox(panel1, wx.ID_ANY, size=(350, 25)) self.cmbInfile.Bind(wx.EVT_COMBOBOX, self.cmbInfile_onChange) self.cmbInfile.Bind(wx.EVT_TEXT_ENTER, self.cmbInfile_onChange) hbox00.Add(self.cmbInfile, 1, flag=wx.EXPAND | wx.RIGHT) self.btnInfile = wx.Button(panel1, wx.ID_ANY, "...", size=(25, 25)) self.btnInfile.Bind(wx.EVT_BUTTON, self.btnInfile_click) self.btnLatest = wx.Button(panel1, wx.ID_ANY, "Latest", size=(50, 25)) self.btnLatest.Bind(wx.EVT_BUTTON, self.btnLatest_click) hbox00.Add(self.btnInfile) hbox00.Add(self.btnLatest) vbox0.Add(hbox00, flag=wx.EXPAND | wx.TOP, border=4) hbox01 = wx.BoxSizer(wx.HORIZONTAL) hbox01.Add(wx.StaticText(panel1, wx.ID_ANY, "Frame no: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.cmbFrame = wx.ComboBox(panel1, wx.ID_ANY, size=(100, 25), value="1") self.cmbFrame.Bind(wx.EVT_COMBOBOX, self.onTextEnter) self.cmbFrame.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) hbox01.Add(self.cmbFrame, flag=wx.EXPAND | wx.RIGHT) self.llbtn = wx.Button(panel1, wx.ID_ANY, "<<") hbox01.Add(self.llbtn, flag=wx.EXPAND | wx.RIGHT) self.lbtn = wx.Button(panel1, wx.ID_ANY, "<") hbox01.Add(self.lbtn, flag=wx.EXPAND | wx.RIGHT) self.rbtn = wx.Button(panel1, wx.ID_ANY, ">") hbox01.Add(self.rbtn, flag=wx.EXPAND | wx.RIGHT) self.rrbtn = wx.Button(panel1, wx.ID_ANY, ">>") hbox01.Add(self.rrbtn, flag=wx.EXPAND | wx.RIGHT) vbox0.Add(hbox01, flag=wx.EXPAND | wx.TOP, border=4) self.lbtn.Bind(wx.EVT_BUTTON, lambda e: self.next_or_back(-1)) self.rbtn.Bind(wx.EVT_BUTTON, lambda e: self.next_or_back(+1)) self.llbtn.Bind(wx.EVT_BUTTON, lambda e: self.play(-1)) self.rrbtn.Bind(wx.EVT_BUTTON, lambda e: self.play(+1)) hbox02 = wx.BoxSizer(wx.HORIZONTAL) hbox02.Add(wx.StaticText(panel1, wx.ID_ANY, "Binning: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtBin = wx.TextCtrl(panel1, wx.ID_ANY, size=(100, 25), style=wx.TE_PROCESS_ENTER) self.txtBin.SetValue("1") self.txtBin.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) hbox02.Add(self.txtBin, flag=wx.EXPAND | wx.RIGHT) vbox0.Add(hbox02, flag=wx.EXPAND | wx.TOP, border=4) panel1.SetSizer(vbox0) notebook.InsertPage(0, panel1, "File") # panel2 vbox1 = wx.BoxSizer(wx.VERTICAL) #hbox10 = wx.BoxSizer(wx.HORIZONTAL) #hbox10.Add(wx.StaticText(panel2, wx.ID_ANY, "Wavelength: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonWavelen = wx.TextCtrl(panel2, wx.ID_ANY, size=(100,25)) #self.txtMonWavelen.SetValue("1.0000") #hbox10.Add(self.txtMonWavelen, flag=wx.EXPAND|wx.RIGHT) #hbox10.Add(wx.StaticText(panel2, wx.ID_ANY, " Distance: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonDistance = wx.TextCtrl(panel2, wx.ID_ANY, size=(100,25)) #self.txtMonDistance.SetValue("300.0") #hbox10.Add(self.txtMonDistance, flag=wx.EXPAND|wx.RIGHT) #vbox1.Add(hbox10, flag=wx.EXPAND|wx.TOP, border=4) hbox11 = wx.BoxSizer(wx.HORIZONTAL) #hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, "Beam center: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonBeamxy = wx.TextCtrl(panel2, wx.ID_ANY, size=(150,25)) #self.txtMonBeamxy.SetValue("1550, 1634.5") #hbox11.Add(self.txtMonBeamxy, flag=wx.EXPAND|wx.RIGHT) self.btnMonRefresh = wx.Button(panel2, wx.ID_ANY, "Start monitoring") self.btnMonRefresh.Bind(wx.EVT_BUTTON, self.on_btnMonRefresh) self.btnMonStop = wx.Button(panel2, wx.ID_ANY, "Stop") self.btnMonStop.Bind(wx.EVT_BUTTON, lambda e: self.monitor_timer.Stop()) self.txtMonInterval = wx.TextCtrl(panel2, wx.ID_ANY, "%.1f" % monitor_interval, size=(50, 25)) hbox11.Add(self.btnMonRefresh, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(self.btnMonStop, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, " interval: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) hbox11.Add(self.txtMonInterval, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, " sec."), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) vbox1.Add(hbox11, flag=wx.EXPAND | wx.TOP, border=4) hbox12 = wx.BoxSizer(wx.HORIZONTAL) self.chkMonRaiseW = wx.CheckBox(panel2, wx.ID_ANY, "Raise adxv windows") self.chkMonRaiseW.SetValue(1) hbox12.Add(self.chkMonRaiseW, flag=wx.EXPAND | wx.RIGHT) vbox1.Add(hbox12, flag=wx.EXPAND | wx.TOP, border=4) hbox13 = wx.BoxSizer(wx.HORIZONTAL) hbox13.Add(wx.StaticText(panel2, wx.ID_ANY, "Eiger DCU host: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtEigerHost = wx.TextCtrl(panel2, wx.ID_ANY, eiger_host, size=(150, 25)) hbox13.Add(self.txtEigerHost) hbox13.Add(wx.StaticText(panel2, wx.ID_ANY, " API ver.: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtEigerAPIver = wx.TextCtrl(panel2, wx.ID_ANY, eiger_api_ver, size=(100, 25)) hbox13.Add(self.txtEigerAPIver) vbox1.Add(hbox13, flag=wx.EXPAND | wx.TOP, border=4) panel2.SetSizer(vbox1) notebook.InsertPage(1, panel2, "Monitor") notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_notebook_page_changed) vbox.Add(notebook, flag=wx.EXPAND) self.txtInfo = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_MULTILINE) self.txtInfo.SetFont(wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL)) self.txtInfo.SetEditable(False) vbox.Add(self.txtInfo, 1, flag=wx.EXPAND, border=4) self.SetSizer(vbox) self.play_timer = wx.Timer(self) self.play_relval = 0 self.Bind(wx.EVT_TIMER, self.on_play_timer, self.play_timer) self.monitor_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_monitor_timer, self.monitor_timer) self.Show() if self.h5file is not None: self.read_h5file()
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) 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 ShowSensors(self): """ Display the sensors. """ sensors = self.getSensorsToDisplay(self.istart) # Destroy previous widgets for b in self.boxes: b.Destroy() for t in self.texts: t.Destroy() self.boxes = [] self.texts = [] # Main sizer boxSizerMain = wx.BoxSizer(wx.VERTICAL) # Grid sizer nrows, ncols = 1, 3 vgap, hgap = 0, 0 gridSizer = wx.GridSizer(nrows, ncols, vgap, hgap) # Create a box for each sensor for index, sensor in sensors: (name, value, unit) = self.port.sensor(index) box = OBDStaticBox(self, wx.ID_ANY) self.boxes.append(box) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) # Text for sensor value if type(value)==float: value = str("%.2f"%round(value, 3)) t1 = wx.StaticText(parent=self, label=str(value), style=wx.ALIGN_CENTER) t1.SetForegroundColour('WHITE') font1 = wx.Font(32, wx.ROMAN, wx.NORMAL, wx.NORMAL, faceName="Monaco") t1.SetFont(font1) boxSizer.Add(t1, 0, wx.ALIGN_CENTER | wx.ALL, 20) boxSizer.AddStretchSpacer() self.texts.append(t1) # Text for sensor name t2 = wx.StaticText(parent=self, label=unit+"\n"+name, style=wx.ALIGN_CENTER) t2.SetForegroundColour('WHITE') font2 = wx.Font(13, wx.ROMAN, wx.NORMAL, wx.BOLD, faceName="Monaco") t2.SetFont(font2) boxSizer.Add(t2, 0, wx.ALIGN_CENTER | wx.ALL, 5) self.texts.append(t2) gridSizer.Add(boxSizer, 1, wx.EXPAND | wx.ALL) # Add invisible boxes if necessary nsensors = len(sensors) for i in range(3-nsensors): box = OBDStaticBox(self) boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL) self.boxes.append(box) box.Show(False) gridSizer.Add(boxSizer, 1, wx.EXPAND | wx.ALL) # Layout boxSizerMain.Add(gridSizer, 1, wx.EXPAND | wx.ALL, 10) self.SetSizer(boxSizerMain) self.Refresh() self.Layout() # Timer for update self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.refresh, self.timer) self.timer.Start(650)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Testu logs", pos = wx.DefaultPosition, size = wx.Size( 700,450 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.HORIZONTAL ) self.m_panel2 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.BORDER_SUNKEN|wx.TAB_TRAVERSAL ) self.m_panel2.SetMinSize( wx.Size( 150,-1 ) ) global x x = np.linspace(0,50., num=100) X,Y = np.meshgrid(x,x) self.client = PlotCanvas(self) #self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) bSizer1.Add( self.client, 1, wx.EXPAND, 5 ) global k k=0. global Blit Blit = True ##########TIMER self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.draw, self.timer) bSizer2 = wx.BoxSizer( wx.VERTICAL ) bSizer2.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_button1 = wx.Button( self.m_panel2, wx.ID_ANY, u"Variants A", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.m_button1, 0, wx.ALL, 5 ) self.m_button2 = wx.Button( self.m_panel2, wx.ID_ANY, u"Variants B", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.m_button2, 0, wx.ALL, 5 ) self.toggleBtn = wx.Button(self.m_panel2, wx.ID_ANY, "Start") bSizer2.Add( self.toggleBtn, 0, wx.ALL, 5 ) bSizer2.Add( ( 0, 0), 1, wx.EXPAND, 5 ) self.m_panel2.SetSizer( bSizer2 ) self.m_panel2.Layout() bSizer2.Fit( self.m_panel2 ) bSizer1.Add( self.m_panel2, 0, wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) self.Layout() self.Centre( wx.BOTH ) self.m_statusBar1 = self.CreateStatusBar( 1, wx.STB_SIZEGRIP|wx.BORDER_RAISED, wx.ID_ANY ) # Connect Events self.Bind( wx.EVT_CLOSE, self.OnClose ) self.Bind( wx.EVT_IDLE, self.OnIdle ) self.m_button1.Bind( wx.EVT_BUTTON, self.OnVariantsA ) self.m_button2.Bind( wx.EVT_BUTTON, self.OnVariantsB ) self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle) ######################## # define the function for drawing pointLabels #self.client.SetPointLabelFunc(self.DrawPointLabel) # Create mouse event for showing cursor coords in status bar #self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown) # Show closest point when enabled #self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion) self.resetDefaults() self.Show(True)
def __init__(self, parent, id, DO_lines): self.debug = True (self.DO_lines_6251, self.DO_lines_6025) = DO_lines wx.Frame.__init__(self, None, -1, title='ATE Manual Control', pos=(10, 10), size=(600, 800)) panel = wx.Panel(self, -1) #main label for the window window_label = wx.StaticText(panel, -1, "ATE Manual Control Utility", pos=(50, 10)) font = wx.Font(31, wx.DEFAULT, wx.NORMAL, wx.NORMAL) window_label.SetFont(font) #***************************************************************** #********Analog input voltage controls**************************** #create labels for 6251 analog voltage display voltage_labels = [ 'VREF', '2V2', '1V8', 'Ibat', '15V', '2V2 ripple', '1V8 ripple', '15V ripple', 'TPECG', 'ISRC', 'VREF ripple', 'VBAT', 'HV CAPS' ] voltage_labels_x_pos = 20 voltage_labels_y_pos = 100 voltage_labels_spacing = 25 column_label_font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL) voltage_display_font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL) num_voltage_measurement_labels = 13 self.voltage_measurement_labels = [] for i in range(num_voltage_measurement_labels): self.voltage_measurement_labels.append( wx.StaticText(panel, -1, voltage_labels[i], pos=(voltage_labels_x_pos, voltage_labels_y_pos + (i * voltage_labels_spacing)), size=(20, 70), style=wx.ALIGN_RIGHT)) self.voltage_measurement_labels[i].SetFont(column_label_font) #create the controls to place 6251 analog voltage measurements into num_6251_displays = 13 voltage_measurements_6251_x_pos = 110 self.voltage_measurements_6251 = [] for i in range(num_6251_displays): self.voltage_measurements_6251.append( wx.TextCtrl( panel, -1, "", size=(67, 20), pos=(voltage_measurements_6251_x_pos, voltage_labels_y_pos + (i * voltage_labels_spacing)))) self.voltage_measurements_6251[i].SetFont(voltage_display_font) self.voltage_measurements_6251[i].SetValue("%.4fV" % (1.2345)) label_6251 = wx.StaticText(panel, -1, ' 6251', pos=(voltage_measurements_6251_x_pos, voltage_labels_y_pos - 25)) label_6251.SetFont(column_label_font) #create labels for 6025 analog voltage display voltage_labels_6025 = ['VREF', '2V2', '1V8', '15V', 'VBAT', 'Ibat'] voltage_labels_6025_x_pos = 260 self.voltage_measurement_labels_6025 = [] for i in range(len(voltage_labels_6025)): self.voltage_measurement_labels_6025.append( wx.StaticText( panel, -1, voltage_labels_6025[i], pos=(voltage_labels_6025_x_pos, voltage_labels_y_pos + (i * voltage_labels_spacing)))) self.voltage_measurement_labels_6025[i].SetFont(column_label_font) #create the controls to place 6025 analog voltage measurements into num_6025_displays = 6 voltage_measurements_6025_x_pos = 190 self.voltage_measurements_6025 = [] for i in range(num_6025_displays): self.voltage_measurements_6025.append( wx.TextCtrl( panel, -1, "", size=(67, 20), pos=(voltage_measurements_6025_x_pos, voltage_labels_y_pos + (i * voltage_labels_spacing)))) self.voltage_measurements_6025[i].SetFont(voltage_display_font) self.voltage_measurements_6025[i].SetValue("%.4fV" % (1.2345)) label_6025 = wx.StaticText(panel, -1, ' 6025', pos=(voltage_measurements_6025_x_pos, voltage_labels_y_pos - 25)) label_6025.SetFont(column_label_font) #create a timer for updating voltage displays self.timer = wx.Timer(self, -1) self.timer.Start(1000) # update clock digits every second (1000ms) self.Bind(wx.EVT_TIMER, self.OnTimer) #***************************************************************** #***************************************************************** #**********Digital Controls*************************************** DIO_6251_port_numbers = ["P0_0", "P0_1"] DIO_portnums_6251 = [] DIO_6251_port_descriptions = ["short TZ", "BOL(off)/EOL(on)"] DIO_portnames_6251 = [] self.DIO_buttons_6251 = [] digital_ports_6251_x_pos = 350 digital_ports_6251_y_pos = 710 digital_y_pos = 100 digital_y_spacing = 18 num_digital_controls_6251 = len(DIO_6251_port_numbers) DIO_label_font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL) DIO_description_font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL) DIO_button_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL) DIO_button_size = (35, 18) #labels for port numbers on 6251 DIO card for i in range(num_digital_controls_6251): DIO_portnums_6251.append( wx.StaticText( panel, -1, DIO_6251_port_numbers[i], pos=(digital_ports_6251_x_pos, digital_ports_6251_y_pos + (i * digital_y_spacing)))) DIO_portnums_6251[i].SetFont(DIO_label_font) #buttons for controlling 6251 ports for i in range(num_digital_controls_6251): self.DIO_buttons_6251.append( wx.Button(panel, -1, 'OFF', pos=(digital_ports_6251_x_pos + 40, digital_ports_6251_y_pos + (i * digital_y_spacing) - 2), size=DIO_button_size)) self.DIO_buttons_6251[i].name = "6251_%d" % i self.DIO_buttons_6251[i].SetFont(DIO_button_font) self.DIO_buttons_6251[i].SetBackgroundColour(STANDARD) self.Bind(wx.EVT_BUTTON, self.on_DIO_click, self.DIO_buttons_6251[i]) #labels for 6251 port descriptions for i in range(num_digital_controls_6251): DIO_portnames_6251.append( wx.StaticText( panel, -1, DIO_6251_port_descriptions[i], pos=(digital_ports_6251_x_pos + 80, digital_ports_6251_y_pos + (i * digital_y_spacing)))) DIO_portnames_6251[i].SetFont(DIO_description_font) #label 6251 column label_6251_DO = wx.StaticText(panel, -1, ' 6251 Digital Output', pos=(digital_ports_6251_x_pos, digital_ports_6251_y_pos - 25)) label_6251_DO.SetFont(column_label_font) #variables for the 6025 digital ports DIO_6025_port_numbers = [ "DIO_0", "DIO_1", "DIO_2", "DIO_3", "DIO_4", "DIO_5", "DIO_6", "DIO_7", "PA_0", "PA_1", "PA_2", "PA_3", "PA_4", "PA_5", "PA_6", "PA_7", "PB_0", "PB_1", "PB_2", "PB_3", "PB_4", "PB_5", "PB_6", "PB_7", "PC_0", "PC_1", "PC_2", "PC_3", "PC_4", "PC_5", "PC_6", "PC_7" ] DIO_portnums_6025 = [] DIO_6025_port_descriptions = [ "shock load 1", "shock load 2", "shock load 3", "shock load 4", "75ohm shock load", "", "", "HVcaps 10K load", "ECG SA-A0", "ECG SA-A1", "ECG SB-A0", "ECG SB-A1", "ECG HVA-A0", "ECG HVA-A1", "ECG HVB-A0", "ECG HVB-A1", "SMU_CH1-2V2", "SMU_CH2-1V8", "SMU_CH3-15V", "GPIP0-1V8", "FDATA0-GND", "ADCIN-2V2", "", "", "PicoscopeA-shock", "PicoscopeB-ECGDATA", "PicoscopeB-CEN", "PicoscopeA-DATA0", "", "", "", "" ] DIO_portnames_6025 = [] self.DIO_buttons_6025 = [] digital_ports_6025_x_pos = 350 num_digital_controls_6025 = len(DIO_6025_port_numbers) DIO_portnums_6025 = [] #labels for port numbers on 6025 DIO card for i in range(num_digital_controls_6025): DIO_portnums_6025.append( wx.StaticText(panel, -1, DIO_6025_port_numbers[i], pos=(digital_ports_6025_x_pos, digital_y_pos + (i * digital_y_spacing)))) DIO_portnums_6025[i].SetFont(DIO_label_font) #buttons for controlling 6025 ports for i in range(num_digital_controls_6025): self.DIO_buttons_6025.append( wx.Button(panel, -1, 'OFF', pos=(digital_ports_6025_x_pos + 40, digital_y_pos + (i * digital_y_spacing) - 2), size=DIO_button_size)) self.DIO_buttons_6025[i].name = "6025_%d" % i self.DIO_buttons_6025[i].SetFont(DIO_button_font) self.DIO_buttons_6025[i].SetBackgroundColour(STANDARD) self.Bind(wx.EVT_BUTTON, self.on_DIO_click, self.DIO_buttons_6025[i]) #labels for 6025 port descriptions for i in range(len(DIO_6025_port_descriptions)): DIO_portnames_6025.append( wx.StaticText(panel, -1, DIO_6025_port_descriptions[i], pos=(digital_ports_6025_x_pos + 80, digital_y_pos + (i * digital_y_spacing)))) DIO_portnames_6025[i].SetFont(DIO_description_font) #label 6025 column label_6025_DO = wx.StaticText(panel, -1, ' 6025 Digital Output', pos=(digital_ports_6025_x_pos, digital_y_pos - 25)) label_6025_DO.SetFont(column_label_font) #***************************************************************** #***************************************************************** #***********Analog Output Controls******************************** AO_x_pos = 100 AO_y_pos = 450 #section label label_AO = wx.StaticText(panel, -1, ' 6251 Analog Output', pos=(AO_x_pos, AO_y_pos)) label_AO.SetFont(column_label_font) #radio buttons for selecting output type output_types_list = ['Sinewave', 'ECG'] self.output_types = wx.RadioBox(panel, -1, "", (AO_x_pos, AO_y_pos + 20), wx.DefaultSize, output_types_list, 2, wx.RA_SPECIFY_COLS) self.Bind(wx.EVT_RADIOBOX, self.on_AO_change, self.output_types) #numeric control for selecting sinewave amplitude self.amplitude_label = wx.StaticText(panel, -1, 'amplitude(Vpp)', pos=(AO_x_pos - 20, AO_y_pos + 76)) self.amplitude_label.SetFont(DIO_label_font) self.amplitude_entry = wx.TextCtrl(panel, -1, '0.05', pos=(AO_x_pos + 70, AO_y_pos + 75), size=(50, 20), style=wx.TE_PROCESS_ENTER) self.Bind(wx.EVT_TEXT_ENTER, self.on_amplitude_entered, self.amplitude_entry) self.amplitude_spin = wx.SpinButton(panel, -1, pos=(AO_x_pos + 120, AO_y_pos + 75)) self.Bind(wx.EVT_SPIN_UP, self.on_amplitude_spin_increase, self.amplitude_spin) self.Bind(wx.EVT_SPIN_DOWN, self.on_amplitude_spin_decrease, self.amplitude_spin) #numeric control for selecting sinewave frequency self.frequency_label = wx.StaticText(panel, -1, 'frequency(Hz)', pos=(AO_x_pos - 20, AO_y_pos + 101)) self.frequency_label.SetFont(DIO_label_font) self.frequency_entry = wx.TextCtrl(panel, -1, '11.0', pos=(AO_x_pos + 70, AO_y_pos + 100), size=(50, 20), style=wx.TE_PROCESS_ENTER) self.Bind(wx.EVT_TEXT_ENTER, self.on_frequency_entered, self.frequency_entry) self.frequency_spin = wx.SpinButton(panel, -1, pos=(AO_x_pos + 120, AO_y_pos + 100)) self.Bind(wx.EVT_SPIN_UP, self.on_frequency_spin_increase, self.frequency_spin) self.Bind(wx.EVT_SPIN_DOWN, self.on_frequency_spin_decrease, self.frequency_spin) #container for all controls related to sinewave output adjustment self.sinewave_controls = [ self.amplitude_label, self.amplitude_entry, self.amplitude_spin, self.frequency_label, self.frequency_entry, self.frequency_spin ] #slider for selecting ECG beats-per-minute self.ecg_bpm = 60 self.min_bpm = 40 self.max_bpm = 300 self.ecg_bpm_slider = wx.Slider(panel, -1, value=self.ecg_bpm, minValue=self.min_bpm, maxValue=self.max_bpm, pos=(AO_x_pos - 50, AO_y_pos + 130), size=(260, 50), style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS) self.ecg_bpm_slider.SetTickFreq(10, 1) self.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.on_bpm_slider_change, self.ecg_bpm_slider) #container for all controls related to ecg output self.ecg_controls = [self.ecg_bpm_slider] #turn ecg bpm slider off as default selection is sinewave output for control in self.ecg_controls: control.Hide() #buttons for selecting which channel the selected signal is applied to AO_button_y_pos = 640 self.AO_buttons_label = wx.StaticText(panel, -1, 'Output Channel Enable', pos=(AO_x_pos, AO_button_y_pos)) self.AO_buttons_label.SetFont( wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) self.AO_CH0_button = wx.Button(panel, -1, 'OFF', pos=(AO_x_pos, AO_button_y_pos + 20), size=(50, 20)) self.AO_CH0_button.SetBackgroundColour(STANDARD) self.AO_CH0_button.name = 'CH0' self.Bind(wx.EVT_BUTTON, self.on_AO_enable_click, self.AO_CH0_button) self.AO_CH0_button_label = wx.StaticText(panel, -1, 'CH_0', pos=(AO_x_pos + 10, AO_button_y_pos + 40)) self.AO_CH0_button_label.SetFont( wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) self.AO_CH0_running = False self.AO_CH1_button = wx.Button(panel, -1, 'OFF', pos=(AO_x_pos + 100, AO_button_y_pos + 20), size=(50, 20)) self.AO_CH1_button.SetBackgroundColour(STANDARD) self.AO_CH1_button.name = 'CH1' self.Bind(wx.EVT_BUTTON, self.on_AO_enable_click, self.AO_CH1_button) self.AO_CH1_button_label = wx.StaticText(panel, -1, 'CH_1', pos=(AO_x_pos + 110, AO_button_y_pos + 40)) self.AO_CH1_button_label.SetFont( wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) self.AO_CH1_running = False self.analog_output_thread_started = False self.AO_buttons = [self.AO_CH0_button, self.AO_CH1_button]
def __init__(self): #-------------- screen = wx.ScreenDC() # Screen size. ws, hs = screen.GetSize() #-------------- # Return bitmaps folder. # self.bitmaps_dir = wx.GetApp().GetBitmapsDir() # Load a background bitmap. bitmap = wx.Bitmap(r"icons\grand-canyon.jpg", type=wx.BITMAP_TYPE_JPEG) # Determine size of bitmap. wi, hi = bitmap.GetWidth(), bitmap.GetHeight() print("\n... Bitmap size : %sx%s px" % (wi, hi)) x = int((ws - wi) / 2) y = int((hs - hi) / 2) #-------------- super(MySplash, self).__init__( bitmap=bitmap, splashStyle=wx.adv.SPLASH_CENTRE_ON_SCREEN | wx.adv.SPLASH_TIMEOUT, milliseconds=8000, parent=None, id=-1, pos=(x, y), size=(wi, hi), style=wx.STAY_ON_TOP | wx.BORDER_NONE) #------------ self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.count = 0 wx.Sleep(1) #------------ # Simplified init method. self.CreateCtrls() self.BindEvents() #------------ # Create a timer for my gauge. self.timer = wx.Timer(self) # Gauge speed. Simulate long startup time. self.timer.Start(90) self.Bind(wx.EVT_TIMER, self.TimerHandler, self.timer) #------------ print("\n... Display the splashScreen") #-------------- wx.BeginBusyCursor()
def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN) # Create some controls try: backend = "" # let MediaCtrl choose default backend #backend=wx.media.MEDIABACKEND_DIRECTSHOW #backend=wx.media.MEDIABACKEND_WMP10 self.mc = wx.media.MediaCtrl() ok = self.mc.Create(self, style=wx.SIMPLE_BORDER, szBackend=backend) if not ok: raise NotImplementedError except NotImplementedError: self.Destroy() raise # the following event is not sent with the Windows default backend # MEDIABACKEND_DIRECTSHOW # choose above e.g. MEDIABACKEND_WMP10 if this is a problem for you self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnMediaLoaded) btn1 = wx.Button(self, -1, "Load File") self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1) btn2 = wx.Button(self, -1, "Play") self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2) self.playBtn = btn2 btn3 = wx.Button(self, -1, "Pause") self.Bind(wx.EVT_BUTTON, self.OnPause, btn3) btn4 = wx.Button(self, -1, "Stop") self.Bind(wx.EVT_BUTTON, self.OnStop, btn4) slider = wx.Slider(self, -1, 0, 0, 10) self.slider = slider slider.SetMinSize((150, -1)) self.Bind(wx.EVT_SLIDER, self.OnSeek, slider) self.st_size = StaticText(self, -1, size=(100,-1)) self.st_len = StaticText(self, -1, size=(100,-1)) self.st_pos = StaticText(self, -1, size=(100,-1)) # setup the layout sizer = wx.GridBagSizer(5,5) sizer.Add(self.mc, (1,1), span=(5,1))#, flag=wx.EXPAND) sizer.Add(btn1, (1,3)) sizer.Add(btn2, (2,3)) sizer.Add(btn3, (3,3)) sizer.Add(btn4, (4,3)) sizer.Add(slider, (6,1), flag=wx.EXPAND) sizer.Add(self.st_size, (1, 5)) sizer.Add(self.st_len, (2, 5)) sizer.Add(self.st_pos, (3, 5)) self.SetSizer(sizer) #self.DoLoadFile(os.path.abspath("data/testmovie.mpg")) wx.CallAfter(self.DoLoadFile, os.path.abspath("data/testmovie.mpg")) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer) self.timer.Start(100)
def start(self): timer = wx.Timer(self, -1) self.notify() self.Bind(wx.EVT_TIMER, self.main, timer) timer.Start(self.interval * 60000) self.MainLoop()
def setupTimers(self): self.runTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.runTick)
def __init__(self, gui): """Set up the relax controller frame. @param gui: The GUI object. @type gui: wx.Frame instance """ # Store the args. self.gui = gui # Initialise the base class. super(Controller, self).__init__(self.gui, -1, style=wx.DEFAULT_FRAME_STYLE) # Some default values. self.size_x = 800 self.size_y = 700 self.border = 5 self.spacer = 10 # Set up the frame. sizer = self.setup_frame() # Add the relax logo. self.add_relax_logo(sizer) # Spacing. sizer.AddSpacer(20) # Add the current analysis info. self.name = self.add_text(self.main_panel, sizer, "Current GUI analysis:") # Add the current data pipe info. self.cdp = self.add_text(self.main_panel, sizer, "Current data pipe:") # Create the relaxation curve-fitting specific panel. self.create_rx(sizer) # Create the model-free specific panel. self.create_mf(sizer) # Add the main execution gauge. self.main_gauge = self.add_gauge( self.main_panel, sizer, "Execution progress:", tooltip= "This gauge will pulse while relax is executing an auto-analysis (when the execution lock is turned on) and will be set to 100% once the analysis is complete." ) # Initialise a queue for log messages. self.log_queue = Queue() # Add the log panel. self.log_panel = LogCtrl(self.main_panel, self, log_queue=self.log_queue, id=-1) sizer.Add(self.log_panel, 1, wx.EXPAND | wx.ALL, 0) # IO redirection for STDOUT (with splitting if logging or teeing modes are set). out = Redirect_text(self.log_panel, self.log_queue, orig_io=sys.stdout, stream=0) if sys.stdout == sys.__stdout__ or status.relax_mode in [ 'test suite', 'system tests', 'unit tests', 'GUI tests' ]: sys.stdout = out else: split_stdout = SplitIO() split_stdout.split(sys.stdout, out) sys.stdout = split_stdout # IO redirection for STDERR (with splitting if logging or teeing modes are set). err = Redirect_text(self.log_panel, self.log_queue, orig_io=sys.stderr, stream=1) if sys.stderr == sys.__stderr__ or status.relax_mode in [ 'test suite', 'system tests', 'unit tests', 'GUI tests' ]: sys.stderr = err else: split_stderr = SplitIO() split_stderr.split(sys.stderr, err) sys.stderr = split_stderr # Initial update of the controller. self.update_controller() # Create a timer for updating the controller elements. self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.handler_timer, self.timer) # The relax intro printout, to mimic the prompt/script interface. if not status.test_mode: info = Info_box() sys.stdout.write(info.intro_text()) sys.stdout.write("\n") sys.stdout.flush() # Set the focus on the log control. self.log_panel.SetFocus() # Register functions with the observer objects. status.observers.pipe_alteration.register( 'controller', self.update_controller, method_name='update_controller') status.observers.auto_analyses.register( 'controller', self.update_controller, method_name='update_controller') status.observers.gui_analysis.register('controller', self.update_controller, method_name='update_controller') status.observers.exec_lock.register('controller', self.update_gauge, method_name='update_gauge')
def __init__(self, parent): super(InteractiveFrame, self).__init__(parent) self._timer = wx.Timer(self) self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down) self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) self.Bind(wx.EVT_TIMER, self.on_timer, self._timer)
def OnInit(self): self.frame = wx.Frame( None, -1, self.action_name + ' - ' + self.action_type.name + ' - GUI Client') self.sz = wx.BoxSizer(wx.VERTICAL) tmp_goal = self.action_type.goal() self.goal = wx.TextCtrl(self.frame, -1, style=wx.TE_MULTILINE) self.goal.SetValue(to_yaml(tmp_goal)) self.goal_st_bx = wx.StaticBox(self.frame, -1, "Goal") self.goal_st = wx.StaticBoxSizer(self.goal_st_bx, wx.VERTICAL) self.goal_st.Add(self.goal, 1, wx.EXPAND) self.feedback = wx.TextCtrl(self.frame, -1, style=(wx.TE_MULTILINE | wx.TE_READONLY)) self.feedback_st_bx = wx.StaticBox(self.frame, -1, "Feedback") self.feedback_st = wx.StaticBoxSizer(self.feedback_st_bx, wx.VERTICAL) self.feedback_st.Add(self.feedback, 1, wx.EXPAND) self.result = wx.TextCtrl(self.frame, -1, style=(wx.TE_MULTILINE | wx.TE_READONLY)) self.result_st_bx = wx.StaticBox(self.frame, -1, "Result") self.result_st = wx.StaticBoxSizer(self.result_st_bx, wx.VERTICAL) self.result_st.Add(self.result, 1, wx.EXPAND) self.send_goal = wx.Button(self.frame, -1, label="SEND GOAL") self.send_goal.Bind(wx.EVT_BUTTON, self.on_goal) self.send_goal.Disable() self.cancel_goal = wx.Button(self.frame, -1, label="CANCEL GOAL") self.cancel_goal.Bind(wx.EVT_BUTTON, self.on_cancel) self.cancel_goal.Disable() self.status_bg = wx.Panel(self.frame, -1) self.status_bg.SetBackgroundColour(wx.Colour(200, 0, 0)) self.status = wx.StaticText(self.status_bg, -1, label="No Goal") self.server_status_bg = wx.Panel(self.frame, -1) self.server_status_bg.SetBackgroundColour(wx.Colour(200, 0, 0)) self.server_status = wx.StaticText(self.server_status_bg, -1, label="Disconnected from server.") self.sz.Add(self.goal_st, 1, wx.EXPAND) self.sz.Add(self.feedback_st, 1, wx.EXPAND) self.sz.Add(self.result_st, 1, wx.EXPAND) self.sz.Add(self.send_goal, 0, wx.EXPAND) self.sz.Add(self.cancel_goal, 0, wx.EXPAND) self.sz.Add(self.status_bg, 0, wx.EXPAND) self.sz.Add(self.server_status_bg, 0, wx.EXPAND) self.frame.SetSizer(self.sz) self.server_check_timer = wx.Timer(self.frame) self.frame.Bind(wx.EVT_TIMER, self.server_check, self.server_check_timer) self.server_check_timer.Start(1000) self.sz.Layout() self.frame.Show() return True
def __init__(self): def makeSP(name, labels, statictexts=None): panel = wx.Panel(self.side_panel, -1) box = wx.StaticBox(panel, -1, name) sizer = wx.StaticBoxSizer(box, wx.VERTICAL) for name, min_value, value, max_value in labels: sp = SpinPanel(panel, name, min_value, value, max_value, self.OnSpinback) sizer.Add(sp, 0, wx.EXPAND) if statictexts: for name, text in statictexts: st = wx.StaticText(panel, -1, text) spin_panels[name] = st # Supposed to be a SpinPanel.... sizer.Add(st, 0, wx.EXPAND) panel.SetSizer(sizer) return panel wx.Frame.__init__(self, None, title="Roses in wxPython") self.rose_panel = RosePanel(self) self.side_panel = wx.Panel(self) # The cmd panel is four buttons whose names and foreground colors # change. Plop them in a StaticBox like the SpinPanels. Use # a 2x2 grid, but StaticBoxSizer can't handle that. Therefore, # create a sub panel, layout the buttons there, then give that to # a higher panel that has the static box stuff. self.cmd_panel = wx.Panel(self.side_panel, -1) self.sub_panel = wx.Panel(self.cmd_panel, -1) sizer = wx.GridSizer(rows=2, cols=2) global ctrl_buttons border = 'wxMac' in wx.PlatformInfo and 3 or 1 for name, handler in (('Go', self.OnGoStop), ('Redraw', self.OnRedraw), ('Backward', self.OnBackward), ('Forward', self.OnForward)): button = wx.Button(self.sub_panel, -1, name) button.SetForegroundColour(self.labelColours[name]) ctrl_buttons[name] = button button.Bind(wx.EVT_BUTTON, handler) sizer.Add(button, 0, wx.EXPAND | wx.ALL, border) self.sub_panel.SetSizer(sizer) # Set up cmd_panel with StaticBox stuff box = wx.StaticBox(self.cmd_panel, -1, 'Command') sizer = wx.StaticBoxSizer(box, wx.VERTICAL) sizer.Add(self.sub_panel) self.cmd_panel.SetSizer(sizer) # Now make the rest of the control panels... # The order of creation of SpinCtrls and Buttons is the order that # the tab key will step through, so the order of panel creation is # important. # In the SpinPanel data (name, min, value, max), value will be # overridden by clroses.py defaults. self.coe_panel = makeSP('Coefficient', (('Style', 0, 100, 3600), ('Sincr', -3600, -1, 3600), ('Petal', 0, 2, 3600), ('Pincr', -3600, 1, 3600))) self.vec_panel = makeSP( 'Vector', (('Vectors', 1, 399, 3600), ('Minimum', 1, 1, 3600), ('Maximum', 1, 3600, 3600), ('Skip first', 0, 0, 3600), ('Draw only', 1, 3600, 3600)), (('Takes', 'Takes 0000 vectors'), )) self.tim_panel = makeSP('Timing', (('Vec/tick', 1, 20, 3600), ('msec/tick', 1, 50, 1000), ('Delay', 1, 2000, 9999))) self.opt_panel = OptionsPanel(self.side_panel, self.rose_panel) # put them all on in a sizer attached to the side_panel panelSizer = wx.BoxSizer(wx.VERTICAL) panelSizer.Add(self.cmd_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5) panelSizer.Add(self.coe_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5) panelSizer.Add(self.vec_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5) panelSizer.Add(self.tim_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5) panelSizer.Add(self.opt_panel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5) self.side_panel.SetSizer(panelSizer) # and now arrange the two main panels in another sizer for the frame mainSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer.Add(self.rose_panel, 1, wx.EXPAND) mainSizer.Add(self.side_panel, 0, wx.EXPAND) self.SetSizer(mainSizer) # bind event handlers self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) # Determine appropriate image size. # At this point, the rose_panel and side_panel will both report # size (20, 20). After mainSizer.Fit(self) they will report the # same, but the Frame size, self.GetSize(), will report the desired # side panel dimensions plus an extra 20 on the width. That lets # us determine the frame size that will display the side panel and # a square space for the diagram. Only after Show() will the two # panels report the accurate sizes. mainSizer.Fit(self) rw, rh = self.rose_panel.GetSize() sw, sh = self.side_panel.GetSize() fw, fh = self.GetSize() h = max(600, fh) # Change 600 to desired minimum size w = h + fw - rw if verbose: print 'rose panel size', (rw, rh) print 'side panel size', (sw, sh) print ' frame size', (fw, fh) print 'Want size', (w, h) self.SetSize((w, h)) self.SupplyControlValues() # Ask clroses to tell us all the defaults self.Show()
def __init__(self, title='', video=''): wx.Frame.__init__(self, None, -1, title=title or 'wxVLC', pos=wx.DefaultPosition, size=(550, 500)) self.video = video # Menu Bar # File Menu self.frame_menubar = wx.MenuBar() self.file_menu = wx.Menu() self.file_menu.Append(1, "&Open...", "Open from file...") self.file_menu.AppendSeparator() self.file_menu.Append(2, "&Close", "Quit") self.Bind(wx.EVT_MENU, self.OnOpen, id=1) self.Bind(wx.EVT_MENU, self.OnExit, id=2) self.frame_menubar.Append(self.file_menu, "File") self.SetMenuBar(self.frame_menubar) # Panels # The first panel holds the video and it's all black self.videopanel = wx.Panel(self, -1) self.videopanel.SetBackgroundColour(wx.BLACK) # The second panel holds controls ctrlpanel = wx.Panel(self, -1) self.timeslider = wx.Slider(ctrlpanel, -1, 0, 0, 1000) self.timeslider.SetRange(0, 1000) self.pause = wx.Button(ctrlpanel, label="Pause") self.pause.Disable() self.play = wx.Button(ctrlpanel, label="Play") self.stop = wx.Button(ctrlpanel, label="Stop") self.stop.Disable() self.mute = wx.Button(ctrlpanel, label="Mute") self.volslider = wx.Slider(ctrlpanel, -1, 0, 0, 100, size=(100, -1)) # Bind controls to events self.Bind(wx.EVT_BUTTON, self.OnPlay, self.play) self.Bind(wx.EVT_BUTTON, self.OnPause, self.pause) self.Bind(wx.EVT_BUTTON, self.OnStop, self.stop) self.Bind(wx.EVT_BUTTON, self.OnMute, self.mute) self.Bind(wx.EVT_SLIDER, self.OnVolume, self.volslider) # Give a pretty layout to the controls ctrlbox = wx.BoxSizer(wx.VERTICAL) box1 = wx.BoxSizer(wx.HORIZONTAL) box2 = wx.BoxSizer(wx.HORIZONTAL) # box1 contains the timeslider box1.Add(self.timeslider, 1) # box2 contains some buttons and the volume controls box2.Add(self.play, flag=wx.RIGHT, border=5) box2.Add(self.pause) box2.Add(self.stop) box2.Add((-1, -1), 1) box2.Add(self.mute) box2.Add(self.volslider, flag=wx.TOP | wx.LEFT, border=5) # Merge box1 and box2 to the ctrlsizer ctrlbox.Add(box1, flag=wx.EXPAND | wx.BOTTOM, border=10) ctrlbox.Add(box2, 1, wx.EXPAND) ctrlpanel.SetSizer(ctrlbox) # Put everything togheter sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.videopanel, 1, flag=wx.EXPAND) sizer.Add(ctrlpanel, flag=wx.EXPAND | wx.BOTTOM | wx.TOP, border=10) self.SetSizer(sizer) self.SetMinSize((350, 300)) # finally create the timer, which updates the timeslider self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new()
def __init__(self): self.count=1 wx.Frame.__init__(self, None, wx.ID_ANY, title="CPU Usage Monitor", size=(1280, 720)) # Matplotlib Figure self.fig = Figure((16, 9), 80) # bind the Figure to the backend specific canvas self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig) # add a subplot self.ax1 = self.fig.add_subplot(411) self.ax2 = self.fig.add_subplot(412) self.ax3 = self.fig.add_subplot(413) self.ax4 = self.fig.add_subplot(414) # limit the X and Y axes dimensions self.ax1.set_ylim([-0.05, 1.2]) self.ax1.set_xlim([0, POINTS]) self.ax2.set_ylim([-0.05, 1.2]) self.ax2.set_xlim([0, POINTS]) self.ax3.set_ylim([-0.05, 1.2]) self.ax3.set_xlim([0, POINTS]) self.ax4.set_ylim([-0.05, 1.2]) self.ax4.set_xlim([0, POINTS]) self.ax1.set_autoscale_on(False) self.ax1.set_xticks([]) self.ax2.set_autoscale_on(False) self.ax2.set_xticks([]) self.ax3.set_autoscale_on(False) self.ax3.set_xticks([]) self.ax4.set_autoscale_on(False) self.ax4.set_xticks([]) # we want a tick every 10 point on Y (101 is to have 10 self.ax1.set_yticks(range(0, 2, 10)) self.ax2.set_yticks(range(0, 2, 10)) self.ax3.set_yticks(range(0, 2, 10)) self.ax4.set_yticks(range(0, 2, 10)) # disable autoscale, since we don't want the Axes to ad # draw a grid (it will be only for Y) self.ax1.grid(True) self.ax2.grid(True) self.ax3.grid(True) self.ax4.grid(True) # generates first "empty" plots self.s1e = [None] * POINTS self.s1s = [None] * POINTS self.s1w = [None] * POINTS self.s2e = [None] * POINTS self.s2s = [None] * POINTS self.s2w = [None] * POINTS self.s3e = [None] * POINTS self.s3s = [None] * POINTS self.s3w = [None] * POINTS self.s4e = [None] * POINTS self.s4s = [None] * POINTS self.s4w = [None] * POINTS self.s1_e,=self.ax1.plot(range(POINTS),self.s1e,label='ECMP',linewidth=3) self.s1_s,=self.ax1.plot(range(POINTS),self.s1s,label='STAT',linewidth=3) self.s1_w,=self.ax1.plot(range(POINTS),self.s1w,label='LBAS',linewidth=3) self.s2_e,=self.ax2.plot(range(POINTS),self.s2e,label='ECMP %',linewidth=3) self.s2_s,=self.ax2.plot(range(POINTS),self.s2s,label='STAT %',linewidth=3) self.s2_w,=self.ax2.plot(range(POINTS),self.s2w,label='WEIG %',linewidth=3) self.s3_e,=self.ax3.plot(range(POINTS),self.s3e,label='ECMP %',linewidth=3) self.s3_s,=self.ax3.plot(range(POINTS),self.s3s,label='STAT %',linewidth=3) self.s3_w,=self.ax3.plot(range(POINTS),self.s3w,label='WEIG %',linewidth=3) self.s4_e,=self.ax4.plot(range(POINTS),self.s4e,label='ECMP %',linewidth=3) self.s4_s,=self.ax4.plot(range(POINTS),self.s4s,label='STAT %',linewidth=3) self.s4_w,=self.ax4.plot(range(POINTS),self.s4w,label='WEIG %',linewidth=3) # add the legend self.ax1.legend(loc='upper center', bbox_to_anchor=(0.5,1.5), ncol=4, prop=font_manager.FontProperties(size=10)) # force a draw on the canvas() # trick to show the grid and the legend self.canvas.draw() # save the clean background - everything but the line # is drawn and saved in the pixel buffer background self.bg1 = self.canvas.copy_from_bbox(self.ax1.bbox) self.bg2 = self.canvas.copy_from_bbox(self.ax2.bbox) self.bg3 = self.canvas.copy_from_bbox(self.ax3.bbox) self.bg4 = self.canvas.copy_from_bbox(self.ax4.bbox) # bind events coming from timer with id = TIMER_ID # to the onTimer callback function self.timer = wx.Timer(self) self.timer.Start(500) self.Bind(wx.EVT_TIMER, self.onTimer,self.timer)
def __init__(self, parent, fitID=None, shipFittingInfo=("Test", "TestTrait", "cnc's avatar", 0, 0, None), shipID=None, itemData=None, graphicID=None, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(0, 40), style=0): # ===================================================================== # animCount should be 10 if we enable animation in Preferences # ===================================================================== self.animCount = 0 self.selectedDelta = 0 SFItem.SFBrowserItem.__init__(self, parent, size=size) self.mainFrame = gui.mainFrame.MainFrame.getInstance() self._itemData = itemData self.fitID = fitID self.shipID = shipID self.shipBrowser = self.Parent.Parent self.shipBmp = None self.deleted = False if shipID: self.shipBmp = BitmapLoader.getBitmap(str(graphicID), "renders") if not self.shipBmp: self.shipBmp = BitmapLoader.getBitmap("ship_no_image_big", "gui") self.shipFittingInfo = shipFittingInfo self.shipName, self.shipTrait, self.fitName, self.fitBooster, self.timestamp, self.notes = shipFittingInfo if config.debug: self.fitName = '({}) {}'.format(self.fitID, self.fitName) self.shipTrait = re.sub("<.*?>", " ", self.shipTrait) # see GH issue #62 # Disabling this due to change in gang boosts Nov 2016 # if self.fitBooster is None: self.fitBooster = False self.fitBooster = False self.boosterBmp = BitmapLoader.getBitmap("fleet_fc_small", "gui") self.copyBmp = BitmapLoader.getBitmap("fit_add_small", "gui") self.renameBmp = BitmapLoader.getBitmap("fit_rename_small", "gui") self.deleteBmp = BitmapLoader.getBitmap("fit_delete_small", "gui") self.acceptBmp = BitmapLoader.getBitmap("faccept_small", "gui") self.shipEffBk = BitmapLoader.getBitmap("fshipbk_big", "gui") img = self.shipEffBk.ConvertToImage() img = img.Mirror(False) self.shipEffBkMirrored = wx.Bitmap(img) self.dragTLFBmp = None self.bkBitmap = None self.__setToolTip() self.padding = 4 self.editWidth = 150 self.dragging = False self.dragged = False self.dragMotionTrail = 5 self.dragMotionTrigger = self.dragMotionTrail self.dragWindow = None self.fontBig = wx.Font(fonts.BIG, wx.SWISS, wx.NORMAL, wx.BOLD) self.fontNormal = wx.Font(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL) self.fontSmall = wx.Font(fonts.SMALL, wx.SWISS, wx.NORMAL, wx.NORMAL) self.SetDraggable() self.boosterBtn = self.toolbar.AddButton(self.boosterBmp, "Booster", show=self.fitBooster) self.toolbar.AddButton(self.copyBmp, "Copy", self.copyBtnCB) self.renameBtn = self.toolbar.AddButton(self.renameBmp, "Rename", self.renameBtnCB) self.toolbar.AddButton(self.deleteBmp, "Delete", self.deleteBtnCB) self.tcFitName = wx.TextCtrl(self, wx.ID_ANY, "%s" % self.fitName, wx.DefaultPosition, (self.editWidth, -1), wx.TE_PROCESS_ENTER) if self.shipBrowser.fitIDMustEditName != self.fitID: self.tcFitName.Show(False) else: self.tcFitName.SetFocus() self.tcFitName.SelectAll() self.shipBrowser.fitIDMustEditName = -1 self.renameBtn.SetBitmap(self.acceptBmp) self.tcFitName.Bind(wx.EVT_TEXT_ENTER, self.renameFit) self.tcFitName.Bind(wx.EVT_KILL_FOCUS, self.editLostFocus) self.tcFitName.Bind(wx.EVT_KEY_DOWN, self.editCheckEsc) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost) self.animTimerId = wx.NewId() self.animTimer = wx.Timer(self, self.animTimerId) self.animStep = 0 self.animPeriod = 10 self.animDuration = 100 self.maxDelta = 48 self.Bind(wx.EVT_TIMER, self.OnTimer) # ===================================================================== # DISABLED - it will be added as an option in PREFERENCES # if self.shipBrowser.GetActiveStage() != 4 and self.shipBrowser.GetLastStage() !=3: # self.animTimer.Start(self.animPeriod) # else: # self.animCount = 0 # ===================================================================== """ # Remove this bit as the time stuff is non-functional (works... but not exactly sure what it's meant to do) self.selTimerID = wx.NewId() self.selTimer = wx.Timer(self, self.selTimerID) self.selTimer.Start(100) """ self.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) self.Bind(wx.EVT_MIDDLE_UP, self.OpenNewTab)
def flash_status_message(self, msg, flash_len_ms=1500): self.statusbar.SetStatusText(msg) self.timeroff = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_flash_status_off, self.timeroff) self.timeroff.Start(flash_len_ms, oneShot=True)
def __init__(self): global GlobalSerialPort global GlobalFacilityText wx.Frame.__init__(self, None, wx.ID_ANY, 'CapCom ', style = wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER, size=(CalcFormLength(), CalcFormHeight()))# + SWVer, ) panel = wx.Panel(self, -1) wx.Frame.CenterOnScreen(self) BackGroundColour = (233, 228, 214) panel.SetBackgroundColour(BackGroundColour) self.Bind (wx.EVT_IDLE, self.OnIdle) self.WritePanel = WriteWindow(self) self.ReadPanel = ReadWindow(self) self.SettingsPanel = SettingsWindow(self) font16 = wx.Font(16, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL) font12 = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL) font10 = wx.Font(10, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL) # Main Page self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) self.timer.Start(5000) self.StatusBar = wx.StatusBar(self, -1) self.StatusBar.SetFieldsCount(4) self.MainLogoText = wx.StaticText(panel, -1, u'cCap', pos = (180, 100), size = (120, 30)) self.MainLogoText.SetFont(wx.Font(72, wx.FONTFAMILY_SWISS, wx.ITALIC, wx.NORMAL)) self.ReadPageGotoButton = wx.Button(panel, -1, label = 'Read Cap', pos = (0, 350), size = (150, 50)) self.ReadPageGotoButton.SetFont(font16) self.Bind(wx.EVT_BUTTON, self.on_ReadPageGotoButton, self.ReadPageGotoButton) self.WritePageGotoButton = wx.Button(panel, -1, label = 'Write Cap', pos = (150, 350), size = (150, 50)) self.WritePageGotoButton.SetFont(font16) self.Bind(wx.EVT_BUTTON, self.on_WritePageGotoButton, self.WritePageGotoButton) self.SettingsPageGotoButton = wx.Button(panel, -1, label = 'Settings', pos = (300, 350), size = (150, 50)) self.SettingsPageGotoButton.SetFont(font16) self.Bind(wx.EVT_BUTTON, self.on_SettingsPageGotoButton, self.SettingsPageGotoButton) self.ExitButton = wx.Button(panel, -1, label = 'Exit', pos = (450, 350), size = (150, 50)) self.ExitButton.SetFont(font16) self.Bind(wx.EVT_BUTTON, self.on_ExitButton, self.ExitButton) # end of GUI initialization # load settings if os.path.exists('CapCom.INI'): f = open('CapCom.INI', 'r') line = f.readline() self.PreviousComPort = line.rstrip() line = f.readline() GlobalFacilityText = line.rstrip() # ReadWindow.ReportDestination.SetValue(line.rstrip()) # line = f.readline() # line = line.rstrip() # if line == 'PDF' or line == 'Excel' or line == 'RawData': # self.ReportFormatChoice.SetStringSelection(line) # else: # self.ReportFormatChoice.SetStringSelection('Text') # line = f.readline() # line = line.rstrip() f.close() else: self.ReadPanel.ReportDestination.SetValue(os.getcwd()) self.ReadPanel.ReportFormatChoice.SetStringSelection('PDF') BaseStationList = FindBaseStation() GlobalSerialPort = BaseStationList[0] SerialPortName = str(BaseStationList[0]) if SerialPortName.find('No') == 0: dlg = wx.MessageDialog(None, GlobalSerialPort, 'Error', wx.OK) DialogReturn = dlg.ShowModal() self.Close(True) else: if platform.system() == "Windows": SerialPortName = 'COM' + SerialPortName self.StatusBar.SetStatusText(SerialPortName,0) self.ReadPanel.StatusBar.SetStatusText(SerialPortName,0) self.WritePanel.StatusBar.SetStatusText(SerialPortName,0) self.SettingsPanel.StatusBar.SetStatusText(SerialPortName,0) BaseStationTitle = BaseStationList[1][4:].strip() BaseStationTitle = BaseStationTitle.replace(':', ' ' ) self.StatusBar.SetStatusText(BaseStationTitle,1) self.ReadPanel.StatusBar.SetStatusText(BaseStationTitle,1) self.WritePanel.StatusBar.SetStatusText(BaseStationTitle,1) self.SettingsPanel.StatusBar.SetStatusText(BaseStationTitle,1) self.OnTimer(wx.EVT_TIMER)
def __init__(self, parent, debug = False): wx.Frame.__init__(self, parent, -1, "ArbotiX Controller GUI", style = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) sizer = wx.GridBagSizer(5,5) # Move Base drive = wx.StaticBox(self, -1, 'Move Base') drive.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) driveBox = wx.StaticBoxSizer(drive,orient=wx.VERTICAL) self.movebase = wx.Panel(self,size=(width,width-20)) self.movebase.SetBackgroundColour('WHITE') self.movebase.Bind(wx.EVT_MOTION, self.onMove) wx.StaticLine(self.movebase, -1, (width/2, 0), (1,width), style=wx.LI_VERTICAL) wx.StaticLine(self.movebase, -1, (0, width/2), (width,1)) driveBox.Add(self.movebase) sizer.Add(driveBox,(0,0),wx.GBSpan(1,1),wx.EXPAND|wx.TOP|wx.BOTTOM|wx.LEFT,5) self.forward = 0 self.turn = 0 self.X = 0 self.Y = 0 self.cmd_vel = rospy.Publisher('cmd_vel', Twist) # Move Servos servo = wx.StaticBox(self, -1, 'Move Servos') servo.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) servoBox = wx.StaticBoxSizer(servo,orient=wx.VERTICAL) servoSizer = wx.GridBagSizer(5,5) joint_defaults = getJointsFromURDF() i = 0 dynamixels = rospy.get_param('/arbotix/dynamixels', dict()) self.servos = list() self.publishers = list() self.relaxers = list() joints = rospy.get_param('/arbotix/joints', dict()) # create sliders and publishers for name in sorted(joints.keys()): # pull angles min_angle, max_angle = getJointLimits(name, joint_defaults) # create publisher self.publishers.append(rospy.Publisher(name+'/command', Float64)) if rospy.get_param('/arbotix/joints/'+name+'/type','dynamixel') == 'dynamixel': self.relaxers.append(rospy.ServiceProxy(name+'/relax', Relax)) else: self.relaxers.append(None) # create slider s = servoSlider(self, min_angle, max_angle, name, i) servoSizer.Add(s.enabled,(i,0), wx.GBSpan(1,1),wx.ALIGN_CENTER_VERTICAL) servoSizer.Add(s.position,(i,1), wx.GBSpan(1,1),wx.ALIGN_CENTER_VERTICAL) self.servos.append(s) i += 1 # add everything servoBox.Add(servoSizer) sizer.Add(servoBox, (0,1), wx.GBSpan(1,1), wx.EXPAND|wx.TOP|wx.BOTTOM|wx.RIGHT,5) self.Bind(wx.EVT_CHECKBOX, self.enableSliders) # now we can subscribe rospy.Subscriber('joint_states', JointState, self.stateCb) # timer for output self.timer = wx.Timer(self, self.TIMER_ID) self.timer.Start(50) wx.EVT_CLOSE(self, self.onClose) wx.EVT_TIMER(self, self.TIMER_ID, self.onTimer) # bind the panel to the paint event wx.EVT_PAINT(self, self.onPaint) self.dirty = 1 self.onPaint() self.SetSizerAndFit(sizer) self.Show(True)
def __init__(self, parent, log): self.log = log wx.Frame.__init__(self, parent, -1, "Shaped Window", style=wx.FRAME_SHAPED | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP) self.hasShape = False self.delta = (0, 0) self.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_RIGHT_UP, self.OnExit) self.Bind(wx.EVT_PAINT, self.OnPaint) self.bmp = wx.Bitmap(gImgDir + os.sep + 'shapedframe.png', wx.BITMAP_TYPE_PNG) w, h = self.bmp.GetWidth(), self.bmp.GetHeight() self.SetClientSize((w, h)) if wx.Platform != "__WXMAC__": # wxMac clips the tooltip to the window shape, YUCK!!! self.SetToolTip( wx.ToolTip( "Right-click to close the window\n" "Double-click the image to set/unset the window shape")) if wx.Platform == "__WXGTK__": # wxGTK requires that the window be created before you can # set its shape, so delay the call to SetWindowShape until # this event. self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape) else: # On wxMSW and wxMac the window has already been created, so go for it. self.SetWindowShape() dc = wx.ClientDC(self) dc.DrawBitmap(self.bmp, 0, 0, True) #----- Start ShapedBitmapButton Stuff -----# bmp1 = wx.Bitmap(gImgDir + os.sep + 'shapedbutton-normal64x40.png') bmp2 = wx.Bitmap(gImgDir + os.sep + 'shapedbutton-pressed64x40.png') bmp3 = wx.Bitmap(gImgDir + os.sep + 'shapedbutton-hover64x40.png') sbbtn1 = SBB.ShapedBitmapButton(self, -1, bitmap=bmp1, pressedBmp=bmp2, hoverBmp=bmp3, disabledBmp=None, parentBgBmp=self.bmp, pos=(104, 10)) img1 = wx.Image(gImgDir + os.sep + 'shapedbutton-hover64x40.png').Rotate90().Mirror(True) img2 = wx.Image(gImgDir + os.sep + 'shapedbutton-normal64x40.png').Rotate90().Mirror(True) img3 = wx.Image(gImgDir + os.sep + 'shapedbutton-pressed64x40.png').Rotate90().Mirror( True) bmp1 = img1.ConvertToBitmap() bmp2 = img2.ConvertToBitmap() bmp3 = img3.ConvertToBitmap() sbbtn2 = SBB.ShapedBitmapButton(self, -1, bitmap=bmp1, pressedBmp=bmp2, hoverBmp=bmp3, disabledBmp=None, parentBgBmp=self.bmp, pos=(10, 104)) sbbtn3 = SBB.ShapedBitmapButton( self, -1, bitmap=wx.Bitmap(gImgDir + os.sep + 'bigcheck128.png'), pressedBmp=wx.Bitmap(gImgDir + os.sep + 'bigcheck128-pressed.png'), hoverBmp=wx.Bitmap(gImgDir + os.sep + 'bigcheck128-hover.png'), disabledBmp=wx.Bitmap(gImgDir + os.sep + 'bigcheck128-disabled.png'), parentBgBmp=self.bmp, pos=(48, 200), # style=wx.BORDER_SIMPLE | wx.WANTS_CHARS ) sbbtn4 = SBB.ShapedBitmapButton( self, -1, bitmap=wx.Bitmap(gImgDir + os.sep + 'shapedbutton-normal.png'), pressedBmp=wx.Bitmap(gImgDir + os.sep + 'shapedbutton-pressed.png'), hoverBmp=wx.Bitmap(gImgDir + os.sep + 'shapedbutton-hover.png'), disabledBmp=wx.Bitmap(gImgDir + os.sep + 'shapedbutton-disabled.png'), parentBgBmp=self.bmp, label='New Widget', # labelColour=wx.WHITE, labelRotation=27.0, labelPosition=(4, 68), labelFont=wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), pos=(192, 200), # style=wx.BORDER_SIMPLE ) sbbtn4.SetToolTip(wx.ToolTip('This is a ShapedBitmapButton.')) sbbtn4.Bind(wx.EVT_TIMER, self.OnTimer) sbbtn4.timer = wx.Timer(sbbtn4) sbbtn4.timer.Start(500) # Every half a second. sbbtn5 = SBB.ShapedBitmapButton( self, wx.ID_CLOSE, bitmap=wx.Bitmap(gImgDir + os.sep + 'bigx128.png'), pressedBmp=wx.Bitmap(gImgDir + os.sep + 'bigx128-pressed.png'), hoverBmp=wx.Bitmap(gImgDir + os.sep + 'bigx128-hover.png'), disabledBmp=wx.Bitmap(gImgDir + os.sep + 'bigx128-disabled.png'), parentBgBmp=self.bmp, pos=(336, 200), # style=wx.BORDER_SIMPLE ) sbbtn6 = SBB.ShapedBitmapButton( self, -1, bitmap=wx.Bitmap(gImgDir + os.sep + 'shapedbitmapbutton_text_normal.png'), pressedBmp=wx.Bitmap(gImgDir + os.sep + 'shapedbitmapbutton_text_pressed.png'), hoverBmp=wx.Bitmap(gImgDir + os.sep + 'shapedbitmapbutton_text_hover.png'), parentBgBmp=self.bmp, pos=(176, 68), # style=wx.BORDER_SIMPLE ) # Lets bind all the ShapedBitmapButtons. for child in self.GetChildren(): child.Bind(wx.EVT_BUTTON, self.OnButton) self.Centre()
def __init__(self, parent): wx.Panel.__init__(self, parent) self.transmitter=None self.figure = Figure(figsize=(0.5, 0.5)) self.axes = self.figure.add_subplot(111, axisbg='0.1') self.canvas = FigureCanvas(self, -1, self.figure) setup_plot(self.figure, self.axes) self.vsizer = wx.BoxSizer(wx.VERTICAL) self.sizer_sizer = wx.BoxSizer(wx.HORIZONTAL) self.tx_sizer = wx.BoxSizer(wx.VERTICAL) self.rx_sizer = wx.BoxSizer(wx.VERTICAL) self.settings_sizer = wx.BoxSizer(wx.VERTICAL) self.preset_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_offset_sizer = wx.BoxSizer(wx.HORIZONTAL) self.gain_sizer = wx.BoxSizer(wx.HORIZONTAL) self.ppm_sizer = wx.BoxSizer(wx.HORIZONTAL) self.squelch_sizer = wx.BoxSizer(wx.HORIZONTAL) self.lpf_sizer = wx.BoxSizer(wx.HORIZONTAL) self.fm_deviation_sizer = wx.BoxSizer(wx.HORIZONTAL) self.source_sizer = wx.BoxSizer(wx.HORIZONTAL) self.destination_sizer = wx.BoxSizer(wx.HORIZONTAL) self.mode_sizer = wx.BoxSizer(wx.HORIZONTAL) self.presets = wx.Choice(self, choices=sorted(presets.keys())) self.save_preset = wx.Button(self, label="Save as...") self.del_preset = wx.Button(self, label="delete") self.frequency = wx.TextCtrl(self, value="30") self.frequency_units = wx.Choice(self, choices=units) self.rx_frequency_offset = wx.TextCtrl(self, value="0") self.rx_gain = wx.TextCtrl(self, value="automatic") self.rx_ppm = wx.TextCtrl(self, value="0") self.rx_squelch = wx.TextCtrl(self, value="0") self.lpf = wx.TextCtrl(self, value="3000") self.fm_deviation = wx.TextCtrl(self, value="5000") self.fm_deviation.Disable() self.mode = wx.Choice(self, choices=modes) self.source = wx.Choice(self, choices=sources) self.destination = wx.Choice(self, choices=sources) self.input_file_button = filebrowse.FileBrowseButton(self, labelText="Input File:") self.device_button = filebrowse.FileBrowseButton(self, labelText="Transmitter:", initialValue="/dev/ttyUSB1") self.input_file_button.Disable() self.output_file_button = filebrowse.FileBrowseButton(self, labelText="Output File:", fileMode=wx.SAVE) self.output_file_button.Disable() self.tx = wx.ToggleButton(self, label="TX") self.rx = wx.ToggleButton(self, label="RX") self.Bind(wx.EVT_TOGGLEBUTTON, self.on_transmit, self.tx) self.Bind(wx.EVT_TOGGLEBUTTON, self.on_receive, self.rx) self.Bind(wx.EVT_CHOICE, self.on_mode, self.mode) self.Bind(wx.EVT_CHOICE, self.on_source, self.source) self.Bind(wx.EVT_CHOICE, self.on_destination, self.destination) self.Bind(wx.EVT_CHOICE, self.on_preset, self.presets) self.Bind(wx.EVT_BUTTON, self.on_save_preset, self.save_preset) self.Bind(wx.EVT_BUTTON, self.on_del_preset, self.del_preset) self.vsizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL) self.preset_sizer.Add(wx.StaticText(self, label="Preset: "), 0, wx.CENTER) self.preset_sizer.Add(self.presets, 1) self.preset_sizer.Add(self.save_preset, 0.5) self.preset_sizer.Add(self.del_preset, 0.5) self.vsizer.Add(self.preset_sizer, 0, wx.EXPAND | wx.ALL, 5) self.tx_sizer.Add(wx.StaticText(self, label="Transmitter Settings"), 0, wx.CENTER | wx.ALL, 10) self.freq_sizer.Add(wx.StaticText(self, label="Frequency: "), 0, wx.CENTER) self.freq_sizer.Add(self.frequency, 1) self.freq_sizer.Add(self.frequency_units, 0.5) self.tx_sizer.Add(self.freq_sizer, 0, wx.EXPAND | wx.ALL, 3) self.lpf_sizer.Add(wx.StaticText(self, label="Audio Cutoff (Hz): "), 0, wx.CENTER) self.lpf_sizer.Add(self.lpf, 1) self.tx_sizer.Add(self.lpf_sizer, 0, wx.EXPAND | wx.ALL, 5) self.fm_deviation_sizer.Add(wx.StaticText(self, label="FM Deviation (Hz): "), 0, wx.CENTER) self.fm_deviation_sizer.Add(self.fm_deviation, 1) self.tx_sizer.Add(self.fm_deviation_sizer, 0, wx.EXPAND | wx.ALL, 5) self.mode_sizer.Add(wx.StaticText(self, label="Mode:"), 0, wx.CENTRE) self.mode_sizer.Add(self.mode, 1, wx.EXPAND | wx.ALL) self.tx_sizer.Add(self.mode_sizer, 0, wx.EXPAND | wx.ALL, 5) self.source_sizer.Add(wx.StaticText(self, label="Source:"), 0, wx.CENTRE) self.source_sizer.Add(self.source, 1, wx.EXPAND | wx.ALL) self.tx_sizer.Add(self.source_sizer, 0, wx.EXPAND | wx.ALL, 5) self.tx_sizer.Add(self.input_file_button, 0, wx.EXPAND | wx.ALL, 5) self.tx_sizer.Add(self.device_button, 0, wx.EXPAND | wx.ALL, 5) self.tx_sizer.Add(self.tx, 0, wx.EXPAND | wx.ALL) self.sizer_sizer.Add(self.tx_sizer, 1, wx.EXPAND | wx.ALL) self.sizer_sizer.Add(wx.StaticLine(self, style=wx.LI_VERTICAL), 0, wx.ALL|wx.EXPAND, 5) self.rx_sizer.Add(wx.StaticText(self, label="Receiver Settings"), 0, wx.CENTRE | wx.ALL, 10) self.freq_offset_sizer.Add(wx.StaticText(self, label="Frequency Offset (Hz):"), 0, wx.CENTRE) self.freq_offset_sizer.Add(self.rx_frequency_offset, 1, wx.EXPAND | wx.ALL) self.rx_sizer.Add(self.freq_offset_sizer, 0, wx.EXPAND | wx.ALL, 5) self.gain_sizer.Add(wx.StaticText(self, label="Gain (dB):"), 0, wx.CENTRE) self.gain_sizer.Add(self.rx_gain, 1) self.rx_sizer.Add(self.gain_sizer, 0, wx.EXPAND | wx.ALL, 5) self.ppm_sizer.Add(wx.StaticText(self, label="Frequency Correction (ppm):"), 0, wx.CENTRE) self.ppm_sizer.Add(self.rx_ppm, 1) self.rx_sizer.Add(self.ppm_sizer, 0, wx.EXPAND | wx.ALL, 5) self.squelch_sizer.Add(wx.StaticText(self, label="Squelch (dB):"), 0, wx.CENTRE) self.squelch_sizer.Add(self.rx_squelch, 1) self.rx_sizer.Add(self.squelch_sizer, 0, wx.EXPAND | wx.ALL, 5) self.rx_sizer.Add((10,10), 1, wx.EXPAND | wx.ALL) self.destination_sizer.Add(wx.StaticText(self, label="Destination:"), 0, wx.CENTRE) self.destination_sizer.Add(self.destination, 1, wx.EXPAND | wx.ALL) self.rx_sizer.Add(self.destination_sizer, 0, wx.EXPAND | wx.ALL, 5) self.rx_sizer.Add(self.output_file_button, 0, wx.EXPAND | wx.ALL, 5) self.rx_sizer.Add(self.rx, 0, wx.EXPAND | wx.ALL) self.sizer_sizer.Add(self.rx_sizer, 1, wx.EXPAND | wx.ALL) self.vsizer.Add(self.sizer_sizer, 0, wx.EXPAND, 10) self.SetSizer(self.vsizer) self.Fit() self.line = None self.t1 = wx.Timer(self) self.t1.Start(100) self.Bind(wx.EVT_TIMER, self.on_timer) self.transmitter = None self.transmitter_thread = None self.transmitter_pipe = None self.receiver_pipe = None self.sox_pipe = None
def __init__(self, parent=None): super(SetupWizard, self).__init__(parent, id=wx.ID_ANY, title=u"FreeMyCall Setup Wizard", pos=wx.DefaultPosition, size=wx.Size(596, 385), style=wx.NO_BORDER | wx.FRAME_SHAPED) self.SetBackgroundColour(wx.Colour(255, 255, 255, 0)) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) image = wx.Image(u"images/wizard/mask.png", wx.BITMAP_TYPE_PNG) image.SetMaskColour(255, 0, 0) image.SetMask(True) self.bmp = wx.BitmapFromImage(image) self.SetShape(wx.RegionFromBitmap(self.bmp)) self.bgpanel = BackgroundPanel(u"images/wizard/background.png", self, wx.ID_ANY, wx.DefaultPosition, size=(596, 385), style=wx.TAB_TRAVERSAL | wx.NO_BORDER) self.bgpanel.SetMinSize(wx.Size(596, 385)) self.bgpanel.Bind(wx.EVT_MOTION, self.OnMouse) self.bgpanel.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.bgpanel.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.next_button = wx.Button(self.bgpanel, wx.ID_ANY, u"Next", wx.Point(491, 340), wx.DefaultSize, 0) self.next_button.Bind(wx.EVT_BUTTON, self.OnClickNext) self.prev_button = wx.Button(self.bgpanel, wx.ID_ANY, u"Previous", wx.Point(386, 340), wx.DefaultSize, 0) self.prev_button.Bind(wx.EVT_BUTTON, self.OnClickPrev) self.prev_button.Disable() #################################################### # # Describing the panels here # #################################################### self.panel1 = BackgroundPanel(u"", self.bgpanel, wx.ID_ANY, wx.Point(2, 88), wx.Size(591, 230), wx.TAB_TRAVERSAL | wx.NO_BORDER) # self.panel1.SetMinSize(wx.Size(591, 230)) text_panel1_s1 = TransparentText(self.panel1, wx.ID_ANY, u"Step 1: Audio output device", wx.DefaultPosition, wx.Size(200, 20), 0) text_panel1_s1.SetFont(wx.Font(11, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_BOLD, False, "Arial")) text_panel1_s1.SetForegroundColour(wx.Colour(3, 106, 157)) # self.text_playtone = TransparentText(self.panel1, wx.ID_ANY, u"Not playing", wx.DefaultPosition, # wx.Size(100, 20), 0) self.text_playtone = wx.StaticText(self.panel1, label=u"Not playing") self.text_playtone.SetFont(wx.Font(9, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_BOLD, False, "Arial")) self.text_playtone.SetForegroundColour(wx.Colour(102, 102, 102)) self.text_playtone.SetBackgroundColour(wx.WHITE) htext = u"Select the speaker or headphone that you would\n" \ u"like to use as the audio output device.\n" \ u"Headphones are recommended over speakers." helptext = TransparentText(self.panel1, wx.ID_ANY, htext, wx.DefaultPosition, wx.Size(200, 20), 0) helptext.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_NORMAL, False, "Arial")) helptext.SetForegroundColour(wx.Colour(3, 106, 157)) spk_icon = TransparentBitmap(u'images/bar/speaker-button.png', self.panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) # Get the self.spk_cb = wx.ComboBox(self.panel1, wx.ID_ANY, u"", wx.DefaultPosition, wx.Size(190, 32), "", wx.CB_READONLY | wx.TRANSPARENT_WINDOW) self.spk_cb.SetMinSize(wx.Size(190, 32)) self.button_playtone = wx.Button(self.panel1, wx.ID_ANY, u"Play test tone", wx.DefaultPosition, wx.DefaultSize, 0) self.button_playtone.Bind(wx.EVT_BUTTON, self.playTestTone) text_panel1_s1.SetPosition(wx.Point(60, 20)) spk_icon.SetPosition(wx.Point(75, 55)) spk_icon.SetSize(spk_icon.DoGetBestSize()) self.spk_cb.SetPosition(wx.Point(185, 60)) self.button_playtone.SetPosition(wx.Point(405, 58)) self.text_playtone.SetPosition(wx.Point(410, 100)) helptext.SetPosition(wx.Point(185, 160)) self.panel1.Show() ########################################################### # # Panel 2 (mic) starts # ############################################################ self.panel2 = BackgroundPanel(u"", self.bgpanel, wx.ID_ANY, wx.Point(2, 88), wx.Size(591, 230), wx.TAB_TRAVERSAL | wx.NO_BORDER) self.panel2.SetMinSize(wx.Size(591, 230)) self.mic_cb = wx.ComboBox(self.panel2, wx.ID_ANY, u"", wx.DefaultPosition, wx.Size(190, 32), "", wx.CB_READONLY | wx.TRANSPARENT_WINDOW) self.mic_cb.SetMinSize(wx.Size(190, 32)) mic_icon = TransparentBitmap(u'images/bar/mic-button.png', self.panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) text_panel2_s1 = TransparentText(self.panel2, wx.ID_ANY, u"Step 2: Audio input device", wx.DefaultPosition, wx.Size(200, 20), 0) text_panel2_s1.SetFont(wx.Font(11, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_BOLD, False, "Arial")) text_panel2_s1.SetForegroundColour(wx.Colour(3, 106, 157)) # htext2 = u"Select the speaker or headphone that you would\n" \ # u"like to use as the audio output device.\n" \ # u"Headphones are recommended over speakers." # helptext2 = TransparentText(self.panel2, wx.ID_ANY, htext2, wx.DefaultPosition, # wx.Size(200, 20), 0) # helptext2.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_NORMAL, False, "Arial")) # helptext2.SetForegroundColour(wx.Colour(3, 106, 157)) text_panel2_s1.SetPosition(wx.Point(60, 20)) mic_icon.SetPosition(wx.Point(75, 55)) mic_icon.SetSize(spk_icon.DoGetBestSize()) self.mic_cb.SetPosition(wx.Point(185, 60)) # helptext2.SetPosition(wx.Point(185, 160)) self.panel2.Hide() ########################################################### # # Panel 3 (review) starts # ############################################################ self.panel3 = BackgroundPanel(u"", self.bgpanel, wx.ID_ANY, wx.Point(2, 88), wx.Size(591, 230), wx.TAB_TRAVERSAL | wx.NO_BORDER) self.panel3.SetMinSize(wx.Size(591, 230)) text_panel3_s1 = TransparentText(self.panel3, wx.ID_ANY, u"Step 3: Review Settings", wx.DefaultPosition, wx.Size(200, 20), 0) text_panel3_s1.SetFont(wx.Font(11, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_BOLD, False, "Arial")) text_panel3_s1.SetForegroundColour(wx.Colour(3, 106, 157)) self.mictext = TransparentText(self.panel3, wx.ID_ANY, u"mic name", (50, 50), wx.Size(200, 20), 0) self.spktext = TransparentText(self.panel3, wx.ID_ANY, u"spk name", (50, 50), wx.Size(200, 20), 0) self.spktext.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_NORMAL, False, "Arial")) self.spktext.SetForegroundColour(wx.Colour(3, 106, 157)) self.mictext.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_NORMAL, False, "Arial")) self.mictext.SetForegroundColour(wx.Colour(3, 106, 157)) p3_mic_icon = TransparentBitmap(u'images/bar/mic-button.png', self.panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) p3_spk_icon = TransparentBitmap(u'images/bar/speaker-button.png', self.panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0) htext3 = u"Click finish to save settings and open dialer." helptext3 = TransparentText(self.panel3, wx.ID_ANY, htext3, wx.DefaultPosition, wx.Size(200, 20), 0) helptext3.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, 90, wx.FONTWEIGHT_NORMAL, False, "Arial")) helptext3.SetForegroundColour(wx.Colour(3, 106, 157)) text_panel3_s1.SetPosition(wx.Point(60, 20)) p3_spk_icon.SetPosition(wx.Point(75, 55)) p3_mic_icon.SetPosition(wx.Point(75, 95)) self.spktext.SetPosition(wx.Point(185, 60)) self.mictext.SetPosition(wx.Point(185, 100)) helptext3.SetPosition(wx.Point(185, 190)) self.panel3.Hide() self.panel3.Bind(wx.EVT_SHOW, self.OnShowReview) self.spk_cb.Bind(wx.EVT_COMBOBOX, self.audioDevChange) self.mic_cb.Bind(wx.EVT_COMBOBOX, self.audioDevChange) ################################################################################## ################################################################################## self.m_pages = [self.panel1, self.panel2, self.panel3] self.m_index = 0 self.app = wx.GetApp() self.tone_timer = wx.Timer(self, TIMER_TESTTONE_ID) wx.EVT_TIMER(self, TIMER_TESTTONE_ID, self.timerTick) self.header_distance = 73 self.dragenable = False self.playenable = True self.Centre(wx.BOTH)
def __init__(self, parent, tbstyle=TB_SIMPLE, windowstyle=TB_DEFAULT_STYLE, closingstyle=TB_ONTIME, scrollType=TB_SCR_TYPE_DU): """ Default class constructor. :param `parent`: the window parent; :param `tbstyle`: the :class:`ToasterBox` main style. Can be one of the following bits: ====================== ======= ================================ `ToasterBox` Style Value Description ====================== ======= ================================ ``TB_SIMPLE`` 0x1 A simple :class:`ToasterBox`, with background image and text customization can be created ``TB_COMPLEX`` 0x2 `ToasterBoxes` with different degree of complexity can be created. You can add as many controls as you want, provided that you call the :meth:`~ToasterBox.AddPanel` method and pass to it a dummy frame and a :class:`Panel`. ====================== ======= ================================ :param `windowstyle`: this parameter influences the visual appearance of :class:`ToasterBox`, and can be one of the following styles: ====================== ========== ================================ Window Style Hex Value Description ====================== ========== ================================ ``TB_DEFAULT_STYLE`` 0x2008002 Default window style for :class:`ToasterBox`, with no caption nor close box. ``TB_CAPTION`` 0x22009806 :class:`ToasterBox` will have a caption, with the possibility to set a title for the :class:`ToasterBox` frame, and a close box. ====================== ========== ================================ :param `closingstyle`: the closing style for :class:`ToasterBox`. Can be one of the following bits: ==================== =========== ================================================== Closing Styles Hex Value Description ==================== =========== ================================================== ``TB_ONTIME`` 0x1 :class:`ToasterBox` will close after a specified amount of time. ``TB_ONCLICK`` 0x2 :class:`ToasterBox` can be closed by clicking anywhere on the :class:`ToasterBox` frame. ==================== =========== ================================================== :param `scrollType`: the scrolling direction for :class:`ToasterBox`. Can be one of the following bits: ==================== =========== ================================================== Scroll Styles Hex Value Description ==================== =========== ================================================== ``TB_SCR_TYPE_UD`` 0x1 :class:`ToasterBox` will scroll from up to down ``TB_SCR_TYPE_DU`` 0x2 :class:`ToasterBox` will scroll from down to up ``TB_SCR_TYPE_FADE`` 0x4 :class:`ToasterBox` will fade in/out (without scrolling). ==================== =========== ================================================== """ self._parent = parent self._sleeptime = 10 self._pausetime = 1700 self._popuptext = "default" self._popupposition = wx.Point(100, 100) self._popuptop = wx.Point(0, 0) self._popupsize = wx.Size(150, 170) self._usefocus = True self._originalfocus = wx.Window.FindFocus() self._backgroundcolour = wx.WHITE self._foregroundcolour = wx.BLACK self._textfont = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Verdana") self._bitmap = None self._tbstyle = tbstyle self._windowstyle = windowstyle self._closingstyle = closingstyle self._scrollType = scrollType self._panel = None self._bottomright = wx.Point(wx.GetDisplaySize().GetWidth(), wx.GetDisplaySize().GetHeight()) if parent is not None: parent.Bind(wx.EVT_ICONIZE, lambda evt: [w.Hide() for w in winlist]) self._moveTimer = wx.Timer(parent, -1) parent.Bind(wx.EVT_TIMER, self.OnMoveTimer, self._moveTimer) self._tb = ToasterBoxWindow(self._parent, self, self._tbstyle, self._windowstyle, self._closingstyle, scrollType=self._scrollType)
def __init__(self): super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion()) wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object( c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [ wx.NewId() for line in xrange(10) ] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [ wx.NewId() for line in xrange(10) ] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Reload platform\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _("Clear platform")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...\tCTRL+G")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Open Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Reset Profile to default")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _("File")) toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _("Auto Firmware Update...")) self.Bind(wx.EVT_MENU, self.OnAutoFirmwareUpdate, i) #i = toolsMenu.Append(-1, _("Copy profile to clipboard")) #self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i) toolsMenu.AppendSeparator() self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() self.bedLevelWizardMenuItem = expertMenu.Append( -1, _("Run bed leveling wizard...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append( -1, _("Run head offset wizard...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, _("Open YouMagine website...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _("About Cura...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style=wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) #Preview window self.scene = sceneView.SceneView(self.rightPane) ##Gui components## self.simpleSettingsPanel = simpleMode.simpleModePanel( self.leftPane, self.scene.sceneUpdated) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour( self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth() / 2, wx.Display().GetClientArea().GetHeight() / 2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) #self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx, posy)) if width > 0 and height > 0: self.SetSize((width, height)) self.normalSashPos = int( profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint( (self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800, 600)) self.Centre() self.updateSliceMode() self.scene.SetFocus() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount( ) if pluginCount == 1: self.scene.notification.message( "Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message( "Warning: %i plugins from the previous session are still active." % pluginCount)
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) pmainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0) i = self.clonesChoice.Append("Omega Clone", None) self.clonesChoice.SetSelection(i) hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5) self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...") hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5) self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch) sChar = Character.getInstance() self.alphaClones = sChar.getAlphaCloneList() char = self.charEditor.entityEditor.getActiveEntity() for clone in self.alphaClones: i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID) if clone.ID == char.alphaCloneID: self.clonesChoice.SetSelection(i) self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged) self.clonesChoice.SetToolTip( wx.ToolTip( "Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels." )) pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5) # Set up timer for skill search self.searchTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch, self.searchTimer) tree = self.skillTreeListCtrl = TreeListCtrl( self, wx.ID_ANY, style=wx.dataview.TL_DEFAULT_STYLE) pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5) self.imageList = wx.ImageList(16, 16) tree.SetImageList(self.imageList) self.skillBookImageId = self.imageList.Add( wx.Icon(BitmapLoader.getBitmap("skill_small", "gui"))) self.skillBookDirtyImageId = self.imageList.Add( wx.Icon(BitmapLoader.getBitmap("skill_small_red", "gui"))) tree.AppendColumn("Skill") tree.AppendColumn("Level", align=wx.ALIGN_CENTER) # tree.SetMainColumn(0) self.root = tree.GetRootItem() # self.root = tree.AppendItem(root, "Skills") # # tree.SetItemText(self.root, 1, "Levels") # first one doesn't work right in Windows. Second one doesn't work right in GTK. Together, we make sure it works. # Gotta love wx tree.SetColumnWidth(0, 525) tree.SetColumnWidth(1, 100) self.btnSecStatus = wx.Button( self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0)) self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus) self.populateSkillTree() tree.Bind(wx.dataview.EVT_TREELIST_ITEM_ACTIVATED, self.expand) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_EXPANDING, self.expandLookup) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.spawnMenu) bSizerButtons = wx.BoxSizer(wx.HORIZONTAL) bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5) bSizerButtons.AddStretchSpacer() importExport = (("Import", wx.ART_FILE_OPEN, "from"), ("Export", wx.ART_FILE_SAVE_AS, "to")) for name, art, direction in importExport: bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON) btn = wx.BitmapButton(self, wx.ID_ANY, bitmap) btn.SetMinSize(btn.GetSize()) btn.SetMaxSize(btn.GetSize()) btn.Layout() setattr(self, "{}Btn".format(name.lower()), btn) btn.Enable(True) btn.SetToolTip("%s skills %s clipboard" % (name, direction)) bSizerButtons.Add( btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT | wx.ALL, 5) btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Skills".format(name.lower()))) pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5) # bind the Character selection event self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged) self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree) # Context menu stuff self.idUnlearned = wx.NewId() self.levelIds = {} self.idLevels = {} self.levelIds[self.idUnlearned] = "Not learned" for level in range(6): id = wx.NewId() self.levelIds[id] = level self.idLevels[level] = id self.revertID = wx.NewId() self.saveID = wx.NewId() self.SetSizer(pmainSizer)
def __init__(self): wx.Frame.__init__(self, None, -1, 'wxutil demo', style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER | wx.TAB_TRAVERSAL) self.SetTitle('wxutil demo') self.SetFont(Font(11)) self.set_menu() self.statusbar = self.CreateStatusBar(2, 1) self.statusbar.SetStatusWidths([-2, -1]) statusbar_fields = ['Initializing....', ' '] for i in range(len(statusbar_fields)): self.statusbar.SetStatusText(statusbar_fields[i], i) self.Bind(wx.EVT_CLOSE, self.onExit) panel = GridPanel(self, nrows=8, ncols=4) tctrl_name = TextCtrl(panel, value='', action=self.onName, size=(250, -1)) lctrl_addr = LabeledTextCtrl(self, value='<>', action=self.onAddr, labeltext=' Address: ', size=(250, -1)) lab3 = HyperText(panel, ' FloatCtrl: ', size=(100, -1), action=self.onHyperText) val3 = FloatCtrl(panel, '3', action=self.onFloat1, precision=2, minval=0, maxval=1000, size=(250, -1)) lab4 = HyperText(panel, ' FloatSpin: ', size=(100, -1), action=self.onHyperText) val4 = FloatSpin(panel, '12.2', action=self.onFloatSpin, digits=2, increment=0.1, size=(250, -1)) labx = HyperText(panel, ' NumericCombo: ', size=(100, -1), action=self.onHyperText) steps = make_steps(prec=1, tmin=0, tmax=100) valx = NumericCombo(panel, steps, precision=1) self.choice1 = Choice(panel, size=(200, -1), action=self.onChoice) self.choice1.SetChoices(['Apple', 'Banana', 'Cherry']) yesno = YesNo(panel) check1 = Check(panel, label='enable? ', action=self.onCheck) btn1 = Button(panel, label='Start', size=(100, -1), action=self.onStart) pinbtn = BitmapButton(panel, get_icon('pin'), size=(50, -1), action=partial(self.onBMButton, opt='pin1'), tooltip='use last point selected from plot') togbtn = ToggleButton(panel, 'Press Me', action=self.onToggleButton, size=(100, -1), tooltip='do it, do it now, you will like it') browse_btn = Button(panel, 'Open File', action=self.onFileOpen, size=(150, -1)) okcancel = OkCancel(panel, onOK=self.onOK, onCancel=self.onCancel) ptable_btn = Button(panel, 'Show Periodic Table', action=self.onPTable, size=(175, -1)) edlist_btn = Button(panel, 'Show Editable Listbox', action=self.onEdList, size=(175, -1)) filelist_btn = Button(panel, 'Show File CheckList', action=self.onFileList, size=(175, -1)) panel.AddText(' Name: ', style=LEFT) panel.Add(tctrl_name, dcol=2) panel.Add(lctrl_addr.label, newrow=True) panel.Add(lctrl_addr, dcol=2) panel.Add(lab3, newrow=True) panel.Add(val3, dcol=3) panel.Add(lab4, newrow=True) panel.Add(val4, dcol=3) panel.Add(labx, newrow=True) panel.Add(valx, dcol=3) panel.AddText(' Choice : ', newrow=True) panel.Add(check1) panel.Add(self.choice1) panel.AddText(' Yes or No: ', newrow=True) panel.Add(yesno) panel.Add(HLine(panel, size=(500, -1)), dcol=3, newrow=True) panel.Add(btn1, newrow=True) panel.Add(pinbtn) panel.Add(togbtn) panel.Add(browse_btn, newrow=True) panel.Add(ptable_btn) panel.Add(edlist_btn, newrow=True) panel.Add(filelist_btn) panel.Add(okcancel, newrow=True) panel.pack() self.timer = wx.Timer(self) self.last_time = time.time() self.Bind(wx.EVT_TIMER, self.onTimer, self.timer) fsizer = wx.BoxSizer(wx.VERTICAL) fsizer.Add(panel, 0, LEFT | wx.EXPAND) wx.CallAfter(self.init_timer) psize = panel.GetBestSize() self.SetSize((psize[0] + 5, psize[1] + 25)) pack(self, fsizer) self.Refresh()
def __init__(self, parent, saver): pi = 3.1415 self.start_flight_time = 0 wx.Frame.__init__(self, parent, -1, "Flight Recorder", size=(800, 600)) #tworzy "layout" programu self.panel1 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER, size=(400, 300)) self.panel2 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER, pos=(400, 0), size=(400, 300)) self.panel3 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER, pos=(0, 300), size=(400, 300)) self.panel4 = wx.Panel(self, -1, style=wx.SUNKEN_BORDER, pos=(400, 300), size=(400, 300)) self.panel1.SetBackgroundColour("LIGHT GREY") self.panel2.SetBackgroundColour("LIGHT GREY") self.panel3.SetBackgroundColour("LIGHT GREY") self.panel4.SetBackgroundColour("LIGHT GREY") box = wx.BoxSizer(wx.VERTICAL) box.Add(self.panel1, 2, wx.EXPAND) box.Add(self.panel2, 1, wx.EXPAND) #predkosciomierz self.speed = SM.SpeedMeter( self.panel2, agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 30), size=(400, 300)) # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!) self.speed.SetAngleRange(-pi / 6, 7 * pi / 6) # Create The Intervals That Will Divide Our SpeedMeter In Sectors intervals = range(0, 901, 50) self.speed.SetIntervals(intervals) # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed) # Usually This Is Black colours = [wx.BLACK] * 18 self.speed.SetIntervalColours(colours) # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals ticks = [str(interval) for interval in intervals] self.speed.SetTicks(ticks) # Set The Ticks/Tick Markers Colour self.speed.SetTicksColour(wx.WHITE) # We Want To Draw 5 Secondary Ticks Between The Principal Ticks self.speed.SetNumberOfSecondaryTicks(5) # Set The Font For The Ticks Markers self.speed.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL)) # Set The Text In The Center Of SpeedMeter self.speed.SetMiddleText("Km/h") # Assign The Colour To The Center Text self.speed.SetMiddleTextColour(wx.WHITE) # Assign A Font To The Center Text self.speed.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD)) # Set The Colour For The Hand Indicator self.speed.SetHandColour(wx.Colour(255, 50, 0)) # Do Not Draw The External (Container) Arc. Drawing The External Arc May # Sometimes Create Uglier Controls. Try To Comment This Line And See It # For Yourself! self.speed.DrawExternalArc(False) # Set The Current Value For The SpeedMeter self.speed.SetSpeedValue(1) #wysokosciomierz self.alt = SM.SpeedMeter(self.panel3, agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(350, 250)) # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!) self.alt.SetAngleRange(-pi, pi) # Create The Intervals That Will Divide Our SpeedMeter In Sectors intervals = range(0, 11, 1) self.alt.SetIntervals(intervals) # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed) # Usually This Is Black colours = [wx.BLACK] * 10 self.alt.SetIntervalColours(colours) # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals ticks = [str(interval) for interval in intervals] self.alt.SetTicks(ticks) # Set The Ticks/Tick Markers Colour self.alt.SetTicksColour(wx.WHITE) # We Want To Draw 5 Secondary Ticks Between The Principal Ticks self.alt.SetNumberOfSecondaryTicks(5) # Set The Font For The Ticks Markers self.alt.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL)) # Set The Text In The Center Of SpeedMeter self.alt.SetMiddleText("0") # Assign The Colour To The Center Text self.alt.SetMiddleTextColour(wx.WHITE) # Assign A Font To The Center Text self.alt.SetMiddleTextFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) # Set The Colour For The Hand Indicator self.alt.SetHandColour(wx.Colour(255, 255, 0)) # Do Not Draw The External (Container) Arc. Drawing The External Arc May # Sometimes Create Uglier Controls. Try To Comment This Line And See It # For Yourself! self.alt.DrawExternalArc(False) # Set The Current Value For The SpeedMeter self.alt.SetSpeedValue(0) #kompass self.com = SM.SpeedMeter(self.panel4, agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS, pos=(0, 0), size=(350, 250)) # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!) self.com.SetAngleRange(-pi, pi) # Create The Intervals That Will Divide Our SpeedMeter In Sectors intervals = range(0, 9, 1) self.com.SetIntervals(intervals) # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed) # Usually This Is Black colours = [wx.BLACK] * 8 self.com.SetIntervalColours(colours) # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals ticks = ["W", "WS", "N", "NE", "E", "EW", "S", "SN", ""] self.com.SetTicks(ticks) # Set The Ticks/Tick Markers Colour self.com.SetTicksColour(wx.GREEN) # We Want To Draw 5 Secondary Ticks Between The Principal Ticks self.com.SetNumberOfSecondaryTicks(2) # Set The Font For The Ticks Markers self.com.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL)) # Set The Text In The Center Of SpeedMeter self.com.SetMiddleText("") # Assign The Colour To The Center Text self.com.SetMiddleTextColour(wx.WHITE) # Assign A Font To The Center Text self.com.SetMiddleTextFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) # Set The Colour For The Hand Indicator self.com.SetHandColour(wx.Colour(255, 0, 0)) # Do Not Draw The External (Container) Arc. Drawing The External Arc May # Sometimes Create Uglier Controls. Try To Comment This Line And See It # For Yourself! self.com.DrawExternalArc(False) # Set The Current Value For The SpeedMeter self.com.SetSpeedValue(2) #zegar led pokazujacy czas lotu self.led = gizmos.LEDNumberCtrl(self.panel1, -1, pos=(10, 30), size=(350, 80), style=gizmos.LED_ALIGN_LEFT) # default colours are green on black self.led.SetBackgroundColour("black") self.led.SetForegroundColour("yellow") #self.on_timer(None) self.timer = wx.Timer(self, -1) # update clock digits every second (1000ms) self.timer.Start(1000) MyFrame.start_flight(self, time.time()) self.Bind(wx.EVT_TIMER, self.since_start) #wywolanie obiektu plane i wystartowanie jako watku, czyli wlaczenie symulatoa self.plane = Plane(self, saver) self.plane.start()
def __init__(self, parent=None, id=wx.ID_ANY, h5in=None, eiger_host="192.168.163.204", eiger_api_ver="1.6.1", bl="BL32XU", monitor_interval=5.): wx.Frame.__init__(self, parent=parent, id=id, title="Adxv launcher for Eiger", size=(540, 500)) self.h5file = None self._lstTrigger_frame_request_workaround = None # dirty workaround.. if h5in: if os.path.isdir(h5in): h5files = filter( lambda x: x.endswith(("_master.h5", "_onlyhits.h5")), sorted(glob.glob(os.path.join(h5in, "*.h5")))) if h5files: self.set_h5file(h5files[0]) else: self.set_h5file(h5in) self.onlyhits_keys = [] self.n_images = -1 self.n_images_each = -1 self.adxv = adxv.Adxv() self.last_monitor_image = None self.bl = bl vbox = wx.BoxSizer(wx.VERTICAL) notebook = wx.Notebook(self, wx.ID_ANY) panel1 = wx.Panel(notebook, wx.ID_ANY) panel2 = wx.Panel(notebook, wx.ID_ANY) # panel1 vbox0 = wx.BoxSizer(wx.VERTICAL) hbox00 = wx.BoxSizer(wx.HORIZONTAL) hbox00.Add(wx.StaticText(panel1, wx.ID_ANY, "File: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.cmbInfile = wx.ComboBox(panel1, wx.ID_ANY, size=(350, 25)) self.cmbInfile.Bind(wx.EVT_COMBOBOX, self.cmbInfile_onChange) self.cmbInfile.Bind(wx.EVT_TEXT_ENTER, self.cmbInfile_onChange) hbox00.Add(self.cmbInfile, 1, flag=wx.EXPAND | wx.RIGHT) self.btnInfile = wx.Button(panel1, wx.ID_ANY, "...", size=(25, 25)) self.btnInfile.Bind(wx.EVT_BUTTON, self.btnInfile_click) self.btnLatest = wx.Button(panel1, wx.ID_ANY, "Latest", size=(50, 25)) self.btnLatest.Bind(wx.EVT_BUTTON, self.btnLatest_click) hbox00.Add(self.btnInfile) hbox00.Add(self.btnLatest) vbox0.Add(hbox00, flag=wx.EXPAND | wx.TOP, border=4) hbox01 = wx.BoxSizer(wx.HORIZONTAL) vbox0.Add(hbox01, flag=wx.EXPAND | wx.TOP, border=4) self.lstTrigger = wx.ListCtrl(panel1, size=(180, 200), style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.lstTrigger.Bind(wx.EVT_LIST_ITEM_SELECTED, self.lstTrigger_onSelected) hbox01.Add(self.lstTrigger) vbox012 = wx.BoxSizer(wx.VERTICAL) hbox01.Add(vbox012, flag=wx.EXPAND | wx.LEFT, border=4) hbox0121 = wx.BoxSizer(wx.HORIZONTAL) vbox012.Add(hbox0121, flag=wx.EXPAND) self.spnFrame = wx.SpinCtrlDouble(panel1, wx.ID_ANY, size=(100, 25), min=1) self.spnFrame.SetDigits( 0) # this is integer actually. but I want arbitrary increments #self.sliFrame = wx.Slider(panel1) self.spnFrame.Bind(wx.EVT_SPINCTRLDOUBLE, self.onTextEnter) self.stFrameRange = wx.StaticText(panel1, wx.ID_ANY, "") hbox0121.Add(wx.StaticText(panel1, wx.ID_ANY, "Frame no: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) hbox0121.Add(self.spnFrame) #, flag=wx.EXPAND|wx.RIGHT) hbox0121.Add(self.stFrameRange, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) #hbox0121.Add(self.sliFrame, 1, flag=wx.EXPAND|wx.RIGHT) self.stShowing = wx.StaticText(panel1, wx.ID_ANY, "Nothing shown") vbox012.Add(self.stShowing, flag=wx.TOP, border=4) hbox0122 = wx.BoxSizer(wx.HORIZONTAL) vbox012.Add(hbox0122, flag=wx.TOP, border=4) self.chkSum = wx.CheckBox(panel1, label="Sum") self.chkSum.Bind(wx.EVT_CHECKBOX, self.chkSum_onChecked) self.spnSumFrame = wx.SpinCtrl(panel1, size=(80, 25)) self.spnSumFrame.Bind(wx.EVT_SPINCTRL, self.onSpnSumFrame) self.spnSumDeg = wx.SpinCtrlDouble(panel1, size=(80, 25)) self.spnSumDeg.Bind(wx.EVT_SPINCTRLDOUBLE, self.onSpnSumDeg) self.spnSumDeg.SetDigits(4) hbox0122.Add(self.chkSum) hbox0122.Add(self.spnSumFrame) hbox0122.Add(wx.StaticText(panel1, wx.ID_ANY, " frames or "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) hbox0122.Add(self.spnSumDeg) hbox0122.Add(wx.StaticText(panel1, wx.ID_ANY, " degrees"), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.chkKeepFrame = wx.CheckBox( panel1, label="Keep frame number when trigger changed") vbox012.Add(self.chkKeepFrame, flag=wx.TOP, border=4) hbox0123 = wx.BoxSizer(wx.HORIZONTAL) vbox012.Add(hbox0123, flag=wx.TOP, border=4) self.llbtn = wx.Button(panel1, wx.ID_ANY, "<<") self.lbtn = wx.Button(panel1, wx.ID_ANY, "<") self.rbtn = wx.Button(panel1, wx.ID_ANY, ">") self.rrbtn = wx.Button(panel1, wx.ID_ANY, ">>") hbox0123.Add(self.llbtn, flag=wx.EXPAND | wx.RIGHT) hbox0123.Add(self.lbtn, flag=wx.EXPAND | wx.RIGHT) hbox0123.Add(self.rbtn, flag=wx.EXPAND | wx.RIGHT) hbox0123.Add(self.rrbtn, flag=wx.EXPAND | wx.RIGHT) self.lbtn.Bind(wx.EVT_BUTTON, lambda e: self.next_or_back(-1)) self.rbtn.Bind(wx.EVT_BUTTON, lambda e: self.next_or_back(+1)) self.llbtn.Bind(wx.EVT_BUTTON, lambda e: self.play(-1)) self.rrbtn.Bind(wx.EVT_BUTTON, lambda e: self.play(+1)) hbox0124 = wx.BoxSizer(wx.HORIZONTAL) vbox012.Add(hbox0124, flag=wx.TOP, border=4) hbox0124.Add(wx.StaticText(panel1, wx.ID_ANY, "Binning: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtBin = wx.TextCtrl(panel1, wx.ID_ANY, size=(100, 25), style=wx.TE_PROCESS_ENTER) self.txtBin.SetValue("1") self.txtBin.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) hbox0124.Add(self.txtBin, flag=wx.EXPAND | wx.RIGHT) panel1.SetSizer(vbox0) notebook.InsertPage(0, panel1, "File") # panel2 vbox1 = wx.BoxSizer(wx.VERTICAL) #hbox10 = wx.BoxSizer(wx.HORIZONTAL) #hbox10.Add(wx.StaticText(panel2, wx.ID_ANY, "Wavelength: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonWavelen = wx.TextCtrl(panel2, wx.ID_ANY, size=(100,25)) #self.txtMonWavelen.SetValue("1.0000") #hbox10.Add(self.txtMonWavelen, flag=wx.EXPAND|wx.RIGHT) #hbox10.Add(wx.StaticText(panel2, wx.ID_ANY, " Distance: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonDistance = wx.TextCtrl(panel2, wx.ID_ANY, size=(100,25)) #self.txtMonDistance.SetValue("300.0") #hbox10.Add(self.txtMonDistance, flag=wx.EXPAND|wx.RIGHT) #vbox1.Add(hbox10, flag=wx.EXPAND|wx.TOP, border=4) hbox11 = wx.BoxSizer(wx.HORIZONTAL) #hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, "Beam center: "), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) #self.txtMonBeamxy = wx.TextCtrl(panel2, wx.ID_ANY, size=(150,25)) #self.txtMonBeamxy.SetValue("1550, 1634.5") #hbox11.Add(self.txtMonBeamxy, flag=wx.EXPAND|wx.RIGHT) self.btnMonRefresh = wx.Button(panel2, wx.ID_ANY, "Start monitoring") self.btnMonRefresh.Bind(wx.EVT_BUTTON, self.on_btnMonRefresh) self.btnMonStop = wx.Button(panel2, wx.ID_ANY, "Stop") self.btnMonStop.Bind(wx.EVT_BUTTON, lambda e: self.monitor_timer.Stop()) self.txtMonInterval = wx.TextCtrl(panel2, wx.ID_ANY, "%.1f" % monitor_interval, size=(50, 25)) hbox11.Add(self.btnMonRefresh, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(self.btnMonStop, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, " interval: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) hbox11.Add(self.txtMonInterval, flag=wx.EXPAND | wx.RIGHT) hbox11.Add(wx.StaticText(panel2, wx.ID_ANY, " sec."), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) vbox1.Add(hbox11, flag=wx.EXPAND | wx.TOP, border=4) hbox12 = wx.BoxSizer(wx.HORIZONTAL) self.chkMonRaiseW = wx.CheckBox(panel2, wx.ID_ANY, "Raise adxv windows") self.chkMonRaiseW.SetValue(1) hbox12.Add(self.chkMonRaiseW, flag=wx.EXPAND | wx.RIGHT) vbox1.Add(hbox12, flag=wx.EXPAND | wx.TOP, border=4) hbox13 = wx.BoxSizer(wx.HORIZONTAL) hbox13.Add(wx.StaticText(panel2, wx.ID_ANY, "Eiger DCU host: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtEigerHost = wx.TextCtrl(panel2, wx.ID_ANY, eiger_host, size=(150, 25)) hbox13.Add(self.txtEigerHost) hbox13.Add(wx.StaticText(panel2, wx.ID_ANY, " API ver.: "), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) self.txtEigerAPIver = wx.TextCtrl(panel2, wx.ID_ANY, eiger_api_ver, size=(100, 25)) hbox13.Add(self.txtEigerAPIver) vbox1.Add(hbox13, flag=wx.EXPAND | wx.TOP, border=4) panel2.SetSizer(vbox1) notebook.InsertPage(1, panel2, "Monitor") notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_notebook_page_changed) vbox.Add(notebook, flag=wx.EXPAND) self.txtInfo = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_MULTILINE) self.txtInfo.SetFont(wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL)) self.txtInfo.SetEditable(False) vbox.Add(self.txtInfo, 1, flag=wx.EXPAND, border=4) self.SetSizer(vbox) self.play_timer = wx.Timer(self) self.play_relval = 0 self.Bind(wx.EVT_TIMER, self.on_play_timer, self.play_timer) self.monitor_timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_monitor_timer, self.monitor_timer) self.Show() if self.h5file is not None: self.read_h5file()