~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to enthought/enable/slider.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-05 21:54:28 UTC
  • mfrom: (1.1.5 upstream)
  • mto: (8.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110405215428-1x2wtubz3ok2kxaq
Tags: upstream-3.4.1
ImportĀ upstreamĀ versionĀ 3.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
from numpy import linspace, zeros
3
3
 
4
4
# Enthought library imports
5
 
from enthought.kiva import STROKE
 
5
from enthought.kiva.constants import STROKE
6
6
from enthought.traits.api import (Any, Bool, Enum, Float, Int, Property,
7
7
                                  on_trait_change, Trait)
8
8
from enthought.traits.ui.api import EnumEditor
13
13
from markers import MarkerNameDict, marker_names, CustomMarker
14
14
 
15
15
slider_marker_names = list(marker_names) + ["rect"]
16
 
SliderMarkerTrait = Trait("rect", "rect", MarkerNameDict, 
 
16
SliderMarkerTrait = Trait("rect", "rect", MarkerNameDict,
17
17
                    editor=EnumEditor(values=slider_marker_names))
18
18
 
19
19
 
23
23
    #------------------------------------------------------------------------
24
24
    # Model traits
25
25
    #------------------------------------------------------------------------
26
 
    
 
26
 
27
27
    min = Float()
28
28
 
29
29
    max = Float()
98
98
    #------------------------------------------------------------------------
99
99
    # Interaction traits
100
100
    #------------------------------------------------------------------------
101
 
    
 
101
 
102
102
    # Can this slider be interacted with, or is it just a display
103
103
    interactive = Bool(True)
104
104
 
159
159
        elif self.min == self.max:
160
160
            coord[axis_ndx] = (screen_low + screen_high) / 2
161
161
            return coord
162
 
        
 
162
 
163
163
        # Handle normal cases
164
164
        coord[axis_ndx] = (val - self.min) / (self.max - self.min) * self.bounds[axis_ndx] + screen_low
165
165
        return coord
204
204
 
205
205
    def set_slider_pixels(self, pixels):
206
206
        """ Sets the width of the slider to be a fixed number of pixels
207
 
        
 
207
 
208
208
        Parameters
209
209
        ==========
210
210
        pixels : int
228
228
 
229
229
    def set_endcap_pixels(self, pixels):
230
230
        """ Sets the width of the endcap to be a fixed number of pixels
231
 
        
 
231
 
232
232
        Parameters
233
233
        ==========
234
234
        pixels : int
252
252
 
253
253
    def set_tick_pixels(self, pixels):
254
254
        """ Sets the width of the tick marks to be a fixed number of pixels
255
 
        
 
255
 
256
256
        Parameters
257
257
        ==========
258
258
        pixels : int
300
300
                end_y = bar_y + self._cached_endcap_size / 2
301
301
                gc.move_to(self.x, start_y)
302
302
                gc.line_to(self.x, end_y)
303
 
                gc.move_to(self.x2, start_y) 
 
303
                gc.move_to(self.x2, start_y)
304
304
                gc.line_to(self.x2, end_y)
305
305
            if self.num_ticks > 0:
306
306
                x_pts = linspace(self.x, self.x2, self.num_ticks+2).astype(int)
506
506
                self._cached_endcap_size = int(self.width * self._endcap_percent)
507
507
 
508
508
        return
509
 
 
 
509