Beispiel #1
0
 def __init__(self,
              parent=None,
              sizer=None,
              label=None,
              value=None,
              converter=identity_converter(),
              callback=None,
              min=0,
              max=100,
              weight=1):
     new_id = wx.NewId()
     w = wx.Slider(parent,
                   new_id, (max + min) / 2,
                   min,
                   max,
                   size=wx.Size(250, -1),
                   style=wx.SL_HORIZONTAL | wx.SL_LABELS)
     self.f = self._pair_with_label(w,
                                    parent=parent,
                                    sizer=sizer,
                                    label=label,
                                    weight=weight)
     if callback:
         wx.EVT_COMMAND_SCROLL(w, new_id,
                               lambda evt: callback(evt.GetInt()))
     field.__init__(self, converter, value)
Beispiel #2
0
    def __init__(self,
                 parent=None,
                 sizer=None,
                 label=None,
                 value=None,
                 converter=identity_converter(),
                 callback=None,
                 range=None,
                 weight=1):
        if not isinstance(range, (tuple, list)) or len(range) != 3:
            raise ValueError, range

        self.min = range[0]
        self.max = range[1]
        self.step_size = float(range[2])
        nsteps = int((self.max - self.min) / self.step_size)

        new_id = wx.NewId()
        w = wx.Slider(parent,
                      new_id,
                      0,
                      0,
                      nsteps,
                      size=wx.Size(250, -1),
                      style=wx.SL_HORIZONTAL)
        self.f = self._pair_with_label(w,
                                       parent=parent,
                                       sizer=sizer,
                                       label=label,
                                       weight=weight)
        if callback:
            wx.EVT_COMMAND_SCROLL(
                w, new_id, lambda evt: callback(self._map_out(evt.GetInt())))
        field.__init__(self, converter, value)
Beispiel #3
0
 def setup(self, parent):
     """
     This is where all the controls get added to the control panel. You 
     *must* call the setup method of the parent class before doing any of
     your own setup.
     """
     
     #call parent class's setup method - do this before anything else
     super(SineWaveFreqCtrl, self).setup(parent)
     
     #create a label for the slider
     label = wx.StaticText(self, wx.ID_ANY, 'Frequency')
     self.Add(label, 0,
              wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_CENTER_HORIZONTAL,
              border=10)
     
     #create a frequency slider
     self.slider = wx.Slider(self, wx.ID_ANY, value=1, minValue=1,
                             maxValue=30, style=wx.SL_LABELS)
     
     #add the slider to the control panel's sizer
     self.Add(self.slider, 0, 
              wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL, border=10)
     
     #register an event handler for slider change events
     wx.EVT_COMMAND_SCROLL(self, self.slider.GetId(), self.on_slider_change)
Beispiel #4
0
    def _bindEvents(self):
        controlFrame = self.slice3dVWR.controlFrame

        wx.EVT_BUTTON(controlFrame, controlFrame.createSliceButtonId,
                      self._handlerCreateSlice)

        # for ortho view use sliceDirection.createOrthoView()

        wx.grid.EVT_GRID_CELL_RIGHT_CLICK(
            self._grid, self._handlerGridRightClick)
        wx.grid.EVT_GRID_LABEL_RIGHT_CLICK(
            self._grid, self._handlerGridRightClick)

        wx.grid.EVT_GRID_RANGE_SELECT(
            self._grid, self._handlerGridRangeSelect)

        # now do the fusion stuff
        wx.EVT_CHOICE(
            self.slice3dVWR.controlFrame,
            self.slice3dVWR.controlFrame.overlayModeChoice.GetId(),
            self._handlerOverlayModeChoice)

        wx.EVT_COMMAND_SCROLL(
            self.slice3dVWR.controlFrame,
            self.slice3dVWR.controlFrame.fusionAlphaSlider.GetId(),
            self._handlerFusionAlphaSlider)
Beispiel #5
0
def slider(parent, min, max, callback):
    """
    Return a wx.Slider object.

    Args:
        min: minimum slider value (float)
        max: maximum slider value (float)
        callback: function of one arg invoked when slider moves.
    @rtype: wx.Slider
    """
    new_id = wx.NewId()
    s = wx.Slider(parent, new_id,
                  (max + min) / 2, min, max, wx.DefaultPosition,
                  wx.Size(250, -1), wx.SL_HORIZONTAL | wx.SL_LABELS)
    wx.EVT_COMMAND_SCROLL(parent, new_id, lambda evt: callback(evt.GetInt()))
    return s
Beispiel #6
0
 def initFrame(self):
     self.gui_frame = self.res.LoadFrame(None, "mainframe")
     self.gui_statusbar = XRCCTRL(self.gui_frame, "statusbar")
     self.gui_console = XRCCTRL(self.gui_frame, "console")
     self.gui_simtime_text = XRCCTRL(self.gui_frame, "simtime_text")
     self.gui_simtime_slider = XRCCTRL(self.gui_frame, "simtime_slider")
     self.gui_delay_text = XRCCTRL(self.gui_frame, "delay_text")
     self.gui_delay_text.SetValue("0 ms")
     self.gui_delay_slider = XRCCTRL(self.gui_frame, "delay_slider")
     wx.EVT_COMMAND_SCROLL(self.gui_frame, XRCID("delay_slider"),
                                      self.onDelayScroll)
     wx.EVT_COMMAND_SCROLL_ENDSCROLL(self.gui_frame, XRCID("delay_slider"),
                                      self.newSimDelay)
     wx.EVT_COMMAND_SCROLL_THUMBRELEASE(self.gui_frame,
                                        XRCID("delay_slider"),
                                        self.newSimDelay)
Beispiel #7
0
    app=wx.PySimpleApp()

    f=wx.Frame(None, -1, "Print Test")
    butsetup=wx.Button(f, wx.NewId(), "Setup")
    butpreview=wx.Button(f, wx.NewId(), "Preview")
    butprint=wx.Button(f, wx.NewId(), "Print")

    slider=wx.Slider(f, wx.NewId(), 5, 0, 10, style=wx.SL_HORIZONTAL)

    szlist=[0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4]

    scale=1.0

    bs=wx.BoxSizer(wx.HORIZONTAL)
    bs.Add(slider, 1, wx.EXPAND|wx.ALL, 5)
    for i in (butsetup,butpreview, butprint):
        bs.Add(i, 0, wx.EXPAND|wx.ALL, 5)
    f.SetSizer(bs)
    bs.Fit(f)

    hep=HtmlEasyPrinting(f, None, None)

    wx.EVT_BUTTON(f, butsetup.GetId(), lambda _: hep.PrinterSetup())
    wx.EVT_BUTTON(f, butpreview.GetId(), lambda _: hep.PreviewText(html, scale=scale))
    wx.EVT_BUTTON(f, butprint.GetId(), lambda _: hep.PrintText(html, scale=scale))
    wx.EVT_COMMAND_SCROLL(f, slider.GetId(), OnSlider)

    f.Show(True)
    app.MainLoop()