Example #1
0
 def __init__(self,
              master=None,
              title='Chooser',
              commands=None,
              immediate=0,
              exitFunction=None):
     if master is None:
         self.master = tkinter.Toplevel()
         self.ownmaster = 1
         self.master.title(title)
         #self.master.protocol('WM_DELETE_WINDOW', self.dismiss)
     else:
         self.ownmaster = 0
         self.master = master
     # The editFrame is the main Frame of the widget
     self.masterFrame = tkinter.Frame(self.master,
                                      borderwidth=2,
                                      relief='ridge')
     self.immediate = immediate
     # Create a cbManager
     self.cbManager = CallbackManager()
     self.createCommon()
     self.createChooser()
     if commands:
         if type(commands) in [ListType, TupleType]:
             list(map(self.cbManager.AddCallback, commands))
             list(map(self.ce.cbManager.AddCallback, commands))
         else:
             self.cbManager.AddCallback(commands)
             self.ce.cbManager.AddCallback(commands)
Example #2
0
    def __init__(self, master=None, label=None, width=18, callback=None, **kw):
        Tkinter.Frame.__init__(self, master)
        Tkinter.Pack.config(self)

        self.var = Tkinter.StringVar()

        self.frame = Tkinter.Frame(self)

        if label and label != '':
            d = {'fg': 'black', 'text': label}
            self.tklabel = apply(Tkinter.Label, (self.frame, ), d)
            self.tklabel.pack()

        kw['width'] = width
        self.tkwidget = apply(Tkinter.Entry, (self.frame, ), kw)
        self.tkwidget.bind('<Return>', self.setValue_cb)
        self.tkwidget.pack()

        self.tkwidget['textvariable'] = self.var
        self.point = [0., 0, 0]
        self.text = '0 0 0'

        self.frame.pack(side='top', expand=1)

        self.myCallback = callback
        self.callbacks = CallbackManager()
        if self.myCallback:
            self.callbacks.AddCallback(self.myCallback)
    def __init__(self,
                 master,
                 title=None,
                 callback=None,
                 size=5,
                 border=1,
                 tkCol=None,
                 immediate=1):
        #tkCol is a list of list where each elemnt is a color
        # tkCol[0][0] = a Tk color
        # size = size of the sqare representing the Tkcolor on the canvas
        # border = border size
        #
        if not master:
            master = tkinter.Toplevel()

        if title is not None:
            master.title(title)

        f = self.frame = tkinter.Frame(master)

        if tkCol:
            self.Xelemt = len(tkCol)
            self.Yelemt = len(tkCol[0])
            self.size = size
            self.border = border
            self.width = (self.Xelemt * self.size + 2 * self.border)
            self.height = (self.Yelemt * self.size + 2 * self.border)
            self.cwcanvas = tkinter.Canvas(f,
                                           width=self.width,
                                           height=self.height,
                                           borderwidth=3)

            xo = self.border
            for i in range(self.Xelemt):
                xe = xo + self.size
                yo = self.border
                for j in range(self.Yelemt):
                    ye = yo + self.size
                    self.cwcanvas.create_rectangle(xo,
                                                   yo,
                                                   xe,
                                                   ye,
                                                   fill=tkCol[i][j])
                    yo = ye
                xo = xe

        self.cwcanvas.pack()
        #self.frame.pack()

        # CallBack Manager
        self.cbManager = CallbackManager()
        if callback:
            if type(callback) in [list, tuple]:
                list(map(self.cbManager.AddCallback, callback))
            else:
                self.cbManager.AddCallback(callback)
