Python wx.EVT_SLIDER Examples

The following are 8 code examples of wx.EVT_SLIDER(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: fourier_demo_wx_sgskip.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, parent, label, param):
        self.sliderLabel = wx.StaticText(parent, label=label)
        self.sliderText = wx.TextCtrl(parent, -1, style=wx.TE_PROCESS_ENTER)
        self.slider = wx.Slider(parent, -1)
        # self.slider.SetMax(param.maximum*1000)
        self.slider.SetRange(0, param.maximum * 1000)
        self.setKnob(param.value)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.sliderLabel, 0,
                  wx.EXPAND | wx.ALIGN_CENTER | wx.ALL,
                  border=2)
        sizer.Add(self.sliderText, 0,
                  wx.EXPAND | wx.ALIGN_CENTER | wx.ALL,
                  border=2)
        sizer.Add(self.slider, 1, wx.EXPAND)
        self.sizer = sizer

        self.slider.Bind(wx.EVT_SLIDER, self.sliderHandler)
        self.sliderText.Bind(wx.EVT_TEXT_ENTER, self.sliderTextHandler)

        self.param = param
        self.param.attach(self) 
Example #2
Source File: spotfinder_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def OnChooseImage(self, event):
        # Whilst scrolling and choosing, show what we are looking at
        selected_image = self.images[self.image_chooser_panel.GetValue() - 1]
        # Always show the current 'loaded' image as such
        if selected_image == self.images.selected:
            self.image_chooser_panel.set_label(self.get_key(selected_image))
        else:
            self.image_chooser_panel.set_temporary_label(self.get_key(selected_image))

        # Don't update whilst dragging the slider
        if event.EventType == wx.EVT_SLIDER.typeId:
            if (
                wx.GetMouseState().LeftDown()
                if WX3
                else wx.GetMouseState().LeftIsDown()
            ):
                return

        # Once we've stopped scrolling, load the selected item
        self.load_image(selected_image) 
Example #3
Source File: spotfinder_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def OnUpdateBrightness(self, event):
        """Handle updates from the brightness-related controls"""

        # Don't update whilst dragging the slider
        if event.GetEventType() == wx.EVT_SLIDER.typeId:
            if wx.GetMouseState().LeftIsDown():
                return

        # For e.g. IntCtrl check the value is valid
        if hasattr(event.EventObject, "IsInBounds"):
            if not event.EventObject.IsInBounds():
                return

        # Read the new value then update everything if we need to
        if self.settings.brightness != event.EventObject.GetValue():
            self.settings.brightness = event.EventObject.GetValue()
            self.OnUpdate(event) 
Example #4
Source File: SettingsWindow.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, label, key, settings_window, speed_classes):
        self.key = key
        self.settings_window = settings_window
        wx.StaticBox.__init__(self, parent, label=label)
        self.sizer = wx.StaticBoxSizer(self, wx.VERTICAL)

        self.text = ElectroStaticText(parent, wx.ID_ANY, 'text')

        self.setfunc = lambda v : self.settings_window.setfunc(key, v)
        self.slider = RateSlider(parent, self.settings_window.config[key], speed_classes)
        self.slider.Bind(wx.EVT_SLIDER, self.OnSlider)
        self.LoadValue()

        self.sizer.Add(self.text, proportion=1, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT, border=SPACING)
        self.sizer.Add(self.slider, proportion=1, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=SPACING) 
Example #5
Source File: wx_viewer.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, parent):
        wx.MiniFrame.__init__(
            self,
            parent,
            -1,
            title="OpenGL settings",
            pos=(100, 100),
            style=wx.CAPTION | wx.CLOSE_BOX | wx.RAISED_BORDER,
        )
        self.parent = parent
        self.widgets = {}
        panel = wx.Panel(self, -1)
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        fog_box = wx.CheckBox(panel, -1, "Use fog")
        fog_box.SetValue(parent.flag_show_fog)
        main_sizer.Add(fog_box, 0, wx.ALL, 5)
        self.fog_box = fog_box
        szr = wx.FlexGridSizer(rows=0, cols=2, vgap=5, hgap=5)
        main_sizer.Add(szr, 0, 0, 0)
        slab_label = wx.StaticText(panel, -1, "Slab:")
        slab_slider = wx.Slider(
            panel, -1, int(parent.slab_scale * 100), minValue=1, maxValue=100
        )
        szr.Add(slab_label, 0, wx.ALL, 5)
        szr.Add(slab_slider, 0, wx.ALL, 5)
        fog_label = wx.StaticText(panel, -1, "Fog scale:")
        fog_slider = wx.Slider(
            panel, -1, int(parent.fog_scale_factor * 100), minValue=1, maxValue=100
        )
        szr.Add(fog_label, 0, wx.ALL, 5)
        szr.Add(fog_slider, 0, wx.ALL, 5)
        self.widgets["slab_scale"] = slab_slider
        self.widgets["fog_scale_factor"] = fog_slider
        self.SetSizer(main_sizer)
        main_sizer.Fit(panel)
        self.Fit()
        self.Bind(wx.EVT_SLIDER, self.OnUpdate)
        self.Bind(wx.EVT_CHECKBOX, self.OnUpdate)
        self.Bind(wx.EVT_CLOSE, self.OnClose) 
