コード例 #1
0
    def draw(self):

        self.sliders = []
        self.slidercaptions = []

        w = 500.0

        spacing_px = 40.0

        button_px = 100

        marginbottom_px = 20.0
        margintop_px = 20.0
        button_area_px = 100.0
        button_height_px = 80

        r = 100.0

        h = len(
            self.variables
        ) * spacing_px + marginbottom_px + margintop_px + button_area_px + button_height_px

        spacing = (spacing_px / h) * r
        posy = -r / 2 + marginbottom_px / h * r + len(self.variables) * spacing

        self.c = controls.controls(x=0, y=0, width=w, height=h, range=r)
        for v in self.variables:
            s = controls.slider(pos=(-15, posy),
                                width=7,
                                length=70,
                                axis=(1, 0, 0))

            s.value = v.default
            s.min, s.max = v.bounds

            sc = controls.label(text=v.name,
                                align='right',
                                pos=(r * (-0.5 + 0.1), posy),
                                display=self.c.display,
                                box=False)
            self.sliders.append(s)
            self.slidercaptions.append(sc)
            print posy
            posy -= spacing

        controls.button(pos=(0, r * (0.5 - button_area_px / h)),
                        height=button_height_px / h * r,
                        width=r / 2,
                        text='reset',
                        action=lambda: self.reset())
コード例 #2
0
ファイル: timemanager.py プロジェクト: jgillis/PyVis
 def draw(self):
   w = 200
   self.c = controls.controls(x=0, y=0, width=w, height=w, range=100)
   controls.button(pos=(-60,30), height=30, width=40, text='<<' , action=lambda: self.first())
   controls.toggle(pos=(0,30),height=30, width=40, text='Pause', action=lambda: self.pauseToggle())
   controls.button(pos=(60,30), height=30, width=40, text='>>',action= lambda: self.last())
   
   self.timelabel = controls.label(pos=(-15,-55),display=self.c.display)
   self.s1=controls.slider(pos=(-15,-30), width=7, length=70, axis=(1,0,0), action=lambda: self.slider1())
   self.s1.value = 0
   
   self.s2=controls.slider(pos=(-15,80),min=-1,max=3, width=7, length=70, axis=(1,0,0),action=lambda: self.slider2())
   self.s2.value = 0
   
   
   self.pause = False
   self.advancestep = 1
コード例 #3
0
ファイル: states.py プロジェクト: jgillis/PyVis
  def draw(self):
  
    
    self.sliders=[]
    self.slidercaptions = []
    
    
    
    w = 500.0
    
    spacing_px = 40.0
    
    button_px = 100
    
    marginbottom_px = 20.0
    margintop_px = 20.0
    button_area_px = 100.0
    button_height_px = 80
    
    
    
    r= 100.0
    
    h = len(self.variables)*spacing_px + marginbottom_px + margintop_px + button_area_px + button_height_px
    
    spacing = (spacing_px / h) * r
    posy = -r/2 + marginbottom_px/h*r + len(self.variables)*spacing

    

    self.c = controls.controls(x=0, y=0, width=w, height=h, range=r)
    for v in self.variables:
      s = controls.slider(pos=(-15,posy), width=7, length=70, axis=(1,0,0))
      
      s.value = v.default
      s.min,s.max = v.bounds
      
      sc = controls.label(text=v.name,align='right', pos=(r*(-0.5+0.1),posy),display=self.c.display,box = False )
      self.sliders.append(s)
      self.slidercaptions.append(sc)
      print posy
      posy-=spacing
    
    controls.button(pos=(0,r*(0.5-button_area_px/h)), height=button_height_px/h*r, width=r/2, text='reset' , action=lambda: self.reset())
コード例 #4
0
ファイル: timemanager.py プロジェクト: jgillis/PyVis
    def draw(self):
        w = 200
        self.c = controls.controls(x=0, y=0, width=w, height=w, range=100)
        controls.button(pos=(-60, 30),
                        height=30,
                        width=40,
                        text='<<',
                        action=lambda: self.first())
        controls.toggle(pos=(0, 30),
                        height=30,
                        width=40,
                        text='Pause',
                        action=lambda: self.pauseToggle())
        controls.button(pos=(60, 30),
                        height=30,
                        width=40,
                        text='>>',
                        action=lambda: self.last())

        self.timelabel = controls.label(pos=(-15, -55), display=self.c.display)
        self.s1 = controls.slider(pos=(-15, -30),
                                  width=7,
                                  length=70,
                                  axis=(1, 0, 0),
                                  action=lambda: self.slider1())
        self.s1.value = 0

        self.s2 = controls.slider(pos=(-15, 80),
                                  min=-1,
                                  max=3,
                                  width=7,
                                  length=70,
                                  axis=(1, 0, 0),
                                  action=lambda: self.slider2())
        self.s2.value = 0

        self.pause = False
        self.advancestep = 1
コード例 #5
0
# Toggles have "text0" and "text1" attributes which can be read and set.
# Toggles and sliders have a "value" attribute (0/1, or location of indicator)
# which can be read and set.

# The pos attribute for buttons, toggles, and menus is the center of the control (like "box").
# The pos attribute for sliders is at one end, and axis points to the other end (like "cylinder").

# By default a control is created in the most recently created "controls" window, but you
# can change this by specifying "controls=..." when creating a button, toggle, slider, or menu.

# The Python construct "lambda: setdir(-1)" below passes the location of the setdir function
# to the interact machinery, which uses "apply" to call the function when an action
# is to be taken. This scheme ensures that the execution of the function takes place
# in the appropriate namespace context in the case of importing the controls module.

BL = ctrls.button(pos=(-30, 30), height=30, width=40, text='Left', action=lambda: setdir(-1))
BR = ctrls.button(pos=(30, 30), height=30, width=40, text='Right', action=lambda: setdir(1))
S1 = ctrls.slider(pos=(-15, -40), width=7, length=70, axis=(1, 0.7, 0), action=lambda: setrate(S1))
S2 = ctrls.slider(pos=(-30, -50), width=7, length=50, axis=(0, 1, 0), action=lambda: setrate(S2))
T1 = ctrls.toggle(pos=(40, -30), width=10, height=10, text0='Red', text1='Cyan',
                  action=lambda: togglecubecolor())
M1 = ctrls.menu(pos=(0, 0, 0), height=7, width=25, text='Options')

# After creating the menu heading, add menu items:
M1.items.append(('Left', lambda: setdir(-1))) # specify menu item title and action to perform
M1.items.append(('Right', lambda: setdir(1)))
M1.items.append(('---------', None)) # a dummy separator
M1.items.append(('Red', lambda: cubecolor(vp.color.red)))
M1.items.append(('Cyan', lambda: cubecolor(vp.color.cyan)))

S1.value = 70 # update the slider