Example #4
0
    def __init__(self,
                 master=None,
                 name='XYZ',
                 callback=None,
                 callbackX=None,
                 widthX=100,
                 heightX=26,
                 wheelPadX=4,
                 labcfgX={'text': None},
                 widthY=100,
                 heightY=26,
                 wheelPadY=4,
                 labcfgY={'text': None},
                 callbackY=None,
                 widthZ=100,
                 heightZ=26,
                 wheelPadZ=4,
                 callbackZ=None,
                 labcfgZ={'text': None},
                 **kw):

        self.callback = callback  # user specified callback
        self.name = name  # title inside canvas

        self.widthX = widthX
        self.heightX = heightX
        self.wheelPadX = wheelPadX
        self.labcfgX = labcfgX
        self.widthY = widthY
        self.heightY = heightY
        self.wheelPadY = wheelPadY
        self.labcfgY = labcfgY
        self.widthZ = widthZ
        self.heightZ = heightZ
        self.wheelPadZ = wheelPadZ
        self.labcfgZ = labcfgZ

        #self.master = master = Tkinter.Frame(master)
        #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

        self.frame = tkinter.Frame(master, relief='sunken', borderwidth=5)
        self.frame.pack(expand=1, fill='x')
        self.createEntries(self.frame)

        if self.callback:
            self.callbacks.AddCallback(self.callback)
    def __init__(self,
                 master,
                 title=None,
                 width=150,
                 height=50,
                 callback=None):
        #tkCol is a list of list where each elemnt is a color
        # tkCol[0][0] = a Tk color
        # size = size of the sqare representing the Tkcolor on the canvas
        # border = border size
        #
        if not master:
            master = tkinter.Toplevel()

        if title is not None:
            master.title(title)

        f = self.frame = tkinter.Frame(master)

        self.coeff = 0.0
        self.value = "%.1f" % self.coeff + '%'
        self.width = width
        self.height = height

        self.cwcanvas = tkinter.Canvas(f, width=self.width, height=self.height)
        self.wrect = self.cwcanvas.create_rectangle(0,
                                                    0,
                                                    100,
                                                    10,
                                                    outline='black',
                                                    fill='white')
        self.rrect = self.cwcanvas.create_rectangle(0,
                                                    0,
                                                    self.coeff,
                                                    10,
                                                    outline='black',
                                                    fill='red')
        self.labelvalue = self.cwcanvas.create_text(120, 10, text=self.value)

        self.cwcanvas.pack(side='top')
        #self.frame.pack()

        # CallBack Manager
        self.cbManager = CallbackManager()
        if callback:
            if type(callback) in [list, tuple]:
                list(map(self.cbManager.AddCallback, callback))
            else:
                self.cbManager.AddCallback(callback)
Example #6
0
    def __init__(self, master, title=None, callback=None, immediate=1):
        if not master:
            master = tkinter.Toplevel()

        if title is not None:
            master.title(title)

        f = self.frame = tkinter.Frame(master)
        path = __import__('mglutil').__path__
        iconfile = os.path.join(path[0], 'gui/BasicWidgets/Tk/cw.ppm')
        self.iconfile = iconfile
        self.cwim = tkinter.PhotoImage(file=iconfile, master=master)
        self.width = self.cwim.width()
        self.height = self.cwim.height()
        self.cwcanvas = tkinter.Canvas(
            f,
            width=self.width,
            height=self.height,  ###relief='sunken',
            borderwidth=3)
        self.cwcanvas.create_image(3, 3, anchor=tkinter.NW, image=self.cwim)
        self.cwcanvas.pack()
        self.frame.pack()

        #self.callback = None
        self.cbManager = CallbackManager()
        if callback:
            if type(callback) in [ListType, TupleType]:
                list(map(self.cbManager.AddCallback, callback))
            else:
                self.cbManager.AddCallback(callback)
        self.afterID = None
        self.immediate = immediate
        self.x = 0
        self.y = 0
        self.radius = 55
        cx = self.cx = self.width / 2 + 3
        cy = self.cy = self.height / 2 + 3

        self.cursor = self.cwcanvas.create_line(cx - 3, cy - 3, cx - 3, cy + 3,
                                                cx + 3, cy + 3, cx + 3, cy - 3,
                                                cx - 3, cy - 3)

        self.hsvColor = [1., 1., 1.]

        self.cwcanvas.bind('<ButtonPress-1>', self.mouse1Down)
Example #7
0
    def __init__(self,
                 master=None,
                 currentColor=(1.0, 1.0, 1.0),
                 mode='RGB',
                 commands=None,
                 immediate=1):
        assert mode in ['RGB', 'HSV', 'HEX']
        self.mode = mode
        if not master:
            self.master = tkinter.Toplevel()
        else:
            self.master = master
        self.afterID = None
        self.immediate = immediate
        # The editFrame is the main Frame of the widget
        self.editFrame = tkinter.Frame(self.master,
                                       borderwidth=2,
                                       relief='ridge')
        self.cbManager = CallbackManager()
        if commands:
            if type(commands) in [ListType, TupleType]:
                list(map(self.cbManager.AddCallback, commands))
            else:
                self.cbManager.AddCallback(commands)

        if mode == 'HSV':
            self.currentHSV = list(currentColor)
            self.currentRGB = list(ToRGB(currentColor))
            self.currentHEX = ToHEX(currentColor, mode='HSV')

        elif mode == 'RGB':
            self.currentRGB = list(currentColor)
            self.currentHSV = list(ToHSV(currentColor))
            self.currentHEX = ToHEX(currentColor, mode='RGB')

        elif mode == 'HEX':
            self.currentRGB = ToHEX(currentColor, mode='RGB')
            self.currentHSV = ToHEX(currentColor, mode='HSV')
            self.currentHEX = currentColor
        else:
            print('mode not recognized mode set to RGB')
        self.createColorEditor()
