def handleKeyStroke(self, event): # handle key strokes for numbers only in widget keyboard entry label key = event.keysym if key.isdigit() or key=='period' or key=='minus' or key=='plus': if key == 'period': key = '.' elif key == 'minus': key = '-' elif key == 'plus': key = '+' self.typedValue += key self.typedValueTK.configure(text=self.typedValue) else: KeyboardEntry.handleKeyStroke(self, event)
def handleKeyStroke(self, event): # handle key strokes for numbers only in widget keyboard entry label key = event.keysym if key.isdigit() or key == 'period' or key == 'minus' or key == 'plus': if key == 'period': key = '.' elif key == 'minus': key = '-' elif key == 'plus': key = '+' self.typedValue += key self.typedValueTK.configure(text=self.typedValue) else: KeyboardEntry.handleKeyStroke(self, event)
def __init__(self, master=None, type='float', labCfg={'fg':'black','side':'left', 'text':None}, min=None, max=None, increment=.0, precision=2, showLabel=1, value=0.0, continuous=1, oneTurn=360., size=50, callback=None, lockMin=0, lockBMin=0, lockMax=0, lockBMax=0, lockIncrement=0, lockBIncrement=0, lockPrecision=0, lockShowLabel=0, lockValue=0, lockType=0, lockContinuous=0, lockOneTurn=0, **kw): Tkinter.Frame.__init__(self, master) Tkinter.Pack.config(self) self.callbacks = CallbackManager() # object to manage callback # functions. They get called with the # current value as an argument # initialize various attributes with default values self.precision = 2 # decimal places self.min = None # minimum value self.max = None # maximum value self.increment = increment # value increment self.minOld = 0. # used to store old values self.maxOld = 0. self.incrementOld = increment self.size = 50 # defines widget size self.offsetValue = 0. # used to set increment correctly self.lab = None # label self.callback = None # user specified callback self.opPanel = None # option panel widget self.oneTurn = 360. # value increment for 1 full turn self.value = 0.0 # current value of widget self.oldValue = 0.0 # old value of widget self.showLabel = 1 # turn on to display label on self.continuous = 1 # set to 1 to call callbacks at # each value change, else gets called # on button release event self.angle = 0. # angle corresponding to value self.labCfg = labCfg # Tkinter Label options self.labelFont = ( ensureFontCase('helvetica'), 14, 'bold') # label font self.labelColor = 'yellow' # label color self.canvas = None # the canvas to create the widget in self.usedArcColor = '#aaaaaa' # filled arc color of used portion self.unusedArcColor = '#cccccc' # filled arc color of unused portion self.pyOver180 = math.pi/180.0 # constants used in various places self.threeSixtyOver1turn = 1 self.piOver1turn = math.pi/360. self.lockMin = lockMin # lock<X> vars are used in self.lock() self.lockMax = lockMax # to lock/unlock entries in optionpanel self.lockIncrement = lockIncrement self.lockBMin = lockBMin self.lockBMax = lockBMax self.lockBIncrement = lockBIncrement self.lockPrecision = lockPrecision self.lockShowLabel = lockShowLabel self.lockValue = lockValue self.lockType = lockType self.lockContinuous = lockContinuous self.lockOneTurn = lockOneTurn self.setArrow() # configure with user-defined values self.setSize(size) self.setCallback(callback) self.setContinuous(continuous) self.setType(type) self.setPrecision(precision) self.setOneTurn(oneTurn) self.setMin(min) self.setMax(max) self.setIncrement(increment) self.setShowLabel(showLabel) self.setValue(value) self.setLabel(self.labCfg) self.createCanvas(master) canvas = self.canvas canvas.bind("<ButtonPress-1>", self.mouseDown) canvas.bind("<ButtonRelease-1>", self.mouseUp) canvas.bind("<B1-Motion>", self.mouseMove) canvas.bind("<Button-3>", self.toggleOptPanel) if os.name == 'nt': #sys.platform == 'win32': canvas.bind("<MouseWheel>", self.mouseWheel) else: canvas.bind("<Button-4>", self.mouseWheel) canvas.bind("<Button-5>", self.mouseWheel) KeyboardEntry.__init__(self, (canvas,), self.setFromEntry) self.opPanel = OptionsPanel(master = self, title="Dial Options")
def __init__(self, master=None, type='float', labCfg={ 'fg': 'black', 'side': 'left', 'text': None }, min=None, max=None, increment=.0, precision=2, showLabel=1, value=0.0, continuous=1, oneTurn=360., size=50, callback=None, lockMin=0, lockBMin=0, lockMax=0, lockBMax=0, lockIncrement=0, lockBIncrement=0, lockPrecision=0, lockShowLabel=0, lockValue=0, lockType=0, lockContinuous=0, lockOneTurn=0, **kw): Tkinter.Frame.__init__(self, master) Tkinter.Pack.config(self) self.callbacks = CallbackManager() # object to manage callback # functions. They get called with the # current value as an argument # initialize various attributes with default values self.precision = 2 # decimal places self.min = None # minimum value self.max = None # maximum value self.increment = increment # value increment self.minOld = 0. # used to store old values self.maxOld = 0. self.incrementOld = increment self.size = 50 # defines widget size self.offsetValue = 0. # used to set increment correctly self.lab = None # label self.callback = None # user specified callback self.opPanel = None # option panel widget self.oneTurn = 360. # value increment for 1 full turn self.value = 0.0 # current value of widget self.oldValue = 0.0 # old value of widget self.showLabel = 1 # turn on to display label on self.continuous = 1 # set to 1 to call callbacks at # each value change, else gets called # on button release event self.angle = 0. # angle corresponding to value self.labCfg = labCfg # Tkinter Label options self.labelFont = (ensureFontCase('helvetica'), 14, 'bold' ) # label font self.labelColor = 'yellow' # label color self.canvas = None # the canvas to create the widget in self.usedArcColor = '#aaaaaa' # filled arc color of used portion self.unusedArcColor = '#cccccc' # filled arc color of unused portion self.pyOver180 = math.pi / 180.0 # constants used in various places self.threeSixtyOver1turn = 1 self.piOver1turn = math.pi / 360. self.lockMin = lockMin # lock<X> vars are used in self.lock() self.lockMax = lockMax # to lock/unlock entries in optionpanel self.lockIncrement = lockIncrement self.lockBMin = lockBMin self.lockBMax = lockBMax self.lockBIncrement = lockBIncrement self.lockPrecision = lockPrecision self.lockShowLabel = lockShowLabel self.lockValue = lockValue self.lockType = lockType self.lockContinuous = lockContinuous self.lockOneTurn = lockOneTurn self.setArrow() # configure with user-defined values self.setSize(size) self.setCallback(callback) self.setContinuous(continuous) self.setType(type) self.setPrecision(precision) self.setOneTurn(oneTurn) self.setMin(min) self.setMax(max) self.setIncrement(increment) self.setShowLabel(showLabel) self.setValue(value) self.setLabel(self.labCfg) self.createCanvas(master) canvas = self.canvas canvas.bind("<ButtonPress-1>", self.mouseDown) canvas.bind("<ButtonRelease-1>", self.mouseUp) canvas.bind("<B1-Motion>", self.mouseMove) canvas.bind("<Button-3>", self.toggleOptPanel) if os.name == 'nt': #sys.platform == 'win32': canvas.bind("<MouseWheel>", self.mouseWheel) else: canvas.bind("<Button-4>", self.mouseWheel) canvas.bind("<Button-5>", self.mouseWheel) KeyboardEntry.__init__(self, (canvas, ), self.setFromEntry) self.opPanel = OptionsPanel(master=self, title="Dial Options")
def __init__(self, master=None, labCfg={ 'fg': 'black', 'side': 'left', 'text': None }, wheelLabCfg={}, canvasCfg={}, callback=None, type='float', min=None, max=None, increment=0.0, precision=2, showLabel=1, value=0.0, continuous=True, width=200, height=40, oneTurn=10., wheelPad=6, lockMin=0, lockBMin=0, lockMax=0, lockBMax=0, lockIncrement=0, lockBIncrement=0, lockPrecision=0, lockShowLabel=0, lockValue=0, lockType=0, lockContinuous=0, lockOneTurn=0, orient=None, reportDelta=0, **kw): # See FIXME init # if __debug__: # checkkeywords(kw) Tkinter.Frame.__init__(self, master) Tkinter.Pack.config(self, side='left', anchor='w') #FIXME: nblines are not dynamically computed self.nblines = 30 self.callback = None self.callbacks = CallbackManager() # object to manage callback # functions. They get called with the # current value as an argument self.width = 200 self.height = 40 self.setWidth(width) self.setHeight(height) # set widget orientation: either horizontal or vertical self.setOrient(orient) # initialize various attributes with default values self.precision = 2 # decimal places self.min = None # minimum value self.max = None # maximum value self.increment = increment # value increment self.minOld = 0. # used to store old values self.maxOld = 0. self.incrementOld = increment self.size = 50 # defines widget size self.offsetValue = 0. # used to set increment correctly self.lab = None # label self.opPanel = None # option panel widget self.oneTurn = 360. # value increment for 1 full turn self.value = 0.0 # current value of widget self.oldValue = 0.0 # old value of widget self.showLabel = 1 # turn on to display label on self.continuous = True # set to 1 to call callbacks at # each value change, else gets called # on button release event self.angle = 0. # angle corresponding to value self.labCfg = labCfg # Tkinter Label options self.labelFont = (ensureFontCase('helvetica'), 14, 'bold' ) # label font self.labelColor = 'yellow' # label color self.canvas = None # the canvas to create the widget in self.usedArcColor = '#aaaaaa' # filled arc color of used portion self.unusedArcColor = '#cccccc' # filled arc color of unused portion self.pyOver180 = math.pi / 180.0 # constants used in various places self.threeSixtyOver1turn = 1 self.piOver1turn = math.pi / 360. self.wheelLabCfg = wheelLabCfg # Tkinter wheel label options self.canvasCfg = canvasCfg # Tkinter Canvas options self.wheelPad = wheelPad # pad between wheel and widget borders self.deltaVal = 0. # delta with value at last callback self.valueLabel = None # Tkinter Label self.setType(type) # can be float or int self.discreteValue = 0. # value in discrete space self.lockMin = lockMin # lock<X> variables in configure() self.lockMax = lockMax # to lock/unlock entries in options # panel self.lockMin = lockMin # lock<X> vars are used in self.lock() self.lockMax = lockMax # to lock/unlock entries in optionpanel self.lockIncrement = lockIncrement self.lockBMin = lockBMin self.lockBMax = lockBMax self.lockBIncrement = lockBIncrement self.lockPrecision = lockPrecision self.lockShowLabel = lockShowLabel self.lockValue = lockValue self.lockType = lockType self.lockContinuous = lockContinuous self.lockOneTurn = lockOneTurn self.reportDelta = reportDelta self.setLabel(self.labCfg) self.createCanvas(master, wheelPad=wheelPad) self.canvas.bind("<ButtonPress-1>", self.mouseDown) self.canvas.bind("<ButtonRelease-1>", self.mouseUp) self.canvas.bind("<B1-Motion>", self.mouseMove) self.canvas.bind("<Button-3>", self.toggleOptPanel) self.valueLabel.bind("<ButtonPress-1>", self.mouseDown) self.valueLabel.bind("<ButtonRelease-1>", self.mouseUp) self.valueLabel.bind("<B1-Motion>", self.mouseMove) self.valueLabel.bind("<Button-3>", self.toggleOptPanel) if os.name == 'nt': #sys.platform == 'win32': self.canvas.bind("<MouseWheel>", self.mouseWheel) self.valueLabel.bind("<MouseWheel>", self.mouseWheel) else: self.canvas.bind("<Button-4>", self.mouseWheel) self.valueLabel.bind("<Button-4>", self.mouseWheel) self.canvas.bind("<Button-5>", self.mouseWheel) self.valueLabel.bind("<Button-5>", self.mouseWheel) self.bind("<Button-3>", self.toggleOptPanel) KeyboardEntry.__init__(self, (self, self.canvas, self.valueLabel), self.setFromEntry) self.opPanel = OptionsPanel(master=self, title="Thumbwheel Options") # now set the constructor options correctly using the configure method self.setValue(value) apply( self.configure, (), { 'type': type, 'min': min, 'max': max, 'increment': increment, 'precision': precision, 'showLabel': showLabel, 'continuous': continuous, 'oneTurn': oneTurn, 'lockType': lockType, 'lockMin': lockMin, 'lockBMin': lockBMin, 'lockMax': lockMax, 'lockBMax': lockBMax, 'lockIncrement': lockIncrement, 'lockBIncrement': lockBIncrement, 'lockPrecision': lockPrecision, 'lockShowLabel': lockShowLabel, 'lockValue': lockValue, 'lockContinuous': lockContinuous, 'lockOneTurn': lockOneTurn, 'orient': orient, 'reportDelta': reportDelta, 'callback': callback })
def __init__(self, master=None, labCfg={'fg':'black','side':'left', 'text':None}, wheelLabCfg={}, canvasCfg={}, callback=None, type='float', min=None, max=None, increment=0.0, precision=2, showLabel=1, value=0.0, continuous=True, width=200, height=40, oneTurn=10., wheelPad=6, lockMin=0, lockBMin=0, lockMax=0,lockBMax=0, lockIncrement=0, lockBIncrement=0, lockPrecision=0, lockShowLabel=0, lockValue=0, lockType=0, lockContinuous=0, lockOneTurn=0, orient=None, reportDelta=0, **kw): # See FIXME init # if __debug__: # checkkeywords(kw) Tkinter.Frame.__init__(self, master) Tkinter.Pack.config(self, side='left', anchor='w') #FIXME: nblines are not dynamically computed self.nblines = 30 self.callback = None self.callbacks = CallbackManager() # object to manage callback # functions. They get called with the # current value as an argument self.width = 200 self.height = 40 self.setWidth(width) self.setHeight(height) # set widget orientation: either horizontal or vertical self.setOrient(orient) # initialize various attributes with default values self.precision = 2 # decimal places self.min = None # minimum value self.max = None # maximum value self.increment = increment # value increment self.minOld = 0. # used to store old values self.maxOld = 0. self.incrementOld = increment self.size = 50 # defines widget size self.offsetValue = 0. # used to set increment correctly self.lab = None # label self.opPanel = None # option panel widget self.oneTurn = 360. # value increment for 1 full turn self.value = 0.0 # current value of widget self.oldValue = 0.0 # old value of widget self.showLabel = 1 # turn on to display label on self.continuous = True # set to 1 to call callbacks at # each value change, else gets called # on button release event self.angle = 0. # angle corresponding to value self.labCfg = labCfg # Tkinter Label options self.labelFont = ( ensureFontCase('helvetica'), 14, 'bold') # label font self.labelColor = 'yellow' # label color self.canvas = None # the canvas to create the widget in self.usedArcColor = '#aaaaaa' # filled arc color of used portion self.unusedArcColor = '#cccccc' # filled arc color of unused portion self.pyOver180 = math.pi/180.0 # constants used in various places self.threeSixtyOver1turn = 1 self.piOver1turn = math.pi/360. self.wheelLabCfg = wheelLabCfg # Tkinter wheel label options self.canvasCfg = canvasCfg # Tkinter Canvas options self.wheelPad = wheelPad # pad between wheel and widget borders self.deltaVal = 0. # delta with value at last callback self.valueLabel = None # Tkinter Label self.setType(type) # can be float or int self.discreteValue = 0. # value in discrete space self.lockMin = lockMin # lock<X> variables in configure() self.lockMax = lockMax # to lock/unlock entries in options # panel self.lockMin = lockMin # lock<X> vars are used in self.lock() self.lockMax = lockMax # to lock/unlock entries in optionpanel self.lockIncrement = lockIncrement self.lockBMin = lockBMin self.lockBMax = lockBMax self.lockBIncrement = lockBIncrement self.lockPrecision = lockPrecision self.lockShowLabel = lockShowLabel self.lockValue = lockValue self.lockType = lockType self.lockContinuous = lockContinuous self.lockOneTurn = lockOneTurn self.reportDelta = reportDelta self.setLabel(self.labCfg) self.createCanvas(master, wheelPad=wheelPad) self.canvas.bind("<ButtonPress-1>", self.mouseDown) self.canvas.bind("<ButtonRelease-1>", self.mouseUp) self.canvas.bind("<B1-Motion>", self.mouseMove) self.canvas.bind("<Button-3>", self.toggleOptPanel) self.valueLabel.bind("<ButtonPress-1>", self.mouseDown) self.valueLabel.bind("<ButtonRelease-1>", self.mouseUp) self.valueLabel.bind("<B1-Motion>", self.mouseMove) self.valueLabel.bind("<Button-3>", self.toggleOptPanel) if os.name == 'nt': #sys.platform == 'win32': self.canvas.bind("<MouseWheel>", self.mouseWheel) self.valueLabel.bind("<MouseWheel>", self.mouseWheel) else: self.canvas.bind("<Button-4>", self.mouseWheel) self.valueLabel.bind("<Button-4>", self.mouseWheel) self.canvas.bind("<Button-5>", self.mouseWheel) self.valueLabel.bind("<Button-5>", self.mouseWheel) self.bind("<Button-3>", self.toggleOptPanel) KeyboardEntry.__init__(self, (self, self.canvas, self.valueLabel), self.setFromEntry) self.opPanel = OptionsPanel(master = self, title="Thumbwheel Options") # now set the constructor options correctly using the configure method self.setValue(value) apply( self.configure, (), {'type':type, 'min':min, 'max':max, 'increment':increment, 'precision':precision, 'showLabel':showLabel, 'continuous':continuous, 'oneTurn':oneTurn, 'lockType':lockType, 'lockMin':lockMin, 'lockBMin':lockBMin, 'lockMax':lockMax, 'lockBMax':lockBMax, 'lockIncrement':lockIncrement, 'lockBIncrement':lockBIncrement, 'lockPrecision':lockPrecision, 'lockShowLabel':lockShowLabel, 'lockValue':lockValue, 'lockContinuous':lockContinuous, 'lockOneTurn':lockOneTurn, 'orient':orient, 'reportDelta':reportDelta, 'callback':callback })