def __init__(self, parent): Box.__init__(self, parent) # init size self.position.w = 300 self.position.h = 40 # Slider specific stuff self._fullRange = Range(0,1) self._range = Range(0,1) self._refRange = Range(0,1) # For sliding self._showTicks = False # Set bgcolor and edge self.bgcolor = (0.6, 0.8, 0.6) self._frontColor = 0.5, 0.7, 0.9 self.edgeWidth = 1 # A slider should respond to mouse self.hitTest = True # Create label centered at the box self._label = Label(self) self._label.position = 0,0,1,1 self._label.halign = 0 self._label.bgcolor = None # State variables self._isOver = False self._sliderDown = False self._sliderRefx = 0.0 # Pool of labels for tickmarks, to reuse them self._wobjects = [] # So we can have Text objects self._labelPool = {} # Calculate dots now self._SliderCalcDots() # Create new events self._eventSliding = BaseEvent(self) self._eventSliderChanged = BaseEvent(self) # To changes appearance on mouse over self.eventEnter.Bind(self._SliderOnEnter) self.eventLeave.Bind(self._SliderOnLeave) # Bind to events self.eventMouseDown.Bind(self._SliderOnDown) self.eventMouseUp.Bind(self._SliderOnUp) self.eventMotion.Bind(self._SliderOnMotion) self.eventPosition.Bind(self._SliderCalcDots)
def __init__(self, parent): Box.__init__(self, parent) # Set color self.bgcolor = 'w' # How soon the mouse snaps to a node self._snapWidth = 5 # The currently selected node (or None if nothing is selected) self._selectedNode = None # The nodes and lines of R,G,B and A self._allNodes = [Pointset(2) for i in range(4)] self._allLines = [Pointset(2) for i in range(4)] # Init nodes for nodes in self._allNodes: nodes.append(0,1) nodes.append(1,0) self._allNodes[3][0,1] = 0 # alpha is completele ones by default # Init lines for line in self._allLines: for i in np.linspace(0,1,256): line.append(i,1) # the actual map will be 1-line # Make lines correct now for nodes, line in zip(self._allNodes, self._allLines): self._NodesToLine(nodes, line) # The node and line currently in control self._nodes = self._allNodes[3] self._line = self._allLines[3] # Bind events self.eventMotion.Bind(self._OnMotion) self.eventMouseUp.Bind(self._OnUp) self.eventMouseDown.Bind(self._OnDown) self.eventDoubleClick.Bind(self._OnDoubleClick) self.hitTest = True # enable firing events
def __init__(self, parent): Box.__init__(self, parent) # Set color self.bgcolor = 'w' # How soon the mouse snaps to a node self._snapWidth = 5 # The currently selected node (or None if nothing is selected) self._selectedNode = None # The nodes and lines of R,G,B and A self._allNodes = [Pointset(2) for i in range(4)] self._allLines = [Pointset(2) for i in range(4)] # Init nodes for nodes in self._allNodes: nodes.append(0,1) nodes.append(1,0) self._allNodes[3][0,1] = 0 # alpha is completele ones by default # Init lines for line in self._allLines: for i in np.linspace(0,1,256): line.append(i,1) # the actual map will be 1-line # Make lines correct now for nodes, line in zip(self._allNodes, self._allLines): self._NodesToLine(nodes, line) # The node and line currently in control self._nodes = self._allNodes[3] self._line = self._allLines[3] # Bind events self.eventMotion.Bind(self._OnMotion) self.eventMouseUp.Bind(self._OnUp) self.eventMouseDown.Bind(self._OnDown) self.eventDoubleClick.Bind(self._OnDoubleClick)
def __init__(self, parent): Box.__init__(self, parent) self._label = Label(self, '') self._label.bgcolor = '' self.eventPosition.Bind(self._OnPositionChange) # Pool of labels for tickmarks, to reuse them self._wobjects = [] # So we can have Text objects self._labelPool = {} # If attached to axes, correct that axes' size if isinstance(parent, Axes): # Init position x = parent.position.width + 5 self.position = x, 0.0, 30, 1.0 # Keep informed of axes movment self.parent.eventPosition.Bind(self._OnAxesPositionChange) # Correct axes' position self.parent.position.Correct(dw=-100) # 30 + 70