Example #8
0
 def __init__(self,master=None,callback=None,continuous=1):
            
     self.master=master
     self.callback = None
     self.callbacks = CallbackManager()
     self.canvas=canvas = Canvas(self.master,width=345,height=320,bg='white') 
     self.toolbar = Frame(master)             # Create Toolbar
     self.toolbar.pack(side='top', expand=1, fill='both') 
     self.menuFrame1 = Tkinter.Frame(self.toolbar, relief='raised', borderwidth=3)
     self.menuFrame1.pack(side='top', expand=1, fill='x')
     self.filebutton = Tkinter.Menubutton(self.menuFrame1, text='File')
     self.filebutton.pack(side='left')
     self.filemenu = Tkinter.Menu(self.filebutton, {})
     self.filemenu.add_command(label='Read', command=self.read_cb)
     self.filemenu.add_command(label='Write', command=self.write_cb)
     self.filebutton['menu'] = self.filemenu
     self.editbutton = Tkinter.Menubutton(self.menuFrame1, text='Edit')
     self.editbutton.pack(side='left', anchor='w')
     self.editmenu = Tkinter.Menu(self.editbutton, {})
     self.editmenu.add_command(label='Reset to first in history', command=self.resetAll_cb)
     self.editmenu.add_command(label='Step back in history loop', command=self.stepBack_cb)
     self.editmenu.add_command(label='Default Curve', command=self.defaultcurve_cb)
     self.editmenu.add_command(label='Invert Curve',command=self.invertGraph)
     self.histvar=IntVar()
     self.histvar.set(1)
     self.editmenu.add_checkbutton(label='Histogram',var=self.histvar,command=self.drawHistogram)
     self.editbutton['menu'] = self.editmenu
     self.optionType = IntVar()
     self.updatebutton = Tkinter.Menubutton(self.menuFrame1, text='Update')
     self.updatebutton.pack(side='left', anchor='w')
     self.updatemenu = Tkinter.Menu(self.updatebutton,{} )
     for v,s in {0:'Continuous',1:'MouseButtonUp',2:'Update'}.items():
         self.updatemenu.add_radiobutton(label=s,
                             var=self.optionType,
                             value = v,command=self.calloption)
     if continuous==1:
         self.optionType.set(0)
     self.updatebutton['menu'] = self.updatemenu
     #Curve Type
     self.CurveType = IntVar()
     self.CurveType.set(0) 
     self.Smooth=1
     self.curvebutton = Tkinter.Menubutton(self.menuFrame1, text='Curve')
     self.curvebutton.pack(side='left', anchor='w')
     self.curvemenu = Tkinter.Menu(self.curvebutton,{} )
     for v,s in {0:'Smooth',1:'Freehand'}.items():
         self.curvemenu.add_radiobutton(label=s,
                             var=self.CurveType,
                             value = v,command=self.curveoption)
     
         
     self.curvebutton['menu'] = self.curvemenu
     f1 = Tkinter.Frame(self.master)
     f1.pack(side='bottom', fill='both', expand=1)
     self.d1scalewheellab=Label(f1,text="Sensitivity")
     self.d1scalewheellab.pack(side="left")
     self.d1scalewheel=ThumbWheel(width=100, height=26,wheelPad=4,master=f1,labcfg={'fg':'black', 'side':'left', 'text':'Test:'},wheelLabcfg1={'font':(ensureFontCase('times'),14,'bold')},wheelLabcfg2={'font':(ensureFontCase('times'),14,'bold')},canvascfg={'bg':'blue'},min = 0.0,max = 1.0,precision =4,showlabel =0,value =0.013,continuous =0,oneTurn =0.01,size = 200)
     self.d1scalewheel.pack(side="left")
     #tooltip
     self.balloon = Pmw.Balloon(f1)
     self.balloon.bind(self.d1scalewheel,"cutoff value for differences in Z xoordinates,small values generate more contours")
     self.Updatebutton=Button(f1,text='  Update  ',command=self.Update)
     self.Updatebutton.pack(side=LEFT)
     
     self.Quitbutton=Button(f1,text=' Dismiss ',command=self.dismiss_cb)
     self.Quitbutton.pack(side=RIGHT)
     self.canvas.bind("<Button-1>", self.OnCanvasClicked)
     self.canvas.bind("<B1-Motion>", self.OnCanvasMouseDrag)
     self.canvas.bind("<ButtonRelease-1>", self.OnCanvasMouseUp)
     self.canvas.config(closeenough=2.0)
     self.canvas.pack(side=BOTTOM, fill=BOTH,expand=1)
     self.startpoint=(px,py)=(50,275)
     self.endpoint=(px1,py1)=(305,20)
     self.newpoints=[(px,py),(px1,py1)]
     self.canvas.create_rectangle([(px-1,py),(px1+1,py1)],fill='white',outline="black",width=1)
     self.canvas.create_text(46,281,text=0,anchor=N)
               
     #Drawing Graph Sheet
     for i in range(1,6):
         x=50+i*50
         canvas.create_line(x,280,x,275,width=1)
         canvas.create_text(x,281,text='%d' %(50*i),anchor=N)
     for i in range(1,5):
         x=50+i*50
         canvas.create_line(x,275,x,20,width=1,fill="gray80")
     for i in range(1,6):
         y=275-i*50
         canvas.create_line(45,y,50,y,width=1)
         canvas.create_text(44,y,text='%d' %(50*i),anchor=E)
     for i in range(1,5):
         y=275-i*50
         canvas.create_line(50,y,305,y,width=1,fill="gray80")
     (x,y)=self.newpoints[0]
     (x1,y1)=self.newpoints[-1]
     self.curline=canvas.create_line(self.newpoints,fill='black',width=1)
     
     #GRAY SCALE
     grays=[]
     for i in range(0,100,1):
         grays.append("gray"+"%d" %i)
     #grays.reverse()
     #bottom one
     x1=48
     x2=51
     self.canvas.create_rectangle([(50,315),(307,300)],fill='white',outline="black",width=0.5)
     for a in grays:
         if x1>306:
             
            x1=x2=306
         self.canvas.create_rectangle([(x1+2.5,314),(x2+2.5,301)],fill=a,outline=a,width=1)
         x1=x1+2.5
         x2=x2+2.5
     #left one
     y1=274
     y2=271
     self.canvas.create_rectangle([(20,275),(5,20)],fill='black',outline="black",width=0.5)
     for a in grays:
         if y1>275:
             y1=y2=275
         self.canvas.create_rectangle([(19,y1-2.5),(6,y2-2.5)],fill=a,outline=a,width=1)    
         y1=y1-2.5
         y2=y2-2.5
           
     self.oldpoints=[]
     self.canvas.configure(cursor='cross')
     self.curovals=[]
     self.default_points=[(50,275),(88, 238), (101, 150), (154, 78), (75, 271),(305,20)]
     # now set the constructor options correctly using the configure method
     apply( self.configure, (),{'callback':callback,'continuous':continuous})
     self.continuous=continuous
     self.mousebuttonup=0
     self.update=0
     self.range_points=[]
     self.history=[]
     self.bars=[]
     self.default_ramp=[]
     self.histvalues=[]