Example #6
Source File: panel_monitor.py    From RF-Monitor with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, parent, eventHandler):
        Monitor.__init__(self, None, False, False, None, None, False, [], [])

        self._eventHandler = eventHandler
        self._isRecording = False
        self._isRunning = False
        self._isLow = True
        self._colours = []

        pre = wx.PrePanel()
        self._ui = load_ui('PanelMonitor.xrc')

        handlerNumCtrl = XrcHandlerNumCtrl()
        handlerMeter = XrcHandlerMeter()
        self._ui.AddHandler(handlerNumCtrl)
        self._ui.AddHandler(handlerMeter)

        self._ui.LoadOnPanel(pre, parent, 'PanelMonitor')
        self.PostCreate(pre)

        self._panelColour = xrc.XRCCTRL(pre, 'panelColour')
        self._checkEnable = xrc.XRCCTRL(pre, 'checkEnable')
        self._checkAlert = xrc.XRCCTRL(pre, 'checkAlert')
        self._checkDynamic = xrc.XRCCTRL(pre, 'checkDynamic')
        self._choiceFreq = xrc.XRCCTRL(pre, 'choiceFreq')
        self._textSignals = xrc.XRCCTRL(pre, 'textSignals')
        # TODO: hackish
        for child in self.GetChildren():
            if isinstance(child, WidgetMeter):
                self._meterLevel = child
        self._sliderThreshold = xrc.XRCCTRL(pre, 'sliderThreshold')
        self._buttonDel = xrc.XRCCTRL(pre, 'buttonDel')

        self.__set_records()

        self._on_del = None

        self._panelColour.Bind(wx.EVT_LEFT_UP, self.__on_colour)
        self.Bind(wx.EVT_CHECKBOX, self.__on_enable, self._checkEnable)
        self.Bind(wx.EVT_CHECKBOX, self.__on_alert, self._checkAlert)
        self.Bind(wx.EVT_CHECKBOX, self.__on_dynamic, self._checkDynamic)
        self.Bind(wx.EVT_CHOICE, self.__on_freq, self._choiceFreq)
        self.Bind(wx.EVT_SLIDER, self.__on_threshold, self._sliderThreshold)
        self.Bind(wx.EVT_BUTTON, self.__on_del, self._buttonDel) 
Example #7
Source File: multiple_individuals_labeling_toolbox.py    From DeepLabCut with GNU Lesser General Public License v3.0 4 votes vote down vote up
def select_individual(self, event):
        individualName = self.individualrdb.GetStringSelection()
        self.change_marker_size.Hide()
        self.change_marker_size.Destroy()
        if individualName == "single":
            self.checkBox.Hide()
            self.individualrdb.Hide()
            self.rdb.Hide()
            (
                self.choiceBox,
                self.individualrdb,
                self.rdb,
                self.change_marker_size,
                self.checkBox,
            ) = self.choice_panel.addRadioButtons(
                self.uniquebodyparts, self.individual_names, self.file, self.markerSize
            )
            self.individualrdb.SetStringSelection(individualName)
            self.individualrdb.Bind(wx.EVT_RADIOBOX, self.select_individual)
            self.figure.delaxes(self.figure.axes[1])
            self.image_panel.addcolorbar(
                self.img,
                self.image_axis,
                self.iter,
                self.uniquebodyparts,
                self.colormap,
            )
            self.checkBox.Bind(wx.EVT_CHECKBOX, self.activateSlider)
            self.change_marker_size.Bind(wx.EVT_SLIDER, self.OnSliderScroll)
        else:
            self.checkBox.Hide()
            self.individualrdb.Hide()
            self.rdb.Hide()
            (
                self.choiceBox,
                self.individualrdb,
                self.rdb,
                self.change_marker_size,
                self.checkBox,
            ) = self.choice_panel.addRadioButtons(
                self.multibodyparts, self.individual_names, self.file, self.markerSize
            )
            self.individualrdb.SetStringSelection(individualName)
            self.change_marker_size.Show()
            self.checkBox.Show()
            self.individualrdb.Show()
            self.rdb.Show()
            self.individualrdb.Bind(wx.EVT_RADIOBOX, self.select_individual)
            self.figure.delaxes(self.figure.axes[1])
            self.image_panel.addcolorbar(
                self.img, self.image_axis, self.iter, self.multibodyparts, self.colormap
            )
            self.checkBox.Bind(wx.EVT_CHECKBOX, self.activateSlider)
            self.change_marker_size.Bind(wx.EVT_SLIDER, self.OnSliderScroll) 
