def __init__(self, *args, **kwds): # begin wxGlade: EngraveProperty.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP wx.Frame.__init__(self, *args, **kwds) self.SetSize((305, 216)) self.spin_speed_set = wx.SpinCtrlDouble(self, wx.ID_ANY, "20.0", min=0.0, max=240.0) self.spin_power_set = wx.SpinCtrlDouble(self, wx.ID_ANY, "1000.0", min=0.0, max=1000.0) self.checkbox_custom_d_ratio = wx.CheckBox(self, wx.ID_ANY, _("Custom D-Ratio")) self.spin_speed_dratio = wx.SpinCtrlDouble(self, wx.ID_ANY, "0.261", min=0.0, max=1.0) self.checkbox_custom_accel = wx.CheckBox(self, wx.ID_ANY, _("Acceleration Override")) self.slider_accel = wx.Slider(self, wx.ID_ANY, 1, 1, 4, style=wx.SL_AUTOTICKS | wx.SL_LABELS) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_speed, self.spin_speed_set) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_speed, self.spin_speed_set) self.Bind(wx.EVT_TEXT, self.on_spin_speed, self.spin_speed_set) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_power, self.spin_power_set) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_power, self.spin_power_set) self.Bind(wx.EVT_TEXT, self.on_spin_power, self.spin_power_set) self.Bind(wx.EVT_CHECKBOX, lambda e: self.spin_speed_dratio.Enable(self.checkbox_custom_d_ratio.GetValue()), self.checkbox_custom_d_ratio) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_speed_dratio, self.spin_speed_dratio) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_speed_dratio, self.spin_speed_dratio) self.Bind(wx.EVT_TEXT, self.on_spin_speed_dratio, self.spin_speed_dratio) self.Bind(wx.EVT_CHECKBOX, lambda e: self.slider_accel.Enable(self.checkbox_custom_accel.GetValue()), self.checkbox_custom_accel) self.Bind(wx.EVT_COMMAND_SCROLL, self.on_slider_accel, self.slider_accel) self.kernel = None self.operation = None self.Bind(wx.EVT_CLOSE, self.on_close, self)
def _create_float(self, option_name: str, options: Sequence): if len(options) in {0, 1, 3} and all( isinstance(o, (int, float)) for o in options): sizer = self._create_horizontal_options_sizer(option_name) if len(options) == 0: option = wx.SpinCtrlDouble( self, min=-30_000_000, max=30_000_000, initial=0, ) elif len(options) == 1: option = wx.SpinCtrlDouble( self, min=-30_000_000, max=30_000_000, initial=options[0], ) elif len(options) == 3: option = wx.SpinCtrlDouble( self, min=min(options[1:3]), max=max(options[1:3]), initial=options[0], ) else: return # should not get here sizer.Add(option) self._options[option_name] = option
def __init__(self, *args, **kwds): # begin wxGlade: RotarySettings.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW wx.Frame.__init__(self, *args, **kwds) self.SetSize((222, 347)) self.checkbox_rotary = wx.CheckBox(self, wx.ID_ANY, "Rotary") self.spin_rotary_scaley = wx.SpinCtrlDouble(self, wx.ID_ANY, "1.0", min=0.0, max=5.0) self.spin_rotary_scalex = wx.SpinCtrlDouble(self, wx.ID_ANY, "1.0", min=0.0, max=5.0) self.checkbox_rotary_loop = wx.CheckBox(self, wx.ID_ANY, "Field Loop") self.spin_rotary_rotation = wx.SpinCtrlDouble(self, wx.ID_ANY, "360.0", min=0.0, max=20000.0) self.checkbox_rotary_roller = wx.CheckBox(self, wx.ID_ANY, "Uses Roller") self.spin_rotary_roller_circumference = wx.SpinCtrlDouble(self, wx.ID_ANY, "50.0", min=0.0, max=800.0) self.spin_rotary_object_circumference = wx.SpinCtrlDouble(self, wx.ID_ANY, "50.0", min=0.0, max=800.0) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_CHECKBOX, self.on_check_rotary, self.checkbox_rotary) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_rotary_scale_y, self.spin_rotary_scaley) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_rotary_scale_y, self.spin_rotary_scaley) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_rotary_scale_x, self.spin_rotary_scalex) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_rotary_scale_x, self.spin_rotary_scalex) self.Bind(wx.EVT_CHECKBOX, self.on_check_rotary_loop, self.checkbox_rotary_loop) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_rotation, self.spin_rotary_rotation) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_rotation, self.spin_rotary_rotation) self.Bind(wx.EVT_CHECKBOX, self.on_check_rotary_roller, self.checkbox_rotary_roller) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_rotary_roller_circumference, self.spin_rotary_roller_circumference) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_rotary_roller_circumference, self.spin_rotary_roller_circumference) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_rotary_object_circumference, self.spin_rotary_object_circumference) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_rotary_object_circumference, self.spin_rotary_object_circumference) # end wxGlade self.project = None self.Bind(wx.EVT_CLOSE, self.on_close, self)
def __init__(self, parent, chromatogram_figure, *args, **kwds): self.chromatogram_figure = chromatogram_figure args = (parent, ) + args # begin wxGlade: border_config.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE wx.Dialog.__init__(self, *args, **kwds) self.main_panel = wx.Panel(self, wx.ID_ANY) self.top_border_value = wx.SpinCtrlDouble(self.main_panel, wx.ID_ANY, "0.9", min=0.0, max=2.0) self.top_border_value.SetDigits(3) self.bottom_border_value = wx.SpinCtrlDouble(self.main_panel, wx.ID_ANY, "0.125", min=0.0, max=2.0) self.bottom_border_value.SetDigits(3) self.left_border_value = wx.SpinCtrlDouble(self.main_panel, wx.ID_ANY, "0.1", min=0.0, max=2.0) self.left_border_value.SetDigits(3) self.right_border_value = wx.SpinCtrlDouble(self.main_panel, wx.ID_ANY, "0.97", min=0.0, max=2.0) self.right_border_value.SetDigits(3) self.tight_layout_button = wx.Button(self.main_panel, wx.ID_ANY, "Tight Layout") self.close_btn = wx.Button(self.main_panel, wx.ID_ANY, "Close") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_SPINCTRLDOUBLE, self.update_borders, self.top_border_value) self.Bind(wx.EVT_TEXT, self.update_borders, self.top_border_value) self.Bind(wx.EVT_TEXT_ENTER, self.update_borders, self.top_border_value) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.update_borders, self.bottom_border_value) self.Bind(wx.EVT_TEXT, self.update_borders, self.bottom_border_value) self.Bind(wx.EVT_TEXT_ENTER, self.update_borders, self.bottom_border_value) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.update_borders, self.left_border_value) self.Bind(wx.EVT_TEXT, self.update_borders, self.left_border_value) self.Bind(wx.EVT_TEXT_ENTER, self.update_borders, self.left_border_value) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.update_borders, self.right_border_value) self.Bind(wx.EVT_TEXT, self.update_borders, self.right_border_value) self.Bind(wx.EVT_TEXT_ENTER, self.update_borders, self.right_border_value) self.Bind(wx.EVT_BUTTON, self.apply_tight_layout, self.tight_layout_button) self.Bind(wx.EVT_BUTTON, self.close_dialog, self.close_btn)
def BuildUi(self): main_sizer = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, "Broadening [eV]:") label.Wrap(-1) self.width_ctrl = wx.SpinCtrlDouble(self, id=-1, value=str(self.DEFAULT_WIDTH), min=self.DEFAULT_WIDTH / 1000, inc=0.1) main_sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5) main_sizer.Add(self.width_ctrl, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) label = wx.StaticText(self, -1, "Mesh step [eV]:") label.Wrap(-1) self.step_ctrl = wx.SpinCtrlDouble(self, id=-1, value=str(self.DEFAULT_STEP), min=self.DEFAULT_STEP / 1000, inc=0.1) main_sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5) main_sizer.Add(self.step_ctrl, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetSizerAndFit(main_sizer)
def __init__(self, *args, **kwds): # begin wxGlade: MyDialogRunningMeancentered.__init__ kwds["style"] = kwds.get("style", 0) | wx.RESIZE_BORDER wx.Dialog.__init__(self, *args, **kwds) self.panel_5 = wx.Panel(self, wx.ID_ANY, style=wx.BORDER_SIMPLE) self.spin_ctrl_current_samplerate = wx.SpinCtrlDouble(self, wx.ID_ANY, "10.0", min=0.0, max=10000.0) self.spin_ctrl_windowsize = wx.SpinCtrlDouble(self, wx.ID_ANY, "10.0", min=0.0, max=10000.0) self.Cancel = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_AUTODRAW) self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_AUTODRAW) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_value_change, self.spin_ctrl_current_samplerate) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_value_change, self.spin_ctrl_windowsize) self.Bind(wx.EVT_BUTTON, self.on_cancel, self.Cancel) self.Bind(wx.EVT_BUTTON, self.on_add, self.button_1)
def drawZdivision(self): sizer = wx.BoxSizer() inputlabel = wx.StaticText(self, wx.ID_ANY, "Przedział z funkcji:", size=(SETTINGS_LABEL_MIN_WIDTH, SETTINGS_LABEL_HEIGHT), style=wx.ST_NO_AUTORESIZE) self.input_z_division_start = wx.SpinCtrlDouble(self, wx.ID_ANY, min=-100000000, max=100000000) self.input_z_division_end = wx.SpinCtrlDouble(self, wx.ID_ANY, min=-100000000, max=100000000) if 'z_division_start' in self.values: self.input_z_division_start.SetValue( self.values['z_division_start']) if 'z_division_end' in self.values: self.input_z_division_end.SetValue(self.values['z_division_end']) sizer.Add(inputlabel, 0, wx.ALL, 5) sizer.Add(self.input_z_division_start, 1, wx.ALL | wx.EXPAND, 5) sizer.Add(self.input_z_division_end, 1, wx.ALL | wx.EXPAND, 5) return sizer
def __init__(self, parent, start=None, stop=None, step=None, **kwargs): """ """ super(ArangeControl, self).__init__(parent, id=-1, **kwargs) text_opts = dict(flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5) ctrl_opts = text_opts main_sizer = wx.BoxSizer(wx.HORIZONTAL) # start text = wx.StaticText(self, -1, "Start:") text.Wrap(-1) text.SetToolTipString( "Start of interval. The interval includes this value.") p = self.SPIN_DOUBLE_DEFAULTS.copy() if start is not None: p["value"] = str(start) self.start_ctrl = wx.SpinCtrlDouble(self, -1, **p) main_sizer.Add(text, **text_opts) main_sizer.Add(self.start_ctrl, **ctrl_opts) # stop text = wx.StaticText(self, -1, "Stop:") text.Wrap(-1) text.SetToolTipString("""\ End of interval. The interval does not include this value, except in some cases where `step` is not an integer and floating point round-off affects the length of `out`.""" ) p = self.SPIN_DOUBLE_DEFAULTS.copy() if stop is not None: p["value"] = str(stop) self.stop_ctrl = wx.SpinCtrlDouble(self, -1, **p) main_sizer.Add(text, **text_opts) main_sizer.Add(self.stop_ctrl, **ctrl_opts) # step text = wx.StaticText(self, -1, "Step:") text.Wrap(-1) text.SetToolTipString("""\ Spacing between values. For any output `out`, this is the distance between two adjacent values, out[i+1] - out[i].""" ) p = self.SPIN_DOUBLE_DEFAULTS.copy() if step is not None: p["value"] = str(step) self.step_ctrl = wx.SpinCtrlDouble(self, -1, **p) main_sizer.Add(text, **text_opts) main_sizer.Add(self.step_ctrl, **ctrl_opts) self.SetSizerAndFit(main_sizer)
def __init__(self, *args, **kwds): # begin wxGlade: Navigate.__init__ kwds["style"] = kwds.get( "style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP wx.Frame.__init__(self, *args, **kwds) self.SetSize((237, 401)) self.button_top = wx.BitmapButton(self, wx.ID_ANY, icons8up.GetBitmap()) self.button_left = wx.BitmapButton(self, wx.ID_ANY, icons8_left.GetBitmap()) self.button_home = wx.BitmapButton(self, wx.ID_ANY, icons8_home_filled_50.GetBitmap()) self.button_right = wx.BitmapButton(self, wx.ID_ANY, icons8_right.GetBitmap()) self.button_bottom = wx.BitmapButton(self, wx.ID_ANY, icons8_down.GetBitmap()) self.button_unlock = wx.BitmapButton(self, wx.ID_ANY, icons8_padlock_50.GetBitmap()) self.button_lock = wx.BitmapButton(self, wx.ID_ANY, icons8_lock_50.GetBitmap()) self.button_pulse = wx.BitmapButton(self, wx.ID_ANY, icons8_gas_industry_50.GetBitmap()) self.spin_step_size = wx.SpinCtrlDouble(self, wx.ID_ANY, "10.0", min=0.0, max=1000.0) self.spin_pulse_time = wx.SpinCtrlDouble(self, wx.ID_ANY, "50.0", min=0.0, max=1000.0) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.move_top, self.button_top) self.Bind(wx.EVT_BUTTON, self.move_left, self.button_left) self.Bind(wx.EVT_BUTTON, self.home, self.button_home) self.Bind(wx.EVT_BUTTON, self.move_right, self.button_right) self.Bind(wx.EVT_BUTTON, self.move_bottom, self.button_bottom) self.Bind(wx.EVT_BUTTON, self.unlock_rail, self.button_unlock) self.Bind(wx.EVT_BUTTON, self.lock_rail, self.button_lock) self.Bind(wx.EVT_BUTTON, self.fire_time, self.button_pulse) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_step_size, self.spin_step_size) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_step_size, self.spin_step_size) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_pulse_time, self.spin_pulse_time) self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_pulse_time, self.spin_pulse_time) # end wxGlade self.project = None self.Bind(wx.EVT_CLOSE, self.on_close, self)
def __init__(self, parent): super().__init__(parent=parent) sizer = wx.BoxSizer(wx.VERTICAL) cl_sizer = wx.BoxSizer(wx.HORIZONTAL) obj_ids = [ '22880', '50606', '61928', '95631', '87390', '21645', '53373', '53759', '95646', '33894', '20238', '61577', '54207', '44227', '89943', '54284', '25092', '55637', '35872', '40927', '54699', '45827', '18512', '56392', '19829', '43017', '88297', '59875', '11360', '49076', '97406', '99086', '48883', '29217', '66345', '90422', '96220', '88648', '61518', '97908', '10769', '93422', '68359', '90497' ] self.obj_choice = wx.Choice(self, choices=obj_ids) self.obj_choice.SetSelection(0) self.date_ctrl = wx.adv.DatePickerCtrl(self) self.time_ctrl = wx.adv.TimePickerCtrl(self) self.cl_low = wx.SpinCtrlDouble(self, min=0, max=100, style=wx.SP_ARROW_KEYS) self.cl_mid = wx.SpinCtrlDouble(self, min=0, max=100, style=wx.SP_ARROW_KEYS) self.cl_high = wx.SpinCtrlDouble(self, min=0, max=100, style=wx.SP_ARROW_KEYS) self.trm = wx.SpinCtrlDouble(self, style=wx.SP_ARROW_KEYS, min=0, max=1, inc=0.1) self.btn = wx.Button(self, label="Get Power") cl_sizer.Add(self.cl_low, 0, wx.ALL | wx.EXPAND, 5) cl_sizer.Add(self.cl_mid, 0, wx.ALL | wx.EXPAND, 5) cl_sizer.Add(self.cl_high, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.obj_choice, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.date_ctrl, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.time_ctrl, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(cl_sizer, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.trm, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.btn, 0, wx.ALL | wx.CENTER, 5) self.SetSizer(sizer)
def get_grid(self, conf): self.sbox_grid = wx.StaticBox(self, -1, L('GRID')) sboxs_grid = wx.StaticBoxSizer(self.sbox_grid, wx.VERTICAL) _label = L('SHOW_GRID') self.ch = wx.CheckBox(self, -1, _label, style=wx.ALIGN_RIGHT) self.ch.SetValue(conf.grid_lines) self.ch.Bind(wx.EVT_CHECKBOX, self.on_checked_grid) self.cho_label = wx.StaticText(self, -1, L('TYPE')) self.cho = wx.Choice(self, -1, choices=TYPES_GRID) self.cho.SetSelection(TYPES_GRID.index(conf.grid_lines_style)) self.cho.SetToolTipString(L('SELECT_TYPE_OF_GRID')) self.g_linewidth_label = wx.StaticText(self, -1, L('WIDTH')) self.g_linewidth = wx.SpinCtrlDouble(self, -1, "") self.g_linewidth.SetDigits(1) self.g_linewidth.SetRange(0.1, 1.0) self.g_linewidth.SetValue(conf.grid_linewidth) self.g_color_label = wx.StaticText(self, -1, L('COLOR')) _c = wx.NamedColour(conf.grid_color) self.g_color = csel.ColourSelect(self, colour=_c) self.g_color_alpha_label = wx.StaticText(self, -1, L('COLOR_ALPHA')) self.g_color_alpha = wx.SpinCtrlDouble(self, -1, "") self.g_color_alpha.SetDigits(1) self.g_color_alpha.SetRange(0.1, 1.0) self.g_color_alpha.SetValue(conf.grid_color_alpha) grid = wx.FlexGridSizer(cols=4) _style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL grid.Add(self.cho_label, 0, _style, 5) grid.Add(self.cho, 0, wx.ALIGN_LEFT | wx.ALL, 5) grid.Add(self.g_linewidth_label, 0, _style, 5) grid.Add(self.g_linewidth, 0, wx.ALIGN_LEFT | wx.ALL, 5) grid.Add(self.g_color_label, 0, _style, 5) grid.Add(self.g_color, 0, wx.ALIGN_LEFT | wx.ALL, 5) grid.Add(self.g_color_alpha_label, 0, _style, 5) grid.Add(self.g_color_alpha, 0, wx.ALIGN_LEFT | wx.ALL, 5) sboxs_grid.Add(self.ch, 0, wx.ALIGN_LEFT | wx.ALL, 5) sboxs_grid.Add(grid, 1, wx.EXPAND | wx.ALL, 10) self.checked_grid(conf.grid_lines) return sboxs_grid
def create_widget(self): mi, ma = self.properties["range"].get_tuple() if self.properties["value"].is_active(): self.widget = wx.SpinCtrlDouble(self.parent.widget, self.id, min=mi, max=ma, initial=self.value) else: self.widget = wx.SpinCtrlDouble(self.parent.widget, self.id, min=mi, max=ma)
def test_spinctrlDoubleProperties(self): sp = wx.SpinCtrlDouble(self.frame) sp.Max sp.Min sp.Value sp.Digits sp.Increment
def __set_input_widgets(self): self.input = {key: [] for key in self.options.save_fig_param.keys()} self.label = {key: [] for key in self.options.save_fig_param.keys()} self.text_ctrl = {} self.combo_box = {} for obj_type, attr_dict in self.options.save_fig_param.items(): for attr, value in attr_dict.items(): self.label[obj_type].append(wx.StaticText(self, wx.ID_ANY, attr.replace('_', ' ').title() + ':')) if type(value) is str: color_options = ['none'] + list(plot_colors.cnames) self.input[obj_type].append(wx.ComboBox(self, wx.ID_ANY, choices=color_options, style=wx.CB_DROPDOWN | wx.TE_READONLY)) self.input[obj_type][-1].SetValue(value) self.combo_box[obj_type + '_' + attr] = self.input[obj_type][-1] else: if 'alpha' in attr: self.input[obj_type].append(wx.SpinCtrlDouble(self, wx.ID_ANY, "0", min=0, max=1, style=wx.SP_ARROW_KEYS)) self.input[obj_type][-1].SetIncrement(0.1) self.input[obj_type][-1].SetValue(str(value)) elif 'width' in attr and obj_type == 'legend': self.input[obj_type].append(wx.SpinCtrl(self, wx.ID_ANY, "0", min=0, max=20, style=wx.SP_ARROW_KEYS)) self.input[obj_type][-1].SetValue(str(value)) else: self.input[obj_type].append(wx.TextCtrl(self, wx.ID_ANY, str(value))) self.text_ctrl[obj_type + '_' + attr] = self.input[obj_type][-1] self.label_plot = wx.StaticText(self, wx.ID_ANY, 'Plot:') self.combo_plot = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_DROPDOWN | wx.TE_READONLY) self.include_range = wx.CheckBox(self, wx.ID_ANY, 'Apply Range Edits')
def __init__(self, parent, posVal, colour=wx.BLACK, alpha=wx.ALPHA_OPAQUE): wx.Panel.__init__(self, parent) # make some widgets self.pos = wx.SpinCtrlDouble(self, value='%2f' % posVal, size=(65, -1), min=0.0, max=1.0, initial=posVal, inc=0.01) self.pos.SetToolTipString( "A value between 0 and 1 representing the distance between (x1,y1) " "and (x2,y2) for this gradient stop.") self.colour = wx.ColourPickerCtrl(self, col=colour) self.colour.SetToolTipString("The colour for this gradient stop") self.minusBtn = wx.Button(self, -1, " - ", style=wx.BU_EXACTFIT) self.minusBtn.SetToolTipString("Remove this gradient stop") # put them in a sizer sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.pos, 0, wx.ALIGN_CENTER_VERTICAL) sizer.Add(self.colour, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) sizer.Add(self.minusBtn, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 25) border = wx.BoxSizer() border.Add(sizer, 1, wx.EXPAND | wx.ALL, 4) self.SetSizer(border) self.Bind(wx.EVT_BUTTON, self.OnMinusButton, self.minusBtn)
def add_float_entry(self, panel, _, *args, **kwargs): if 'min' not in kwargs: kwargs['min'] = -3.402823466e38 if 'max' not in kwargs: kwargs['max'] = 3.402823466e38 return wx.SpinCtrlDouble(panel, *args, **kwargs)
def __init__(self, *args, **kwds): # begin wxGlade: Ventana.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((815, 494)) self.panel_1 = wx.Panel(self, wx.ID_ANY) self.spinWidth = wx.SpinCtrl(self.panel_1, wx.ID_ANY, "128", min=1, max=65535) self.spinHeight = wx.SpinCtrl(self.panel_1, wx.ID_ANY, "128", min=1, max=65535) self.buttonLockSize = wx.ToggleButton(self.panel_1, wx.ID_ANY, "", style=wx.BU_EXACTFIT) self.gradientWidget = GradientWidget(self.panel_1, wx.ID_ANY) self.radioTypeA = wx.RadioButton(self.panel_1, wx.ID_ANY, _("Type A"), style=wx.RB_GROUP) self.radioTypeB = wx.RadioButton(self.panel_1, wx.ID_ANY, _("Type B")) self.radioTypeC = wx.RadioButton(self.panel_1, wx.ID_ANY, _("Type C")) self.spinNumFrames = wx.SpinCtrl(self.panel_1, wx.ID_ANY, "6", min=1, max=65535) self.spinGranularity = wx.SpinCtrl(self.panel_1, wx.ID_ANY, "0", min=0, max=100) self.buttonGenerate = wx.Button(self.panel_1, wx.ID_ANY, _("Generate!")) self.panel_2 = wx.Panel(self, wx.ID_ANY) self.imageDisplay = ImageDisplay(self.panel_2, wx.ID_ANY) self.buttonPlayPause = wx.ToggleButton(self.panel_2, wx.ID_ANY, "", style=wx.BU_EXACTFIT) self.sliderPreview = wx.Slider(self.panel_2, wx.ID_ANY, 0, 0, 10) self.labelVelocidad = wx.StaticText(self.panel_2, wx.ID_ANY, _("Speed")) self.spinFps = wx.SpinCtrlDouble(self.panel_2, wx.ID_ANY, "24.0", min=0.1, max=100.0) self.labelFPS = wx.StaticText(self.panel_2, wx.ID_ANY, _("FPS")) self.buttonSave = wx.Button(self.panel_2, wx.ID_ANY, _("Save")) self.__set_properties() self.__do_layout()
def __init__(self, parent: wx.Window) -> None: super().__init__(parent, title="Move Stage") self._spins = [] position = cockpit.interfaces.stageMover.getPosition() limits = cockpit.interfaces.stageMover.getSoftLimits() for i in range(3): self._spins.append( wx.SpinCtrlDouble(self, min=limits[i][0], max=limits[i][1], initial=position[i])) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(wx.StaticText(self, label="Select stage position"), wx.SizerFlags().Border().Centre()) spins_sizer = wx.FlexGridSizer(cols=2, gap=(0, 0)) for spin, name in zip(self._spins, ['X', 'Y', 'Z']): spins_sizer.Add(wx.StaticText(self, label=name), wx.SizerFlags().Border().Centre()) spins_sizer.Add(spin, wx.SizerFlags().Border().Expand()) sizer.Add(spins_sizer, wx.SizerFlags().Border().Centre()) buttons_sizer = self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL) sizer.Add(buttons_sizer, wx.SizerFlags().Border().Centre()) self.SetSizerAndFit(sizer)
def DoCreateResource(self): assert self.GetInstance() is None parent_window = self.GetParentAsWindow() # Now create the object spinctrl = wx.SpinCtrlDouble( parent_window, self.GetID(), self.GetText("value"), self.GetPosition(), self.GetSize(), self.GetStyle( "style", wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT | wx.TE_PROCESS_ENTER), self.GetFloat("min", DEFAULT_MIN), self.GetFloat("max", DEFAULT_MAX), self.GetFloat( "initial", DEFAULT_INITIAL), # Ignored if value contains a number self.GetFloat("inc", DEFAULT_STEP), self.GetName(), ) if self.GetParamNode("digits"): spinctrl.SetDigits(self.GetLong("digits")) # Set standard window attributes self.SetupWindow(spinctrl) return spinctrl
def __init__(self, parent, baseValue, minValue, maxValue, inverse=False, id=-1): wx.Panel.__init__(self, parent, id=id) self.parent = parent self.base_value = baseValue self.UserMinValue = minValue self.UserMaxValue = maxValue print(self.UserMinValue, self.UserMaxValue) self.inverse = inverse def getStep(valRange): """ Find step for the passed range, which is based on 1, 2 or 5. Step returned will make sure that range fits 10..50 of them, as close to 10 as possible. """ steps = {1: None, 2: None, 5: None} for baseInc in steps: baseIncAmount = valRange / baseInc incScale = math.floor(math.log10(baseIncAmount) - 1) steps[baseInc] = baseInc * 10 ** incScale chosenBase = min(steps, key=lambda base: valRange / steps[base]) chosenStep = steps[chosenBase] if inverse: chosenStep *= -1 return chosenStep def getDigitPlaces(minValue, maxValue): minDigits = 3 maxDigits = 5 currentDecision = minDigits for value in (floatUnerr(minValue), floatUnerr(maxValue)): for currentDigit in range(minDigits, maxDigits + 1): if round(value, currentDigit) == value: if currentDigit > currentDecision: currentDecision = currentDigit break # Max decimal places we can afford to show was not enough else: return maxDigits return currentDecision self.ctrl = wx.SpinCtrlDouble(self, min=minValue, max=maxValue, inc=getStep(maxValue - minValue)) self.ctrl.SetDigits(getDigitPlaces(minValue, maxValue)) self.ctrl.Bind(wx.EVT_SPINCTRLDOUBLE, self.UpdateValue) self.slider = AttributeGauge(self, size=(-1, 8)) b = 4 vsizer1 = wx.BoxSizer(wx.VERTICAL) vsizer1.Add(self.ctrl, 0, wx.LEFT | wx.RIGHT | wx.CENTER, b) vsizer1.Add(self.slider, 0, wx.EXPAND | wx.ALL , b) self.SetSizerAndFit(vsizer1) self.parent.SetClientSize((500, vsizer1.GetSize()[1]))
def proc(): r = value_list[name]['min'], value_list[name]['max'] if useSlider: s = wx.Slider(self.scrolledWindow) s.SetRange(0, 1000) else: s = wx.SpinCtrlDouble(self.scrolledWindow) s.SetRange(r[0], r[1]) s.SetIncrement(min(1, (r[1] - r[0]) / 100.0)) s.SetDigits(-math.log(s.GetIncrement()) / math.log(10) + 1) sizer.Add(s, 0, wx.EXPAND) self.controls[name] = s sname = name def onspin(event): if useSlider: v = s.GetValue() / 1000.0 * (r[1] - r[0]) + r[0] self.client.set(sname, v) else: self.client.set(sname, s.GetValue()) if useSlider: s.Bind(wx.EVT_SLIDER, onspin) self.sliderrange[name] = r else: s.Bind(wx.EVT_SPINCTRLDOUBLE, onspin)
def addLabelledCtrl(self, panel, boxSizer, label): """ Add a StaticText and SpinControl pair Args: boxSizer (wx.BoxSizer): BoxSizer that will hold everything created in this function pnl (wx.Panel): Panel to be parent of the elements created, since BoxSizers cannot be used as parent label (str): Label of the format DGLX or DL1 to help identify which setting is modified by each control Besides creating the mentioned controls, the function adds them to the attribute setting_to_control for later use. This dictionary allows to remember which setting is modified by each control. Each control is stacked on top of each other with StaticText in between to identify them """ st = wx.StaticText(panel, label=label) boxSizer.Add(st, proportion=0, flag=wx.CENTER | wx.TOP, border=10) if label[0] == "D": spinCtrl = wx.SpinCtrlDouble( panel, min=-3000, max=3000, initial=self.settings.ReadFloat(label) ) spinCtrl.SetDigits(2) else: if label[0] == "I": spinCtrl = wx.SpinCtrl( panel, min=1, max=self.settings.ReadInt("numSensors", 1), initial=self.settings.ReadInt(label), ) boxSizer.Add(spinCtrl, proportion=0, flag=wx.ALL | wx.CENTER) self.setting_to_control[st.GetLabelText()] = spinCtrl
def __init__(self, parent, label_, value_=1, style_=wx.SL_HORIZONTAL, min_=1, max_=30): """Initialise and lay out the panel.""" # Initialise the panel super().__init__(parent) self.value = value_ # Initialise the slider control, the spin box, and the label self.slider = wx.Slider(self, value=value_, style=style_, minValue=min_ * 10, maxValue=max_ * 10) self.spinCtrl = wx.SpinCtrlDouble(self, initial=value_, min=min_, max=max_, inc=0.1) self.label = wx.StaticText(self, label=label_) # Lay out the slider and spin box vertically # i.e. slider on top of spin box self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.slider, 1, wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL) self.vbox.AddSpacer(10) self.spinCtrl.SetSize(self.slider.GetSize()) self.vbox.Add(self.spinCtrl, 1, wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL) # Lay out the slider and spin box next to the label self.hbox = wx.BoxSizer(wx.HORIZONTAL) self.hbox.AddSpacer(5) self.hbox.Add(self.label, 1, wx.ALIGN_CENTRE_VERTICAL) self.hbox.AddSpacer(20) self.hbox.Add(self.vbox) self.SetSizer(self.hbox) # When the slider or spin box is used, react accordingly self.slider.Bind(wx.EVT_SLIDER, self.onSlider) self.spinCtrl.Bind(wx.EVT_SPINCTRLDOUBLE, self.onSpin)
def createControls(self): '''create controls''' self.logger = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY) self.lineDivider = wx.StaticLine(self, -1, size=(10, 2), style=wx.LI_HORIZONTAL) self.inputPathLabel = wx.StaticText(self, label="Input Path:") self.inputPathFilePickerCtrl = wx.FilePickerCtrl( self, message="Select Input Video", wildcard='*.mp4', path=cfgParams['inputpath'], style=wx.FLP_OPEN | wx.FLP_FILE_MUST_EXIST | wx.FLP_USE_TEXTCTRL) self.outputPathLabel = wx.StaticText(self, label="Output Path:") self.outputPathFilePickerCtrl = wx.FilePickerCtrl( self, message="Select Output Video", path=cfgParams['outputpath'], style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL) self.magnitudeThresholdRatioLabel = wx.StaticText( self, label="magnitude-threshold-ratio:") self.magnitudeThresholdRatioSpinCtrl = wx.SpinCtrlDouble( self, value=cfgParams['magnitude-threshold-ratio'], inc=0.01) self.processButton = wx.Button(self, label="Jump Cut!")
def MySpin(parent, digits, *args, **kw): # in GTK 3.[01], spinner is not large enough to fit text # Could be a class, but use function to avoid load errors if wx # not installed # If native wx.SpinCtrlDouble has problems in different platforms # try agw # from wx.lib.agw.floatspin import FloatSpin import wx sp = wx.SpinCtrlDouble(parent, *args, **kw) # sp = FloatSpin(parent) sp.SetDigits(digits) # sp.SetValue(kw['initial']) def fitValue(ev): text = '%%.%df' % digits % sp.Max # native wx.SpinCtrlDouble does not return good size # in GTK 3.0 tex = sp.GetTextExtent(text) tsz = sp.GetSizeFromTextSize(tex.x) if sp.MinSize.x < tsz.x: # print('fitValue', getattr(sp, 'setting', None), sp.Value, sp.Digits, tsz.x) sp.MinSize = tsz # sp.Size = tsz # sp.Bind(wx.EVT_TEXT, fitValue) fitValue(None) return sp
def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) wx.StaticText(self, -1, "wx.SpinCtrlDouble:", pos=(25,25)) spin = wx.SpinCtrlDouble(self, value='0.00', pos=(75,50), min=-5.0, max=25.25, inc=0.25) spin.SetDigits(2)
def __init__(self, *args, **kw): HistogramInfoGUI.HistogramInfoGUI.__init__(self, *args, **kw) old_sizer = self.GetSizer() new_sizer = wx.WrapSizer() for si in old_sizer.GetChildren(): sizer = si.GetSizer() old_sizer.Detach(sizer) new_sizer.Add(sizer, 0, 0, 0) self.SetSizer(new_sizer) bSizerLower = wx.BoxSizer(wx.HORIZONTAL) bSizerUpper = wx.BoxSizer(wx.HORIZONTAL) m_staticTextLower = wx.StaticText( self, wx.ID_ANY, u"Lower:", wx.DefaultPosition, wx.DefaultSize, 0) m_staticTextLower.Wrap(-1) bSizerLower.Add( m_staticTextLower, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.m_spinCtrlLower = wx.SpinCtrlDouble( self, -1, inc=0.01, name='lower') self.m_spinCtrlLower.SetDigits(2) bSizerLower.Add( self.m_spinCtrlLower, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) new_sizer.Add(bSizerLower, 0, 0, 5) m_staticTextUpper = wx.StaticText( self, wx.ID_ANY, u"Upper:", wx.DefaultPosition, wx.DefaultSize, 0) m_staticTextUpper.Wrap(-1) bSizerUpper.Add( m_staticTextUpper, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.m_spinCtrlUpper = wx.SpinCtrlDouble( self, -1, inc=0.01, name='upper') self.m_spinCtrlUpper.SetDigits(2) bSizerUpper.Add( self.m_spinCtrlUpper, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) new_sizer.Add(bSizerUpper, 0, 0, 5) self.Layout()
def get_specific_widget(self, parent): import wx self.widget = wx.SpinCtrlDouble(parent, -1, min=self.min, max=self.max) self.widget.SetDigits(0) self.widget.SetValue(self.value) orig = self.widget.GetValue self.widget.GetValue = lambda: int(orig()) return self.widget
def InsertSpinControlDouble(self, dv="0"): return wx.SpinCtrlDouble(self, -1, value=dv, style=wx.SP_ARROW_KEYS, min=0, max=1000, inc=1)
def Pf_range_check(self): if self.Inc_Label is None or self.Upper_Label is None: wx.StaticText(self.pnl, label="Min", pos=(135, 10)) wx.StaticText(self.pnl, label="Max", pos=(285, 10)) wx.StaticText(self.pnl, label='Step', pos=(360, 10)) if self.Pf_range_box.GetValue(): self.Pf_Upper = wx.SpinCtrlDouble(self.pnl, value=str(self.Pf.GetValue()+0.01), pos=(275, 150), size=(60, -1), min=0.0, max=1.0, initial=self.Pf.GetValue()+0.01, inc=0.01) self.Pf_Step = wx.SpinCtrlDouble(self.pnl, value=str(0.01), pos=(350, 150), size=(60, -1), min=0.0, max=1.0, initial=0.01, inc=0.01) else: self.Pf_Upper.Hide() self.Pf_Step.Hide() self.Pf_Step = None self.Pf_Upper = None return True