Example #9
0
    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")
Example #10
0
    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,
                 name='vector',
                 size=200,
                 continuous=1,
                 vector=[0.0, 0.0, 1.0],
                 mode='XY',
                 precision=5,
                 lockContinuous=0,
                 lockPrecision=0,
                 lockMode=0,
                 callback=None,
                 labelSide='top'):

        KeyboardModifierMonitor.__init__(self)

        self.callback = callback  # user specified callback
        self.name = name  # title inside canvas
        self.labelSide = labelSide  # where title gets packed
        self.mode = mode  # axe mode: can be 'XY', 'X', 'Y' or 'Z'
        self.precision = precision  # floating number digits
        self.continuous = continuous  # can be 1 or 0
        self.vector = vector  # initial vector value
        self.size = size  # size of vector widget

        self.lockContinuous = lockContinuous  # set to 1 to lock menus in
        # option panel
        self.lockPrecision = lockPrecision
        self.lockMode = lockMode

        self.r = self.size / 2
        self.r2 = self.r * self.r

        self.drawShadowX = 0
        self.drawShadowY = 1
        self.drawShadowZ = 0
        self.fillShadowPlanes = 1

        self.master = master = tkinter.Frame(master)
        #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
        self.zeros = numpy.array((0, 0, 0), numpy.int16)
        self.viewingMatInv = numpy.array(
            [[0.96770716, -0.03229283, -0.25, 0.],
             [0.03229283, -0.96770716, 0.25, 0.], [0.25, 0.25, 0.93541437, 0.],
             [0., 0., 0., 1.]], 'f')
        self.viewingMat = numpy.transpose(self.viewingMatInv)
        self.createCanvas(master, size)
        self.createEntries(self.frame)
        tkinter.Widget.bind(self.canvas, "<ButtonPress-1>", self.mouseDown)
        tkinter.Widget.bind(self.canvas, "<ButtonRelease-1>", self.mouseUp)
        tkinter.Widget.bind(self.canvas, "<B1-Motion>", self.mouseMove)

        self.setEntries()

        self.opPanel = VectorOptionsPanel(master=self,
                                          title="Vector GUI Options")
        tkinter.Widget.bind(self.canvas, "<Button-3>", self.toggleOptPanel)

        if self.callback:
            self.callbacks.AddCallback(self.callback)