Example #8
Source File: rstbx_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, *args, **kwds):
        wx.Panel.__init__(self, *args, **kwds)
        self.settings = self.GetParent().settings
        self._sizer = wx.BoxSizer(wx.VERTICAL)
        s = self._sizer
        self.SetSizer(self._sizer)
        grid = wx.FlexGridSizer(cols=2, rows=2)
        s.Add(grid)
        txt1 = wx.StaticText(self, -1, "Zoom level:")
        grid.Add(txt1, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.zoom_ctrl = wx.Choice(
            self, -1, choices=["Auto", "25%", "50%", "100%", "200%", "400%", "800%"]
        )
        self.zoom_ctrl.SetSelection(self.settings.zoom_level)
        grid.Add(self.zoom_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        txt11 = wx.StaticText(self, -1, "Color scheme:")
        grid.Add(txt11, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.color_ctrl = wx.Choice(
            self, -1, choices=["grayscale", "rainbow", "heatmap", "invert"]
        )
        self.color_ctrl.SetSelection(0)
        grid.Add(self.color_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self._sizer.Fit(self)
        box = wx.BoxSizer(wx.HORIZONTAL)
        s.Add(box)
        txt2 = wx.StaticText(self, -1, "Brightness")
        box.Add(txt2, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.brightness_ctrl = wx.Slider(
            self, -1, size=(200, -1), style=wx.SL_AUTOTICKS | wx.SL_LABELS
        )
        box.Add(self.brightness_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.brightness_ctrl.SetMin(1)
        self.brightness_ctrl.SetMax(500)
        self.brightness_ctrl.SetValue(self.settings.brightness)
        self.brightness_ctrl.SetTickFreq(25)
        self.center_ctrl = wx.CheckBox(self, -1, "Mark beam center")
        self.center_ctrl.SetValue(self.settings.show_beam_center)
        s.Add(self.center_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.spots_ctrl = wx.CheckBox(self, -1, "Show spotfinder results")
        self.spots_ctrl.SetValue(self.settings.show_spotfinder_spots)
        s.Add(self.spots_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.integ_ctrl = wx.CheckBox(self, -1, "Show integration results")
        self.integ_ctrl.SetValue(self.settings.show_integration)
        s.Add(self.integ_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        #    self.invert_ctrl = wx.CheckBox(self, -1, "Invert beam center axes")
        #    self.invert_ctrl.SetValue(self.settings.invert_beam_center_axes)
        #    s.Add(self.invert_ctrl, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
        self.Bind(wx.EVT_CHOICE, self.OnUpdate, self.zoom_ctrl)
        self.Bind(wx.EVT_CHOICE, self.OnUpdate, self.color_ctrl)
        self.Bind(wx.EVT_SLIDER, self.OnUpdateBrightness, self.brightness_ctrl)
        self.Bind(wx.EVT_CHECKBOX, self.OnUpdate2, self.center_ctrl)
        self.Bind(wx.EVT_CHECKBOX, self.OnUpdate2, self.spots_ctrl)
        txt3 = wx.StaticText(self, -1, "Thumbnail view:")
        s.Add(txt3, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.thumb_panel = rstbx.viewer.display.ThumbnailView(
            parent=self, size=(256, 256), style=wx.SUNKEN_BORDER
        )
        s.Add(self.thumb_panel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

    #    self.Bind(wx.EVT_CHECKBOX, self.OnUpdate2, self.invert_ctrl)