Example #12
0
    def __init__(self):
        self.kbdModifier = {
            'Shift_L':0,
            'Alt_L':0,
            'Control_L':0,
            'Shift_R':0,
            'Alt_R':0,
            'Control_R':0,
            }
	self.keybdModifierCallbacksDown = {
	    'Shift_L':CallbackManager(),
            'Alt_L':CallbackManager(),
            'Control_L':CallbackManager(),
            'Shift_R':CallbackManager(),
            'Alt_R':CallbackManager(),
            'Control_R':CallbackManager(),
	}
	self.keybdModifierCallbacksUp = {
	    'Shift_L':CallbackManager(),
            'Alt_L':CallbackManager(),
            'Control_L':CallbackManager(),
            'Shift_R':CallbackManager(),
            'Alt_R':CallbackManager(),
            'Control_R':CallbackManager(),
	}
Example #13
0
    def __init__(self,
                 master=None,
                 type='float',
                 labCfg={
                     'fg': 'black',
                     'side': 'left',
                     'text': None
                 },
                 min=None,
                 max=None,
                 showLabel=1,
                 value=0.0,
                 continuous=1,
                 precision=2,
                 callback=None,
                 lockMin=0,
                 lockBMin=0,
                 lockMax=0,
                 lockBMax=0,
                 lockPrecision=0,
                 lockShowLabel=0,
                 lockValue=0,
                 lockType=0,
                 lockContinuous=0,
                 signatures=None,
                 **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.height = 100  # widget height
        self.width = 256  # widget height
        self.widthMinusOne = self.width - 1

        self.min = 0  # minimum value
        self.max = 1  # maximum value
        self.range = self.max - self.min

        self.precision = 2  # decimal places
        self.minOld = 0.  # used to store old values
        self.maxOld = 0.
        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.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.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.lockMin = lockMin  # lock<X> vars are used in self.lock()
        self.lockMax = lockMax  # to lock/unlock entries in optionpanel
        self.lockBMin = lockBMin
        self.lockBMax = lockBMax
        self.lockPrecision = 0
        self.lockShowLabel = lockShowLabel
        self.lockValue = lockValue
        self.lockType = lockType
        self.lockContinuous = lockContinuous

        # configure with user-defined values
        self.setCallback(callback)
        self.setContinuous(continuous)

        self.setType(type)
        self.setPrecision(precision)
        self.setMin(min)
        self.setMax(max)
        self.setShowLabel(showLabel)
        self.setValue(value)
        self.setLabel(self.labCfg)

        if master is None:
            master = Tkinter.Toplevel()

        self.master = master  # widget master

        self.createCanvas(master)

        Tkinter.Widget.bind(self.canvas, "<ButtonPress-1>", self.mouseDown)
        Tkinter.Widget.bind(self.canvas, "<B1-Motion>", self.mouseMove)
        Tkinter.Widget.bind(self.canvas, "<ButtonRelease-1>", self.mouseUp)

        # create cursor
        self.cursorTk = self.canvas.create_line(0, 0, 0, 0, tags=['cursor'])

        self.increment = 0.0
        self.incrementOld = 0.
        self.lockIncrement = 0
        self.lockBIncrement = 0
        self.oneTurn = 360.
        self.lockOneTurn = 0
        self.opPanel = OptionsPanel(master=self, title="Slider graph Options")

        self.signatures = None  # Signature objects fro isocontouring lib
        self.sigData = []  # list of (x,y) values arrays for each signature
        self.maxFun = []  # max Y value in each signature
        self.minFun = []  # min Y value in each signature
        self.yratios = []  # normalization factors
        self.colors = ['red', 'green', 'blue', 'orange']
        self.tkLines = []  # list of Tkids for lines
        if signatures:
            self.setSignatures(signatures)