def test_thumbwheel():
    def tw_cb(event=None):
        pass
    from mglutil.gui.BasicWidgets.Tk.thumbwheel import ThumbWheel
    descr = InputFormDescr(title = 'Testing InputForm')
    descr.append({'name':'thumbwheel',
                  'widgetType':ThumbWheel,
                  'tooltip':"""Right click on the widget will display the control
                  panel and you can type a value manually""",
                  'defaultValue':100,
                  'wcfg':{'text':None,
                          'showLabel':1, 'width':100,
                          'min':0,
                          'lockBMin':1,
                          'lockBMax':1,
                          'lockBIncrement':1,
                          'value':40,
                          'oneTurn':1000,
                          'type':'int',
                          'increment':2,
                          'canvascfg':{'bg':'red'},
                          'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                          'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                          'callback':tw_cb,
                          'continuous':1, 'wheelPad':1, 'height':20},
                  'gridcfg':{'sticky':'e','row':-1}})
    
    form = InputForm(master, root, descr)
    value = form.testForm()
    assert value['thumbwheel']==100
    form.destroy() 
Exemplo n.º 2
0
 def test_constructorOptions(self):
     # test all possible constructor options
     root = Tkinter.Tk()
     tw = ThumbWheel(width=100, height=26,wheelPad=4,master = root,
                     labcfg={'fg':'black', 'side':'left', 'text':'Test:'},
                     wheelLabcfg1={'font':(ensureFontCase('times'),14,'bold')},
                     wheelLabcfg2={'font':(ensureFontCase('times'),14,'bold')},
                     canvascfg={'bg':'blue'}) 
     tw.master.update()
     pause()
     tw.master.destroy()
Exemplo n.º 3
0
 def resetTags(self):
     self.textFrame.tag_configure('email', font=(ensureFontCase('times'), 10, 'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('http', font=(ensureFontCase('times'), 12, 'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('normal10b',
                                  font=(ensureFontCase('helvetica'), 10, 'bold'),
                                  justify="right",
                                  foreground=self.avg)
     self.textFrame.tag_configure('mediumb',
                                  font=(ensureFontCase('helvetica'), 14, 'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('title',
                                  font=(ensureFontCase('helvetica'), 14, 'bold'),
                                  foreground=self.avg, justify="center")
Exemplo n.º 4
0
    def createForm(self):

        self.idf.append({'widgetType':Tkinter.Label,
                 'wcfg':{'text':'Sphere quality'},
                 'gridcfg':{'sticky':'w','columnspan':1, 'row':0, 'column':0},
                 })

        self.idf.append({'name':'inpSphQual',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':self.sphereQuality,
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.sphInput,
                                 'command':self.sphereQuality_cb,
                                 },
                         'gridcfg':{'sticky':'e',
                                    'columnspan':1, 'row':0, 'column':1 }
                         })

        self.idf.append({'widgetType':Tkinter.Label,
                 'wcfg':{'text':'Cylinder quality'},
                 'gridcfg':{'sticky':'w','columnspan':1, 'row':1, 'column':0},
                 })

        self.idf.append({'name':'inpCylQual',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':self.cylinderQuality,
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.cylInput,
                                 'command':self.cylinderQuality_cb,
                                 },
                         'gridcfg':{'sticky':'e',
                                    'columnspan':1, 'row':1, 'column':1 }
                         })
        
	self.idf.append({'widgetType':Tkinter.Button,
                         'text':'OK',
                         'wcfg':{},
                         'gridcfg':{'sticky':'wens',
                                    'columnspan':1, 'row':2, 'column':0},
                         'command': self.OK_cb})


	self.idf.append({'widgetType':Tkinter.Button,
                         'text':'Cancel',
                         'wcfg':{},
                         'gridcfg':{'sticky':'wens',
                                    'columnspan':1, 'row':2, 'column':1},
                         'command': self.Cancel_cb})
    def __init__(self, name='NoName', master=None, nodeList=[], **kw):
        """
        """
        self.name = name
        self.nodes = {}
        self.geoms = {}

        if 'visibleWidth' in kw:
            self.visibleWidth = visibleWidth
            del kw['visibleWidth']
        else:
            self.visibleWidth = 400

        if 'visibleHeight' in kw:
            self.visibleWidth = visibleHeight
            del kw['visibleHeight']
        else:
            self.visibleHeight = 400

        if 'totalWidth' in kw:
            self.visibleWidth = totalWidth
            del kw['totalWidth']
        else:
            self.totalWidth = 400

        if 'totalHeight' in kw:
            self.totalHeight = totalHeight
            del kw['totalHeight']
        else:
            self.totalHeight = 400

        if 'hasScroll' in kw:
            self.hasScroll = hasScroll
            del kw['hasScroll']
        else:
            self.hasScroll = 0

        if 'font' in kw:
            self.font = font
            del kw['font']
        else:
            self.font = (ensureFontCase('helvetica'), 14)

        tkinter.Frame.__init__(self, master)
        tkinter.Pack.config(self, expand=1, fill=tkinter.BOTH)
        self.createCanvas(*(), **kw)
        self.paramPanelObject = None
        self.plotarea_size = [None, None]
        tkinter.Widget.bind(self.draw, '<Enter>', self.enter)
        # bind mouse button callbacks
        self.draw.bind("<Any-ButtonPress-1>", self.mouse1DownCanvas)
        self.draw.bind("<Any-ButtonPress-3>", self.mouse1DownCanvas)
        self.draw.bind("<Any-ButtonPress-2>", self.mouse1DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-1>", self.mouse2DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-2>", self.mouse2DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-3>", self.mouse2DownCanvas)
        self.draw.old_current = None
    def __init__(self, name='NoName', master=None, nodeList=[], **kw):
        """
        """
        self.name = name
        self.nodes = {}
        self.geoms = {}

        if kw.has_key('visibleWidth'):
            self.visibleWidth = visibleWidth
            del kw['visibleWidth']
        else:
            self.visibleWidth = 400

        if kw.has_key('visibleHeight'):
            self.visibleWidth = visibleHeight
            del kw['visibleHeight']
        else:
            self.visibleHeight = 400

        if kw.has_key('totalWidth'):
            self.visibleWidth = totalWidth
            del kw['totalWidth']
        else:
            self.totalWidth = 400

        if kw.has_key('totalHeight'):
            self.totalHeight = totalHeight
            del kw['totalHeight']
        else:
            self.totalHeight = 400

        if kw.has_key('hasScroll'):
            self.hasScroll = hasScroll
            del kw['hasScroll']
        else:
            self.hasScroll = 0

        if kw.has_key('font'):
            self.font = font
            del kw['font']
        else:
            self.font = (ensureFontCase('helvetica'), 14)

        Tkinter.Frame.__init__(self, master)
        Tkinter.Pack.config(self, expand=1, fill=Tkinter.BOTH)
        apply(self.createCanvas, (), kw)
        self.paramPanelObject = None
        self.plotarea_size = [None, None]
        Tkinter.Widget.bind(self.draw, '<Enter>', self.enter)
        # bind mouse button callbacks
        self.draw.bind("<Any-ButtonPress-1>", self.mouse1DownCanvas)
        self.draw.bind("<Any-ButtonPress-3>", self.mouse1DownCanvas)
        self.draw.bind("<Any-ButtonPress-2>", self.mouse1DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-1>", self.mouse2DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-2>", self.mouse2DownCanvas)
        self.draw.bind("<Any-Double-ButtonPress-3>", self.mouse2DownCanvas)
        self.draw.old_current = None
Exemplo n.º 7
0
    def buildPanel(self):
        # prevent re-creation
        if self.panel is not None:
            self.panel.show()
            return
        
        root = self.panel = Tkinter.Toplevel()
        self.frame = Tkinter.Frame(root, borderwidth=2,
                                   relief='sunken', padx=5, pady=5)
        self.frame.pack(side='top', expand=1, fill='both')

        txtFrame = Tkinter.Frame(self.frame)

        self.textFrame = Tkinter.Text(txtFrame, background=self.bg,
                                      exportselection=1, padx=10, pady=10,)
        
        self.textFrame.tag_configure('big', font=(ensureFontCase('Courier'), 24, 'bold'),
                                foreground=self.fg)
        self.textFrame.tag_configure('medium', font=(ensureFontCase('helvetica'), 14, 'bold'),
                                foreground=self.fg)
        self.textFrame.tag_configure('normal12',
                                     font=(ensureFontCase('helvetica'), 12, 'bold'),
                                     foreground=self.fg)
        self.textFrame.tag_configure('normal10',
                                     font=(ensureFontCase('helvetica'), 10, 'bold'),
                                     foreground=self.fg)
        self.textFrame.tag_configure('normal8',
                                     font=(ensureFontCase('helvetica'), 8, 'bold'),
                                     foreground=self.fg)
        self.textFrame.tag_configure('email', font=(ensureFontCase('times'), 10, 'bold'),
                                     foreground='lightblue')
        self.textFrame.tag_configure('http', font=(ensureFontCase('times'), 12, 'bold'),
                                     foreground='lightblue')
        self.textFrame.tag_configure('normal10b',
                                     font=(ensureFontCase('helvetica'), 10, 'bold'),
                                     foreground='lightblue')
        
        self.textFrame.pack(side='left', expand=1, fill='both')

        # provide a scrollbar
        self.scroll = Tkinter.Scrollbar(txtFrame, command=self.textFrame.yview)
        self.textFrame.configure(yscrollcommand = self.scroll.set)
        self.scroll.pack(side='right', fill='y')
        txtFrame.pack(expand=1, fill='both')
        
        # proved an OK button
        buttonFrame = Tkinter.Frame(self.frame)
        buttonFrame.pack(side='bottom', fill='x')
        self.buttonOk = Tkinter.Button(buttonFrame, text='  Ok  ',
                                       command=self.Ok)
        self.buttonOk.pack(padx=6, pady=6)
 def validateFunc(self, font):
     root=self.vf.GUI.ROOT.tk
     familyNames=list(root.splitlist(root.call('font','families')))
     if not type(font) == tuple:
         font = font.split() 
     if len(font) < 3:
         return False
     font0 = ensureFontCase(font[0])
     if font0 in familyNames and font[2] in['normal','bold','bold italic','italic']:
         return True
     else:
         return False
Exemplo n.º 9
0
 def viewSource(self):
     import tkinter, Pmw
     root = tkinter.Toplevel()
     root.title(self.filename)
     self.st = Pmw.ScrolledText(root)
     self.st.pack(fill = 'both', expand=1)
     
     self.st._textbox.configure(bg='white', font=(ensureFontCase('Courier'), '10'))
     txt = ''
     for line in self.allLines:
         txt += ''.join(line)
     self.st.setvalue(txt)
Exemplo n.º 10
0
 def __init__(self, master, lists, **kw):
     Pmw.ScrolledFrame.__init__(self,
                                master,
                                horizflex='expand',
                                vertflex='elastic',
                                vscrollmode='none',
                                **kw)
     self.lists = []
     self.colmapping = {}
     self.origData = None
     self.rows = None
     self.myFont = tkinter.font.Font(font=(ensureFontCase('helvetica'), 11,
                                           "bold"))
     frame_main = Frame(self.interior())
     frame_main.pack(side=LEFT, expand=YES, fill=BOTH)
     frame_sb = Frame(self.interior())
     frame_sb.pack(side=LEFT, fill=Y)
     sb = Scrollbar(frame_sb, orient=VERTICAL, command=self._scroll)
     m = PanedWindow(frame_main, bd=0, handlepad=0, handlesize=0, sashpad=0)
     m.pack(fill=BOTH, expand=1)
     self.PanedWindow = m
     for l, w in lists:
         frame = Frame(m, bd=0)
         frame.pack(side=LEFT, expand=YES, fill=BOTH)
         b = Button(frame,
                    text=str(l),
                    relief=RAISED,
                    font=self.myFont,
                    bd=1)
         b.pack(fill=X)
         b.bind('<Button-1>', self._sort)
         self.colmapping[b] = (len(self.lists), 1)
         lb = Listbox(frame,
                      width=w,
                      bd=0,
                      exportselection=FALSE,
                      bg='white')
         lb.pack(expand=YES, fill=BOTH)
         self.lists.append(lb)
         lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
         lb.bind('<Button-1>', lambda e, s=self: s._select(e.y))
         lb.bind('<Double-Button-1>', lambda e, s=self: s.output(e.y))
         lb.bind('<Leave>', lambda e: 'break')
         lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
         lb.bind('<Button-2>', lambda e, s=self: s._button2(e.x, e.y))
         #            import pdb
         #            pdb.set_trace()
         m.add(frame, width=lb.winfo_reqwidth())
     sb.pack(expand=YES, fill=Y)
     self.lists[0]['yscrollcommand'] = sb.set
     self.interior().pack(expand=YES, fill=BOTH)
Exemplo n.º 11
0
 def validateFunc(self, font):
     root = self.vf.GUI.ROOT.tk
     familyNames = list(root.splitlist(root.call('font', 'families')))
     if not type(font) == tuple:
         font = font.split()
     if len(font) < 3:
         return False
     font0 = ensureFontCase(font[0])
     if font0 in familyNames and font[2] in [
             'normal', 'bold', 'bold italic', 'italic'
     ]:
         return True
     else:
         return False
Exemplo n.º 12
0
 def resetTags(self):
     self.textFrame.tag_configure('email',
                                  font=(ensureFontCase('times'), 10,
                                        'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('http',
                                  font=(ensureFontCase('times'), 12,
                                        'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('normal10b',
                                  font=(ensureFontCase('helvetica'), 10,
                                        'bold'),
                                  justify="right",
                                  foreground=self.avg)
     self.textFrame.tag_configure('mediumb',
                                  font=(ensureFontCase('helvetica'), 14,
                                        'bold'),
                                  foreground=self.avg)
     self.textFrame.tag_configure('title',
                                  font=(ensureFontCase('helvetica'), 14,
                                        'bold'),
                                  foreground=self.avg,
                                  justify="center")
Exemplo n.º 13
0
    def gui(self, master):

        Tkinter.Label(master, text=self.title, font =(ensureFontCase('helvetica'), 16, 'bold') ).\
                      pack(side='top')
        text = 'Version ' + self.version
        if self.revision is not None:
            text += ' revision ' + self.revision
        night = self.path_data.find(" Nightly ")
        if night != -1:
            tmpTxt = self.path_data[night:].split()
            text += " - Update Nightly Build " + tmpTxt[1]
        else:
            tested = self.path_data.find(" Tested ")
            if tested != -1:
                tmpTxt = self.path_data[tested:].split()
                text += " - Update Tested Build " + tmpTxt[1]
        text += " DAMJAN "
        Tkinter.Label(master, text=text).pack(side='top')

        files = os.listdir(self.image_dir)
        import fnmatch
        files = fnmatch.filter(files, '*.jpg') + fnmatch.filter(files, '*.png')
        import random
        rand = random.randint(0, len(files) - 1)
        image_file = os.path.join(os.path.join(self.image_dir, files[rand]))
        image = Image.open(image_file)
        self.image1 = ImageTk.PhotoImage(image, master=master)
        self.imageTk = Tkinter.Label(master, image=self.image1)
        self.imageTk.pack()
        Tkinter.Label(master, text=self.authors,
                      relief='sunken').pack(fill='x')
        Tkinter.Label(master, text=self.copyright, relief='sunken').pack()
        logoFrame = Tkinter.Frame(master, bg='white')
        logoFrame.pack(fill='x', expand=True)

        basepath = os.path.join(os.path.split(__file__)[0], 'gui', 'splash')

        NBCR = Image.open(os.path.join(basepath, 'NBCR.jpg'))
        self.NBCR1 = ImageTk.PhotoImage(NBCR, master=master)
        self.NBCRTk = Tkinter.Label(logoFrame, image=self.NBCR1, bd=0)
        self.NBCRTk.pack(side='left', padx=40, expand=True)
        NIH = Image.open(os.path.join(basepath, 'NIH.gif'))
        self.NIH1 = ImageTk.PhotoImage(NIH, master=master)
        self.NIHTk = Tkinter.Label(logoFrame, image=self.NIH1, bd=0)
        self.NIHTk.pack(side='left', padx=40, expand=True)
        NSF = Image.open(os.path.join(basepath, 'NSF.gif'))
        self.NSF1 = ImageTk.PhotoImage(NSF, master=master)
        self.NSFTk = Tkinter.Label(logoFrame, image=self.NSF1, bd=0)
        self.NSFTk.pack(side='left', padx=40, expand=True)
Exemplo n.º 14
0
    def __init__(self, title="Bug Report", message="", bg=None,
                 fg=None, font=(ensureFontCase('helvetica'), 8, 'bold'),):
        self.panel = None 
        self.title = title         # Title of this Dialog window
        self.message = message     # Help message
        self.bg = bg               # Frame background
        self.fg = fg               # text color
        self.font = font           # text font

        self.buildPanel()

        self.panel.title(self.title)
        
        # bind OK button callback
        self.panel.protocol("WM_DELETE_WINDOW", self.Ok)
Exemplo n.º 15
0
    def gui(self, master):
        
        Tkinter.Label(master, text=self.title, font =(ensureFontCase('helvetica'), 16, 'bold') ).\
                      pack(side='top')
        text = 'Version ' + self.version
        if self.revision is not None:
            text += ' revision ' + self.revision
        night = self.path_data.find(" Nightly ")
        if night != -1:
            tmpTxt = self.path_data[night:].split()
            text += " - Update Nightly Build " + tmpTxt[1]
        else:
            tested = self.path_data.find(" Tested ")
            if tested != -1:
                tmpTxt = self.path_data[tested:].split()
                text += " - Update Tested Build " + tmpTxt[1]
        text += " DAMJAN "    
        Tkinter.Label(master, text=text).pack(side='top')

        files = os.listdir(self.image_dir)
        import fnmatch
        files = fnmatch.filter(files,'*.jpg') + fnmatch.filter(files,'*.png')
        import random
        rand = random.randint(0,len(files)-1)
        image_file = os.path.join(os.path.join(self.image_dir ,files[rand]))
        image = Image.open(image_file)
        self.image1 = ImageTk.PhotoImage(image, master=master)
        self.imageTk = Tkinter.Label(master,image=self.image1 )
        self.imageTk.pack()
        Tkinter.Label(master, text=self.authors, relief='sunken' ).pack(fill='x')
        Tkinter.Label(master, text=self.copyright, relief='sunken' ).pack()
        logoFrame = Tkinter.Frame(master, bg='white')
        logoFrame.pack(fill='x',expand=True)

        basepath = os.path.join(os.path.split(__file__)[0], 'gui', 'splash')
        
        NBCR = Image.open(os.path.join(basepath,'NBCR.jpg'))
        self.NBCR1 = ImageTk.PhotoImage(NBCR, master=master)
        self.NBCRTk = Tkinter.Label(logoFrame,image=self.NBCR1, bd=0 )
        self.NBCRTk.pack(side='left', padx=40, expand=True)
        NIH = Image.open(os.path.join(basepath,'NIH.gif'))
        self.NIH1 = ImageTk.PhotoImage(NIH, master=master)
        self.NIHTk = Tkinter.Label(logoFrame,image=self.NIH1, bd=0)
        self.NIHTk.pack(side='left', padx=40,expand=True)
        NSF = Image.open(os.path.join(basepath,'NSF.gif'))
        self.NSF1 = ImageTk.PhotoImage(NSF, master=master)
        self.NSFTk = Tkinter.Label(logoFrame,image=self.NSF1, bd=0)
        self.NSFTk.pack(side='left', padx=40, expand=True)
Exemplo n.º 16
0
 def __init__(
         self,
         title="Bug Report",
         message="",
         bg=None,
         fg=None,
         font=(ensureFontCase('helvetica'), 10, 'bold'),
 ):
     BugReport.__init__(
         self,
         title,
         message,
         bg,
         fg,
         font,
     )
Exemplo n.º 17
0
    def __init__(self, title="Help Dialog", message="", bg=None,
                 fg=None, font=(ensureFontCase('helvetica'), 8, 'bold'),):
        self.panel = None 
        self.title = title         # Title of this Dialog window
        self.message = message     # Help message
        self.bg = bg               # Frame background
        self.fg = fg               # text color
        self.font = font           # text font

        self.buildPanel()

        self.panel.title(self.title)
        
        # bind OK button callback
        self.panel.protocol("WM_DELETE_WINDOW", self.Ok)
        # disable typing stuff in the window
        self.textFrame.configure(state='disabled')
Exemplo n.º 18
0
    def __init__(self, master, lists, **kw):
        Pmw.ScrolledFrame.__init__(self, master, horizflex='expand',vertflex='elastic',
                                    vscrollmode='none', **kw)
        self.lists = []
        self.colmapping = {}
        self.origData = None
        self.rows = None
        self.myFont = tkFont.Font(font = (ensureFontCase('helvetica'), 11, "bold"))
        frame_main = Frame(self.interior())
        frame_main.pack(side=LEFT, expand=YES, fill=BOTH)
        frame_sb = Frame(self.interior())
        frame_sb.pack(side=LEFT, fill=Y)
        sb = Scrollbar(frame_sb, orient=VERTICAL, command=self._scroll)
        m = PanedWindow(frame_main,bd=0,handlepad=0,handlesize=0,sashpad=0)
        m.pack(fill=BOTH, expand=1)
        self.PanedWindow = m
        for l,w in lists:
            frame = Frame(m,bd=0); frame.pack(side=LEFT, expand=YES, fill=BOTH)
            b = Button(frame, text=unicode(l),  relief=RAISED, font=self.myFont,bd=1)
            b.pack(fill = X)
            b.bind('<Button-1>', self._sort)
            self.colmapping[b]=(len(self.lists),1)
            lb = Listbox(frame, width=w, bd=0,
                         exportselection=FALSE,bg='white')
            lb.pack(expand=YES, fill=BOTH)
            self.lists.append(lb)
            lb.bind('<B1-Motion>', lambda e, s=self: s._select(e.y))
            lb.bind('<Button-1>', lambda e, s=self: s._select(e.y))
            lb.bind('<Double-Button-1>', lambda e, s=self: s.output(e.y))
            lb.bind('<Leave>', lambda e: 'break')
            lb.bind('<B2-Motion>', lambda e, s=self: s._b2motion(e.x, e.y))
            lb.bind('<Button-2>', lambda e, s = self: s._button2(e.x, e.y))
#            import pdb
#            pdb.set_trace()
            m.add(frame, width=lb.winfo_reqwidth())    
        sb.pack(expand=YES, fill=Y)
        self.lists[0]['yscrollcommand']=sb.set        
        self.interior().pack(expand=YES, fill=BOTH)
    def __init__(self, master=None, title=None):
        self.master = master
        self.root = None

        self.title = title
        if self.title is None:
            self.title = 'Options Panel'

        if self.master is None:  # this is to test this widget without a widget
            self.master = tkinter.Tk()
            self.master.continuous = 1

            def configure(**kw):
                pass

            self.master.configure = configure
            self.master.min = None  # min value allowed for val
            self.master.max = None  # max value allowed for val
            self.master.increment = None  # discrete value allowed for val
            self.master.incrementOld = 0.0
            self.master.oneTurn = 1.0
            self.master.value = 0.0
            self.master.type = float
            self.master.precision = 3
            self.master.showLabel = 0
            self.master.labelFormat = "%d"
            self.master.minOld = 0
            self.master.maxOld = 0
            self.master.lockContinuous = 0
            self.master.lockMin = 0
            self.master.lockMax = 0
            self.master.lockBMin = 0
            self.master.lockBMax = 0
            self.master.lockIncrement = 1
            self.master.lockBIncrement = 0
            self.master.lockValue = 0
            self.master.lockOneTurn = 0
            self.master.lockShowLabel = 0
            self.master.lockType = 0
            self.master.lockPrecision = 0
            self.master.opPanel = self
            #self.master.withdraw()

        self.flag = 0  # this flag toggles display/undisplay
        # used in the various GUIs

        self.type = float  # can be float or int

        self.toggleMin = tkinter.IntVar()
        self.minInput = tkinter.StringVar()
        self.min_entry = None

        self.toggleMax = tkinter.IntVar()
        self.maxInput = tkinter.StringVar()
        self.max_entry = None

        self.toggleIncr = tkinter.IntVar()
        self.incrInput = tkinter.StringVar()
        self.incr_entry = None

        self.valInput = tkinter.StringVar()
        self.sensInput = tkinter.StringVar()

        self.toggleMin.set(0)
        self.toggleMax.set(0)
        self.toggleIncr.set(0)

        self.idf = InputFormDescr(title=self.title)

        self.idf.append({
            'widgetType': tkinter.Label,
            'wcfg': {
                'text': '\n'
            },
            'gridcfg': {
                'columnspan': 3,
                'row': 0,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'togCont',
            'widgetType': Pmw.OptionMenu,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Continuous    ',
                'menubutton_width': 3,
                'items': ('on', 'off'),
                'command': self.toggleCont_cb
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 1,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'togMin',
            'widgetType': tkinter.Checkbutton,
            'wcfg': {
                'text': 'Minimum',
                'variable': self.toggleMin,
                'command': self.toggleMin_cb
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': 2,
                'column': 0
            }
        })

        self.idf.append({
            'name': 'inpMin',
            'widgetType': tkinter.Entry,
            'defaultValue': '0.0',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.minInput,
                'command': self.inputMin_cb,
                'eventType': '<Return>'
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 2,
                'column': 1
            }
        })

        self.idf.append({
            'name': 'togMax',
            'widgetType': tkinter.Checkbutton,
            'wcfg': {
                'text': 'Maximum',
                'variable': self.toggleMax,
                'command': self.toggleMax_cb,
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': 3,
                'column': 0
            }
        })

        self.idf.append({
            'name': 'inpMax',
            'widgetType': tkinter.Entry,
            'defaultValue': '0.0',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.maxInput,
                'command': self.inputMax_cb,
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 3,
                'column': 1
            }
        })

        self.idf.append({
            'name': 'togIncr',
            'widgetType': tkinter.Checkbutton,
            'wcfg': {
                'text': 'Increment',
                'variable': self.toggleIncr,
                'command': self.toggleIncr_cb
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': 4,
                'column': 0
            }
        })

        self.idf.append({
            'name': 'inpIncr',
            'widgetType': tkinter.Entry,
            'defaultValue': '0.1',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.incrInput,
                'command': self.inputIncr_cb,
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 4,
                'column': 1
            }
        })

        self.idf.append({
            'widgetType': tkinter.Label,
            'wcfg': {
                'text': 'Value'
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': 5,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'inpVal',
            'widgetType': tkinter.Entry,
            'defaultValue': '0.0',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.valInput,
                'command': self.inputVal_cb,
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 5,
                'column': 1
            }
        })

        self.idf.append({
            'widgetType': tkinter.Label,
            'wcfg': {
                'text': 'Sensitivity'
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': 6,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'inpSens',
            'widgetType': tkinter.Entry,
            'defaultValue': self.master.oneTurn,
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.sensInput,
                'command': self.inputSens_cb,
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2,
                'row': 6,
                'column': 1
            }
        })

        self.idf.append({
            'name': 'togLabel',
            'widgetType': Pmw.OptionMenu,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Show label',
                'menubutton_width': 5,
                'items': ('never', 'always', 'move'),
                'command': self.toggleLabel_cb
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2
            },
        })

        self.idf.append({
            'name': 'togIntFloat',
            'widgetType': Pmw.OptionMenu,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Type',
                'menubutton_width': 3,
                'items': ('float', 'int'),
                'command': self.toggleIntFloat_cb
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2
            },
        })

        self.idf.append({
            'name': 'selPrec',
            'widgetType': Pmw.OptionMenu,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Precision',
                'menubutton_width': 3,
                'items': ("1", '2', '3', '4', '5', '6', '7', '8', '9', '10'),
                'command': self.selPrec_cb
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 2
            },
        })

        #########Buttons##########

        self.idf.append({
            'name': 'OKButton',
            'widgetType': tkinter.Button,
            'text': '  OK  ',
            'wcfg': {
                'bd': 3
            },
            'gridcfg': {
                'sticky': 'we',
                'row': 10,
                'column': 0
            },
            'command': self.OK_cb
        })

        self.idf.append({
            'name': 'ApplyButton',
            'widgetType': tkinter.Button,
            'text': 'Apply',
            'wcfg': {
                'bd': 3
            },
            'gridcfg': {
                'sticky': 'we',
                'row': 10,
                'column': 1
            },
            'command': self.Apply_cb
        })

        self.idf.append({
            'name': 'CancelButton',
            'widgetType': tkinter.Button,
            'text': 'Dismiss',
            'wcfg': {
                'bd': 3
            },
            'gridcfg': {
                'sticky': 'we',
                'row': 11,
                'column': 0,
                'columnspan': 2
            },
            'command': self.Dismiss_cb
        })
    def SetMode_cb(self, event=None):
        #print 'SetMode'
        #playMode options:
        #   0   play once and stop
        #   1   play continuously in 1 direction
        #   2   play once in 2 directions
        #   3   play continuously in 2 directions
        #play framerate is frame/per second
        if not hasattr(self, 'playModeForm'):
            self.showPlayMode = Tkinter.IntVar()
            self.showFrameParmWidgets = Tkinter.IntVar()
            self.playModeVar = Tkinter.StringVar()
            self.playModeVar.set('once and stop')
            self.playModeList=[ 'once and stop', 
                                'continuously in 1 direction',
                                'once in 2 directions', 
                                'continuously in 2 directions']
            self.frameParmsList=[ 'framerateLabel','framerateTW','startFrameLabel', 
                                  'startFrameTW', 'endFrameLabel', 'endFrameTW', 
                                  'stepSizeLabel', 'stepSizeTW']

            #self.showListVar = Tkinter.IntVar()
            ifd2 = InputFormDescr(title='Set Play Options')    
            ## ifd2.append({'name':'selectCB',
##                 'widgetType': Tkinter.Checkbutton,
##                 'tooltip':'show ids of current ordered conformation list',
##                 'wcfg':{ 'text':'Show Conf List',
##                         #'command': self.showStatesList,
##                         #'variable': self.showListVar,
##                        },
##                 'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})
##                 #'gridcfg':{'sticky':'ew'}})
            ifd2.append({'name':'playModeMb',
                'widgetType': Tkinter.Menubutton,
                'tooltip':'set play mode choice',
                'wcfg':{ 'text':'Play Mode',
                       },
                'gridcfg':{'sticky':'we'}})
                #'gridcfg':{'sticky':'w', 'columnspan':2}})
            ifd2.append({'name':'adjustFrameParmsMb',
                'widgetType': Tkinter.Checkbutton,
                'tooltip':'opens panel to set play rate, start conf number, end conf number \nand step size for playing conf sequence',
                'wcfg':{ 'text':'Play Parameters',
                        'command': self.showFrameParms_cb,
                        'variable': self.showFrameParmWidgets,
                       },
                'gridcfg':{'sticky':'w', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'framerateLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'frame rate:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'framerateTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set max num of confs to be displayed per second',
                    'wcfg':{'labCfg':{'fg':'black', 'side':'left', 'text':''},
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':100,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.framerate,
                        'oneTurn':100,
                        'type':'float',
                        'increment':.1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'red'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'startFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'start frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'startFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set number of first conf to be displayed',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':self.endFrame,
                        'lockBMin':0,
                        'lockBMax':1,
                        'lockBIncrement':1,
                        'value':self.startFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'ew', 'row':-1,  'column':1}})
            ifd2.append( {'name': 'endFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'end frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'endFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set number of last conf to be displayed',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':self.startFrame,
                        'max':self.maxFrame,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.endFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'stepSizeLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'step size:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'stepSizeTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set step before next conf number: default is 1',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':1,
                        'max':1000,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.stepSize,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'blue'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append({'name':'buildB',
                'widgetType': Tkinter.Button,
                'tooltip':'build a new molecule with current conf coords\nand add it to viewer',
                'wcfg':{ 'text':'Build Current',
                        'command': self.Build_cb,
                       },
                'gridcfg':{'sticky':'we'}})
                #'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})

            ifd2.append({'name':'writeB',
                'widgetType': Tkinter.Button,
                'tooltip':'write a new file with current conf coords',
                'wcfg':{ 'text':'Write Current',
                        'command': self.Write_cb,
                       },
                #'gridcfg':{'sticky':'we'}})
                'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})         

            ifd2.append({'name':'cancelB',
                        'widgetType': Tkinter.Button,
                        'wcfg':{
                            'text': 'Close',
                            'command': self.cancelPlayMode_cb,
                        },
                        #'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})
                        'gridcfg':{'sticky':'ew','columnspan':2}}),
            self.playModeForm = InputForm(self.master, self.root,
                        descr = ifd2,
                        modal = 0, blocking = 0)
            self.framerateWidget = ifd2.entryByName['framerateTW']['widget']
            self.startFrameWidget = ifd2.entryByName['startFrameTW']['widget']
            self.endFrameWidget = ifd2.entryByName['endFrameTW']['widget']
            self.stepSizeWidget = ifd2.entryByName['stepSizeTW']['widget']
            self.frameParmCfgs = []
            self.frameParmWidgets = []
            for i in self.frameParmsList:
                ent = ifd2.entryByName[i]
                self.frameParmCfgs.append(ent['gridcfg'])
                self.frameParmWidgets.append(ent['widget'])
            self.playModeMb = ifd2.entryByName['playModeMb']['widget']
            self.playModeMb.bind('<ButtonPress>', self.buildPlayModeMenu, add='+')
            self.showFrameParms_cb()
            #self.showList = ifd2.entryByName['selectCB']['widget']
        else:
            self.playModeVar.set(self.playModeList[self.playMode])
            self.framerateWidget.set(self.framerate)
            self.startFrameWidget.set(self.startFrame)
            self.endFrameWidget.set(self.endFrame)
            self.stepSizeWidget.set(self.stepSize)
            self.playModeForm.deiconify()
        self.playModeForm.autoSize()
    def guiCallback(self):
        #familyNames=[ensureFontCase('times'),ensureFontCase('helvetica'),ensureFontCase('Courier'),'Symbol','Verdana']
        root=self.vf.GUI.ROOT.tk
        familyNames=list(root.splitlist(root.call('font','families')))
        familyNames.sort()
        familyNames.append('from entry')
        sizeNames=[6,8,10,12,14,16,18,20]
        styleNames=['normal','bold','bold italic','italic']
        if self.familyVar.get() not in familyNames: 
                self.familyVar.set(ensureFontCase('helvetica'))
        if int(self.sizeVar.get()) not in sizeNames: 
                self.sizeVar.set('10')
        if self.styleVar.get() not in styleNames: 
                self.styleVar.set(styleNames[0])

        ifd=InputFormDescr(title='Select New Font')
        ifd.append({'widgetType':Pmw.ComboBox,
                    'name':'family',
                    'defaultValue':self.familyVar.get(),
                    'wcfg':{'label_text':'Font Name',
                            'labelpos':'n',
                            'scrolledlist_items': familyNames,
                            'selectioncommand': self.changeSampleFont,
                            },
                    'gridcfg':{'sticky':'w'}})
        ifd.append({'widgetType':Tkinter.Radiobutton,
                'name':'size',
                'listtext':sizeNames,
                'defaultValue':self.sizeVar.get(),
                'command': self.changeSampleOpt,
                'wcfg':{'variable':self.sizeVar},
                'gridcfg':{'sticky':Tkinter.W,'row':0,'column':5}})
        ifd.append({'widgetType':Tkinter.Radiobutton,
                'name':'style',
                'listtext':styleNames,
                'command': self.changeSampleOpt,
                'defaultValue':self.styleVar.get(),
                'wcfg':{'variable':self.styleVar},
                'gridcfg':{'sticky':Tkinter.W,'row':0,'column':6}})
        ifd.append({'widgetType':Tkinter.Entry,
                'wcfg':{ 'textvariable':self.fontVar,
                        'width':60},
                'defaultValue':self.getCurrentFont(),
                'name':'ent',
                'gridcfg':{'sticky':Tkinter.W,'row':11,'column':0,'columnspan':16}})
        ifd.append({'widgetType':Tkinter.Label,
                'name':'sample',
                'wcfg':{ 'text':"""This is a sample of this font 0123456789_!@#$%^&*()\nABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz""",
                        'width':60, 'relief':'ridge',
                         'borderwidth': 3},
                'gridcfg':{'sticky':Tkinter.W,'row':11,'column':0,
                           'columnspan':16}})
        self.ifd = ifd
        val=self.vf.getUserInput(ifd)
        if not val: return
        self.val=val
        font = self.fontVar.get()
        if val['family'][0]=='from entry':
            newfont=val['ent']
            newfont=eval('%s'%val['ent']) # turn tuple repr into objs
            self.fontVar.set(newfont)
        else:
            newfont=(val['family'][0],int(val['size']),val['style'])
        self.doitWrapper(newfont, log=1, redraw=0)
Exemplo n.º 22
0
    def guiCallback(self):
        #familyNames=[ensureFontCase('times'),ensureFontCase('helvetica'),ensureFontCase('Courier'),'Symbol','Verdana']
        root = self.vf.GUI.ROOT.tk
        familyNames = list(root.splitlist(root.call('font', 'families')))
        familyNames.sort()
        familyNames.append('from entry')
        sizeNames = [6, 8, 10, 12, 14, 16, 18, 20]
        styleNames = ['normal', 'bold', 'bold italic', 'italic']
        if self.familyVar.get() not in familyNames:
            self.familyVar.set(ensureFontCase('helvetica'))
        if int(self.sizeVar.get()) not in sizeNames:
            self.sizeVar.set('10')
        if self.styleVar.get() not in styleNames:
            self.styleVar.set(styleNames[0])

        ifd = InputFormDescr(title='Select New Font')
        ifd.append({
            'widgetType': Pmw.ComboBox,
            'name': 'family',
            'defaultValue': self.familyVar.get(),
            'wcfg': {
                'label_text': 'Font Name',
                'labelpos': 'n',
                'scrolledlist_items': familyNames,
                'selectioncommand': self.changeSampleFont,
            },
            'gridcfg': {
                'sticky': 'w'
            }
        })
        ifd.append({
            'widgetType': Tkinter.Radiobutton,
            'name': 'size',
            'listtext': sizeNames,
            'defaultValue': self.sizeVar.get(),
            'command': self.changeSampleOpt,
            'wcfg': {
                'variable': self.sizeVar
            },
            'gridcfg': {
                'sticky': Tkinter.W,
                'row': 0,
                'column': 5
            }
        })
        ifd.append({
            'widgetType': Tkinter.Radiobutton,
            'name': 'style',
            'listtext': styleNames,
            'command': self.changeSampleOpt,
            'defaultValue': self.styleVar.get(),
            'wcfg': {
                'variable': self.styleVar
            },
            'gridcfg': {
                'sticky': Tkinter.W,
                'row': 0,
                'column': 6
            }
        })
        ifd.append({
            'widgetType': Tkinter.Entry,
            'wcfg': {
                'textvariable': self.fontVar,
                'width': 60
            },
            'defaultValue': self.getCurrentFont(),
            'name': 'ent',
            'gridcfg': {
                'sticky': Tkinter.W,
                'row': 11,
                'column': 0,
                'columnspan': 16
            }
        })
        ifd.append({
            'widgetType': Tkinter.Label,
            'name': 'sample',
            'wcfg': {
                'text':
                """This is a sample of this font 0123456789_!@#$%^&*()\nABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz""",
                'width': 60,
                'relief': 'ridge',
                'borderwidth': 3
            },
            'gridcfg': {
                'sticky': Tkinter.W,
                'row': 11,
                'column': 0,
                'columnspan': 16
            }
        })
        self.ifd = ifd
        val = self.vf.getUserInput(ifd)
        if not val: return
        self.val = val
        font = self.fontVar.get()
        if val['family'][0] == 'from entry':
            newfont = val['ent']
            newfont = eval('%s' % val['ent'])  # turn tuple repr into objs
            self.fontVar.set(newfont)
        else:
            newfont = (val['family'][0], int(val['size']), val['style'])
        self.doitWrapper(newfont, log=1, redraw=0)
Exemplo n.º 23
0
    def buildPanel(self):
        # prevent re-creation
        if self.panel is not None:
            self.panel.show()
            return
        
        root = self.panel = Tkinter.Toplevel()
        frame = Tkinter.Frame(root, borderwidth=2,
                                   relief='sunken')#, padx=5, pady=5)
        frame.pack(side='top', expand=1, fill='both')

        ## Font Group ##
        fontGroup = Pmw.Group(frame, tag_text='Font Chooser')
        fontGroup.pack(fill='both', expand=1, padx=6, pady=6)

        f1 = Tkinter.Frame(fontGroup.interior())
        f1.pack(side='top', fill='both', expand=1)
        f2 = Tkinter.Frame(fontGroup.interior())
        f2.pack(side='bottom', fill='both', expand=1)
        
        familyNames=list(root.tk.splitlist(root.tk.call('font','families')))
        familyNames.sort()
        self.fontChooser = Pmw.ComboBox(
            f1,
            label_text = 'Font Name',
            labelpos = 'n',
            scrolledlist_items = familyNames,
            selectioncommand = None
            )
        self.fontChooser.pack(side='left', expand=1, fill='both',
                              padx=6, pady=6)

        sizes = [6,7,8,10,12,14,18,24,48]
        self.sizeChooser = Pmw.ComboBox(
            f1,
            label_text = 'Font Size',
            labelpos = 'n',
            scrolledlist_items = sizes,
            selectioncommand = None,
            entryfield_entry_width=4,
            )
        self.sizeChooser.pack(side='left', expand=1, fill='both',
                              padx=6, pady=6)
        
        
        styles = ['normal', 'bold', 'italic', 'bold italic']
        self.styleVarTk = Tkinter.StringVar()
        for i in range(len(styles)):
            b = Tkinter.Radiobutton(
                f2,
                variable = self.styleVarTk,
                text=styles[i], value=styles[i])
            b.pack(side='left', expand=1, fill='both')

        ## End Font Group ## ##########################################

        ## GUI Group ##

        guiGroup = Pmw.Group(frame, tag_text='GUI Component to Apply Font')
        guiGroup.pack(fill='both', expand=1, padx=6, pady=6)
        group1 = ['All', 'Menus', 'LibTabs', 'Categories']
        group2 = ['LibNodes', 'NetTabs', 'Nodes', 'Root']
        self.groupVarTk = Tkinter.StringVar()
        frame1 = Tkinter.Frame(guiGroup.interior())
        frame2 = Tkinter.Frame(guiGroup.interior())
        frame1.pack(side='top', fill='both', expand=1)
        frame2.pack(side='bottom', fill='both', expand=1)

        for i in range(len(group1)):
            b = Tkinter.Radiobutton(
                frame1,
                variable = self.groupVarTk,
                text=group1[i], value=group1[i])
            b.grid(row=0, column=i, pady=6)
            
        for i in range(len(group2)):
            b = Tkinter.Radiobutton(
                frame2,
                variable = self.groupVarTk,
                text=group2[i], value=group2[i])
            b.grid(row=0, column=i, pady=6)
 
        buttonFrame = Tkinter.Frame(root, borderwidth=2,
                                   relief='sunken', padx=5, pady=5)
        buttonFrame.pack(side='top', expand=1, fill='both')
        self.buttonOk = Tkinter.Button(buttonFrame, text='  Ok  ',
                                       command=self.Ok_cb)
        self.buttonApply = Tkinter.Button(buttonFrame, text='  Apply  ',
                                       command=self.Apply_cb)
        self.buttonCancel = Tkinter.Button(buttonFrame, text='  Cancel  ',
                                       command=self.Cancel_cb)
                
        self.buttonOk.grid(row=0, column=0, padx=6, pady=6)
        self.buttonApply.grid(row=0, column=1, padx=6, pady=6)
        self.buttonCancel.grid(row=0, column=2, padx=6, pady=6)

        # set default values
        try:
            self.fontChooser.selectitem(ensureFontCase('helvetica'))
            self.sizeChooser.selectitem(2) # choose '8'
            self.styleVarTk.set('normal')
            self.groupVarTk.set('Nodes')
        except:
            pass
Exemplo n.º 24
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")
Exemplo n.º 25
0
    def createForm(self):
        row = 0
        self.idf.append({
            'name': 'savNormals',
            'widgetType': Tkinter.Checkbutton,
            'wcfg': {
                'text': 'Save Normals            ',
                'variable': self.saveNormals,
                'command': self.saveNormals_cb
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': row,
                'column': 0
            }
        })
        row += 1
        self.idf.append({
            'widgetType': Tkinter.Frame,
            'wcfg': {
                'relief': 'sunken',
                'borderwidth': 2,
                'height': 2
            },
            'gridcfg': {
                'columnspan': 2,
                'row': row,
                'column': 0
            },
        })

        row += 1
        self.idf.append({
            'name': 'colorPerVertex',
            'widgetType': Tkinter.Checkbutton,
            'wcfg': {
                'text': 'color per vertex',
                'variable': self.colorPerVertex,
                'command': self.colorPerVertex_cb
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': row,
                'column': 0
            }
        })

        row += 1
        self.idf.append({
            'widgetType': Tkinter.Frame,
            'wcfg': {
                'relief': 'sunken',
                'borderwidth': 2,
                'height': 2
            },
            'gridcfg': {
                'columnspan': 2,
                'row': row,
                'column': 0
            },
        })

        row += 1
        self.idf.append({'name':'usePROTO',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Use PROTO for instance\n'+\
                                 'matrices to lower file size',
                                 'variable':self.usePROTO,
                                 'command':self.usePROTO_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':row, 'column':0}
                         })
        row += 1
        self.idf.append({
            'widgetType': Tkinter.Frame,
            'wcfg': {
                'relief': 'sunken',
                'borderwidth': 2,
                'height': 2
            },
            'gridcfg': {
                'columnspan': 2,
                'row': row,
                'column': 0
            },
        })

        row += 1
        self.idf.append({
            'widgetType': Tkinter.Label,
            'wcfg': {
                'text': 'Sphere quality'
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': row,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'inpSphQual',
            'widgetType': Tkinter.Entry,
            'defaultValue': '2',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.sphInput,
                'command': self.sphereQuality_cb,
            },
            'gridcfg': {
                'sticky': 'e',
                'columnspan': 2,
                'row': row,
                'column': 1
            }
        })
        row += 1
        self.idf.append({
            'widgetType': Tkinter.Label,
            'wcfg': {
                'text': 'Cylinder quality'
            },
            'gridcfg': {
                'sticky': 'w',
                'columnspan': 2,
                'row': row,
                'column': 0
            },
        })

        self.idf.append({
            'name': 'inpCylQual',
            'widgetType': Tkinter.Entry,
            'defaultValue': '10',
            'wcfg': {
                'font': (ensureFontCase('Courier'), 10),
                'width': 5,
                'textvariable': self.cylInput,
                'command': self.cylinderQuality_cb,
            },
            'gridcfg': {
                'sticky': 'e',
                'columnspan': 2,
                'row': row,
                'column': 1
            }
        })

        row += 1
        self.idf.append({
            'widgetType': Tkinter.Button,
            'text': 'OK',
            'wcfg': {},
            'gridcfg': {
                'sticky': 'wens',
                'columnspan': 1,
                'row': row,
                'column': 0
            },
            'command': self.OK_cb
        })

        self.idf.append({
            'widgetType': Tkinter.Button,
            'text': 'Cancel',
            'wcfg': {},
            'gridcfg': {
                'sticky': 'wens',
                'columnspan': 1,
                'row': row,
                'column': 1
            },
            'command': self.Cancel_cb
        })
Exemplo n.º 26
0
    def SetMode_cb(self, event=None):
        # print 'SetMode'
        # playMode options:
        #   0   play once and stop
        #   1   play continuously in 1 direction
        #   2   play once in 2 directions
        #   3   play continuously in 2 directions
        # play framerate is frame/per second
        if not hasattr(self, "playModeForm"):
            self.playModeList = [
                "once and stop",
                "continuously in 1 direction",
                "once in 2 directions",
                "continuously in 2 directions",
            ]
            ifd2 = InputFormDescr(title="Set Play Mode")

            ifd2.append(
                {
                    "name": "playModeLabel",
                    "widgetType": Tkinter.Label,
                    "wcfg": {"text": "play mode options:", "font": (ensureFontCase("helvetica"), 12, "bold")},
                    "gridcfg": {"sticky": "w"},
                }
            )

            ifd2.append(
                {
                    "name": "playMode",
                    "widgetType": Tkinter.Radiobutton,
                    "defaultValue": self.playModeList[self.playMode],
                    "listtext": self.playModeList,
                    "gridcfg": {"sticky": "w"},
                }
            )

            ifd2.append(
                {
                    "name": "framerateTW",
                    "widgetType": ThumbWheel,
                    "tooltip": """Framerate to enforce during playback""",
                    "gridcfg": {"sticky": "we"},
                    "wcfg": {
                        "value": self.framerate,
                        "oneTurn": 100.0,
                        "type": "float",
                        "continuous": True,
                        "wheelPad": 2,
                        "width": 145,
                        "height": 18,
                        "labCfg": {"text": "framerate:  "},
                    },
                }
            )

            ifd2.append(
                {
                    "name": "startFrameTW",
                    "widgetType": ThumbWheel,
                    "tooltip": """First frame used in playback""",
                    "gridcfg": {"sticky": "we"},
                    "wcfg": {
                        "value": self.startFrame,
                        "oneTurn": 100,
                        "type": "int",
                        "continuous": True,
                        "wheelPad": 2,
                        "width": 145,
                        "height": 18,
                        "labCfg": {"text": "start frame: "},
                    },
                }
            )

            ifd2.append(
                {
                    "name": "endFrameTW",
                    "widgetType": ThumbWheel,
                    "tooltip": """Last frame used in playback""",
                    "gridcfg": {"sticky": "we"},
                    "wcfg": {
                        "value": self.endFrame,
                        "oneTurn": 100,
                        "type": "int",
                        "continuous": True,
                        "wheelPad": 2,
                        "width": 145,
                        "height": 18,
                        "labCfg": {"text": " end frame: "},
                    },
                }
            )

            ifd2.append(
                {
                    "name": "stepSizeTW",
                    "widgetType": ThumbWheel,
                    "tooltip": """???""",
                    "gridcfg": {"sticky": "we"},
                    "wcfg": {
                        "value": self.stepSize,
                        "oneTurn": 100,
                        "type": "int",
                        "continuous": True,
                        "wheelPad": 2,
                        "width": 145,
                        "height": 18,
                        "labCfg": {"text": " step size:  "},
                    },
                }
            )

            ifd2.append(
                {
                    "name": "acceptB",
                    "widgetType": Tkinter.Button,
                    "wcfg": {"text": "ok", "command": self.setPlayMode_cb},
                    "gridcfg": {"sticky": "nesw"},
                }
            )

            ifd2.append(
                {
                    "name": "cancelB",
                    "widgetType": Tkinter.Button,
                    "wcfg": {"text": "cancel", "command": self.cancelPlayMode_cb},
                    "gridcfg": {"sticky": "nesw", "row": -1, "column": 1},
                }
            )
            if self.master is None:
                master = self.root
            else:
                master = Tkinter.Toplevel()
            self.playModeForm = InputForm(master, None, descr=ifd2, modal=0, blocking=0)
            self.playModeVar = self.playModeForm.descr.entryByName["playMode"]["variable"]
            self.framerateWidget = self.playModeForm.descr.entryByName["framerateTW"]["widget"]
            self.startFrameWidget = self.playModeForm.descr.entryByName["startFrameTW"]["widget"]
            self.endFrameWidget = self.playModeForm.descr.entryByName["endFrameTW"]["widget"]
            self.stepSizeWidget = self.playModeForm.descr.entryByName["stepSizeTW"]["widget"]
        else:
            self.playModeForm.deiconify()
Exemplo n.º 27
0
    def SetMode_cb(self, event=None):
        #print 'SetMode'
        #playMode options:
        #   0   play once and stop
        #   1   play continuously in 1 direction
        #   2   play once in 2 directions
        #   3   play continuously in 2 directions
        #play framerate is frame/per second
        if not hasattr(self, 'playModeForm'):
            self.playModeList=[ 'once and stop', 
                                'continuously in 1 direction',
                                'once in 2 directions', 
                                'continuously in 2 directions']
            ifd2 = InputFormDescr(title='Set Play Mode')    
            ifd2.append( {'name': 'playModeLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'play mode options:', 
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name':'playMode',
                        'widgetType': Tkinter.Radiobutton,
                        'defaultValue': self.playModeList[self.playMode],
                        'listtext':self.playModeList,
                        'gridcfg':{'sticky':'w'}})
            ifd2.append( {'name': 'framerateLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'framerate:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'framerateTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'wcfg':{
                        'labcfg':{
                            'fg':'black',
                            'side':'left',
                            'text':'       '
                            },
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':100,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.framerate,
                        'oneTurn':100,
                        'type':'float',
                        'increment':.1,
                        'canvascfg':{'bg':'red'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':1, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw'}})

            ifd2.append( {'name': 'startFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'start frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'startFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'wcfg':{
                        'labcfg':{
                            'fg':'black',
                            'side':'left',
                            'text':'       '
                            },
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':self.endFrame,
                        'lockBMin':0,
                        'lockBMax':1,
                        'lockBIncrement':1,
                        'value':self.startFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':1, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw'}})
            ifd2.append( {'name': 'endFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'end frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'endFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'wcfg':{
                        'labcfg':{
                            'fg':'black',
                            'side':'left',
                            'text':'       '
                            },
                        'showLabel':1, 'width':100,
                        'min':self.startFrame,
                        'max':self.maxFrame,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.endFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':1, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw'}})
            ifd2.append( {'name': 'stepSizeLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'step size:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'stepSizeTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'wcfg':{
                        'labcfg':{
                            'fg':'black',
                            'side':'left',
                            'text':'       '
                            },
                        'showLabel':1, 'width':100,
                        'min':1,
                        'max':1000,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.stepSize,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'canvascfg':{'bg':'blue'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':1, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw'}})
            ifd2.append({'name':'acceptB',
                        'widgetType': Tkinter.Button,
                        'wcfg':{
                            'text': 'ok',
                            'command': self.setPlayMode_cb,
                        },
                        'gridcfg':{'sticky':'nesw'}})
            ifd2.append({'name':'cancelB',
                        'widgetType': Tkinter.Button,
                        'wcfg':{
                            'text': 'cancel',
                            'command': self.cancelPlayMode_cb,
                        },
                        'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            self.playModeForm = InputForm(self.master, self.root,
                        descr = ifd2,
                        modal = 0, blocking = 0)
            self.playModeVar = self.playModeForm.descr.entryByName['playMode']['variable']
            self.framerateWidget = self.playModeForm.descr.entryByName['framerateTW']['widget']
            self.startFrameWidget = self.playModeForm.descr.entryByName['startFrameTW']['widget']
            self.endFrameWidget = self.playModeForm.descr.entryByName['endFrameTW']['widget']
            self.stepSizeWidget = self.playModeForm.descr.entryByName['stepSizeTW']['widget']
        else:
            self.playModeForm.deiconify()
Exemplo n.º 28
0
    def SetMode_cb(self, event=None):
        #print 'SetMode'
        #playMode options:
        #   0   play once and stop
        #   1   play continuously in 1 direction
        #   2   play once in 2 directions
        #   3   play continuously in 2 directions
        #play framerate is frame/per second
        if not hasattr(self, 'playModeForm'):
            self.playModeList = [
                'once and stop', 'continuously in 1 direction',
                'once in 2 directions', 'continuously in 2 directions'
            ]
            ifd2 = InputFormDescr(title='Set Play Mode')

            ifd2.append({
                'name': 'playModeLabel',
                'widgetType': Tkinter.Label,
                'wcfg': {
                    'text': 'play mode options:',
                    'font': (ensureFontCase('helvetica'), 12, 'bold')
                },
                'gridcfg': {
                    'sticky': 'w'
                }
            })

            ifd2.append({
                'name': 'playMode',
                'widgetType': Tkinter.Radiobutton,
                'defaultValue': self.playModeList[self.playMode],
                'listtext': self.playModeList,
                'gridcfg': {
                    'sticky': 'w'
                }
            })

            ifd2.append({
                'name': 'framerateTW',
                'widgetType': ThumbWheel,
                'tooltip': """Framerate to enforce during playback""",
                'gridcfg': {
                    'sticky': 'we'
                },
                'wcfg': {
                    'value': self.framerate,
                    'oneTurn': 100.,
                    'type': 'float',
                    'continuous': True,
                    'wheelPad': 2,
                    'width': 145,
                    'height': 18,
                    'labCfg': {
                        'text': 'framerate:  '
                    },
                },
            })

            ifd2.append({
                'name': 'startFrameTW',
                'widgetType': ThumbWheel,
                'tooltip': """First frame used in playback""",
                'gridcfg': {
                    'sticky': 'we'
                },
                'wcfg': {
                    'value': self.startFrame,
                    'oneTurn': 100,
                    'type': 'int',
                    'continuous': True,
                    'wheelPad': 2,
                    'width': 145,
                    'height': 18,
                    'labCfg': {
                        'text': 'start frame: '
                    },
                },
            })

            ifd2.append({
                'name': 'endFrameTW',
                'widgetType': ThumbWheel,
                'tooltip': """Last frame used in playback""",
                'gridcfg': {
                    'sticky': 'we'
                },
                'wcfg': {
                    'value': self.endFrame,
                    'oneTurn': 100,
                    'type': 'int',
                    'continuous': True,
                    'wheelPad': 2,
                    'width': 145,
                    'height': 18,
                    'labCfg': {
                        'text': ' end frame: '
                    },
                },
            })

            ifd2.append({
                'name': 'stepSizeTW',
                'widgetType': ThumbWheel,
                'tooltip': """???""",
                'gridcfg': {
                    'sticky': 'we'
                },
                'wcfg': {
                    'value': self.stepSize,
                    'oneTurn': 100,
                    'type': 'int',
                    'continuous': True,
                    'wheelPad': 2,
                    'width': 145,
                    'height': 18,
                    'labCfg': {
                        'text': ' step size:  '
                    },
                },
            })

            ifd2.append({
                'name': 'acceptB',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'ok',
                    'command': self.setPlayMode_cb,
                },
                'gridcfg': {
                    'sticky': 'nesw'
                }
            })

            ifd2.append({
                'name': 'cancelB',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'cancel',
                    'command': self.cancelPlayMode_cb,
                },
                'gridcfg': {
                    'sticky': 'nesw',
                    'row': -1,
                    'column': 1
                }
            })
            if self.master is None:
                master = self.root
            else:
                master = Tkinter.Toplevel()
            self.playModeForm = InputForm(master,
                                          None,
                                          descr=ifd2,
                                          modal=0,
                                          blocking=0)
            self.playModeVar = self.playModeForm.descr.entryByName['playMode'][
                'variable']
            self.framerateWidget = self.playModeForm.descr.entryByName[
                'framerateTW']['widget']
            self.startFrameWidget = self.playModeForm.descr.entryByName[
                'startFrameTW']['widget']
            self.endFrameWidget = self.playModeForm.descr.entryByName[
                'endFrameTW']['widget']
            self.stepSizeWidget = self.playModeForm.descr.entryByName[
                'stepSizeTW']['widget']
        else:
            self.playModeForm.deiconify()
Exemplo n.º 29
0
    def SetMode_cb(self, event=None):
        #print 'SetMode'
        #playMode options:
        #   0   play once and stop
        #   1   play continuously in 1 direction
        #   2   play once in 2 directions
        #   3   play continuously in 2 directions
        #play framerate is frame/per second
        if not hasattr(self, 'playModeForm'):
            self.showPlayMode = Tkinter.IntVar()
            self.showFrameParmWidgets = Tkinter.IntVar()
            self.playModeVar = Tkinter.StringVar()
            self.playModeVar.set('once and stop')
            self.playModeList=[ 'once and stop', 
                                'continuously in 1 direction',
                                'once in 2 directions', 
                                'continuously in 2 directions']
            self.frameParmsList=[ 'framerateLabel','framerateTW','startFrameLabel', 
                                  'startFrameTW', 'endFrameLabel', 'endFrameTW', 
                                  'stepSizeLabel', 'stepSizeTW']

            #self.showListVar = Tkinter.IntVar()
            ifd2 = InputFormDescr(title='Set Play Options')    
            ## ifd2.append({'name':'selectCB',
##                 'widgetType': Tkinter.Checkbutton,
##                 'tooltip':'show ids of current ordered conformation list',
##                 'wcfg':{ 'text':'Show Conf List',
##                         #'command': self.showStatesList,
##                         #'variable': self.showListVar,
##                        },
##                 'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})
##                 #'gridcfg':{'sticky':'ew'}})
            ifd2.append({'name':'playModeMb',
                'widgetType': Tkinter.Menubutton,
                'tooltip':'set play mode choice',
                'wcfg':{ 'text':'Play Mode',
                       },
                'gridcfg':{'sticky':'we'}})
                #'gridcfg':{'sticky':'w', 'columnspan':2}})
            ifd2.append({'name':'adjustFrameParmsMb',
                'widgetType': Tkinter.Checkbutton,
                'tooltip':'opens panel to set play rate, start conf number, end conf number \nand step size for playing conf sequence',
                'wcfg':{ 'text':'Play Parameters',
                        'command': self.showFrameParms_cb,
                        'variable': self.showFrameParmWidgets,
                       },
                'gridcfg':{'sticky':'w', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'framerateLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'frame rate:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'framerateTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set max num of confs to be displayed per second',
                    'wcfg':{'labCfg':{'fg':'black', 'side':'left', 'text':''},
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':100,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.framerate,
                        'oneTurn':100,
                        'type':'float',
                        'increment':.1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'red'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'startFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'start frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'startFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set number of first conf to be displayed',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':0,
                        'max':self.endFrame,
                        'lockBMin':0,
                        'lockBMax':1,
                        'lockBIncrement':1,
                        'value':self.startFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'ew', 'row':-1,  'column':1}})
            ifd2.append( {'name': 'endFrameLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'end frame:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'endFrameTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set number of last conf to be displayed',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':self.startFrame,
                        'max':self.maxFrame,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.endFrame,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'green'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append( {'name': 'stepSizeLabel',
                    'widgetType':Tkinter.Label,
                    'wcfg':{'text':'step size:',
                        'font':(ensureFontCase('helvetica'),12,'bold')},
                    'gridcfg':{'sticky':'w'}})
            ifd2.append({'name': 'stepSizeTW',
                    'wtype':ThumbWheel,
                    'widgetType':ThumbWheel,
                    'tooltip':'set step before next conf number: default is 1',
                    'wcfg':{
                        'labCfg':{
                            'fg':'black',
                            'side':'left',
                            'text':''
                            },
                        'showLabel':1, 'width':100,
                        'min':1,
                        'max':1000,
                        'lockBMin':1,
                        'lockBMax':0,
                        'lockBIncrement':1,
                        'value':self.stepSize,
                        'oneTurn':10,
                        'type':'int',
                        'increment':1,
                        'callback':self.setMode_cb,
                        'canvascfg':{'bg':'blue'},
                        'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                        'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                        'continuous':0, 'wheelPad':1, 'height':20},
                    'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})
            ifd2.append({'name':'buildB',
                'widgetType': Tkinter.Button,
                'tooltip':'build a new molecule with current conf coords\nand add it to viewer',
                'wcfg':{ 'text':'Build Current',
                        'command': self.Build_cb,
                       },
                'gridcfg':{'sticky':'we'}})
                #'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})

            ifd2.append({'name':'writeB',
                'widgetType': Tkinter.Button,
                'tooltip':'write a new file with current conf coords',
                'wcfg':{ 'text':'Write Current',
                        'command': self.Write_cb,
                       },
                #'gridcfg':{'sticky':'we'}})
                'gridcfg':{'sticky':'nesw', 'row':-1, 'column':1}})         

            ifd2.append({'name':'cancelB',
                        'widgetType': Tkinter.Button,
                        'wcfg':{
                            'text': 'Close',
                            'command': self.cancelPlayMode_cb,
                        },
                        #'gridcfg':{'sticky':'ew', 'row':-1, 'column':1}})
                        'gridcfg':{'sticky':'ew','columnspan':2}}),
            self.playModeForm = InputForm(self.master, self.root,
                        descr = ifd2,
                        modal = 0, blocking = 0)
            self.framerateWidget = ifd2.entryByName['framerateTW']['widget']
            self.startFrameWidget = ifd2.entryByName['startFrameTW']['widget']
            self.endFrameWidget = ifd2.entryByName['endFrameTW']['widget']
            self.stepSizeWidget = ifd2.entryByName['stepSizeTW']['widget']
            self.frameParmCfgs = []
            self.frameParmWidgets = []
            for i in self.frameParmsList:
                ent = ifd2.entryByName[i]
                self.frameParmCfgs.append(ent['gridcfg'])
                self.frameParmWidgets.append(ent['widget'])
            self.playModeMb = ifd2.entryByName['playModeMb']['widget']
            self.playModeMb.bind('<ButtonPress>', self.buildPlayModeMenu, add='+')
            self.showFrameParms_cb()
            #self.showList = ifd2.entryByName['selectCB']['widget']
        else:
            self.playModeVar.set(self.playModeList[self.playMode])
            self.framerateWidget.set(self.framerate)
            self.startFrameWidget.set(self.startFrame)
            self.endFrameWidget.set(self.endFrame)
            self.stepSizeWidget.set(self.stepSize)
            self.playModeForm.deiconify()
        self.playModeForm.autoSize()
    def __init__(self, about, noSplash=False, app=None):
        """Constructor for SplashScreen"""
        self.app = app
        name = validFilename(about.title)
        self.version = about.version
        rcWithVersion = getResourceFolderWithVersion()
        if rcWithVersion is not None:
            registration = rcWithVersion + os.sep + '.registration'
            self.timing_rc = rcWithVersion + os.sep + '.timing_' + name
            self.usage_rc = rcWithVersion + os.sep + '.usage_' + name
            try:
                open(self.usage_rc, 'a').write(str(time.time()) + "\n")
            except:
                pass
        else:
            registration = None
            self.timing_rc = None
            self.usage_rc = None

        self.noSplash = noSplash
        self.registered = False  # change this to False to check registration
        self.register = None

        # check if the user has registered
        if registration is None or os.path.exists(registration):
            self.registered = True
            #self.check_for_updates(registration)
        else:
            # count number of use and ask to register
            lines = open(self.usage_rc).readlines()
            if len(lines) < 10:
                self.registered = True

        self.waitTk = tkinter.IntVar()
        self.percent = 0
        if self.timing_rc is None:
            self.timing_data = []
        else:

            try:
                timing_file = open(self.timing_rc, 'r+')
            except:
                timing_file = open(self.timing_rc, 'w+')
            self.timing_data = timing_file.readlines()
            timing_file.close()
            ###self.percent = 0
            if self.timing_data:
                for data in self.timing_data:
                    self.percent += int(data)
                self.percent = int(self.percent / len(self.timing_data))
                self.percent = 100 / self.percent
        if self.percent == 0: self.percent = 1
        self.counter = 0

        if self.registered and self.noSplash:
            return

        self.splash_win = tkinter.Toplevel()
        self.splash_win.overrideredirect(1)
        self.splash_win.withdraw()
        _splashDisplayed[self.app] = self

        frame = tkinter.Frame(self.splash_win, relief='raised', bd=3)
        frame.pack()
        try:
            about.gui(master=frame)
        except Exception as inst:
            print(inst)
        self.progressBar = ProgressBar(master=frame,
                                       labelside=None,
                                       width=420,
                                       height=20,
                                       mode='percent')
        self.progressBar.setLabelText('Loading Modules...')
        self.progressBar.set(0)

        if not self.registered:
            text = """ Please Register! It helps us secure funding for
supporting development and you won't have to
click these buttons again in the future. Thanks."""
            tkinter.Label(frame, text = text, font =(ensureFontCase('helvetica'), 14, 'bold') ).\
                                                                          pack()
            tkinter.Button(frame,
                           text='Register Now',
                           bg='Green',
                           command=self.Register_Now).pack(side='left')
            self.Later_Button = tkinter.Button(frame,
                                               text='Remind Me Later',
                                               state='disabled',
                                               command=self.Later)
            self.Later_Button.pack(side='right')

        self._updateprogressBar()
        self.splash_win.update_idletasks()

        width = self.splash_win.winfo_reqwidth()
        height = self.splash_win.winfo_reqheight()
        screenwidth = self.splash_win.winfo_screenwidth()
        if screenwidth > 2000:
            screenwidth = 1000
        x = (screenwidth - width) / 2 - self.splash_win.winfo_vrootx()
        y = (self.splash_win.winfo_screenheight() - height) / 4 - \
                                                    self.splash_win.winfo_vrooty()
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        geometry = '%dx%d+%d+%d' % (width, height, x, y)
        self.splash_win.geometry(geometry)
        self.splash_win.update_idletasks()
        self.splash_win.deiconify()
        self.splash_win.update()
        self.splash_win_children = self.splash_win.children
        self.splash_win.children = [
        ]  # this is needed to avoid problems self.changeFont
Exemplo n.º 31
0
    except:
        return None
    
def findFilePathTry(fileName, packageName):
    """ Find the path to the file from the package packageName"""
    fullName = os.path.join(os.path.join(path,packageName), fileName)
    if os.path.exists(fullName):
        return fullName
    else:
        return None


tk_root = Tkinter.Tk()
tk_root.title("License Agreements for add-on packages")
label_1 = Tkinter.Label(text="License Agreements for add-on packages.",
                           bg ='pink',font=(ensureFontCase('Helvetica'), 16) )
label_1.pack(fill='both',expand=0)

sf = Pmw.ScrolledFrame(tk_root,hscrollmode='none',usehullsize=1,
                       hull_width = 500,hull_height = 470,
                       vertflex='expand',horizflex='elastic',)
sf.pack(fill='both',expand=1)
sframe = sf.interior()
balloon = Pmw.Balloon(tk_root)

acad_var = Tkinter.BooleanVar()

def toggle_acad_comm():
    global acad_var
    if acad_var.get():
        mslib_radio.invoke(0)
Exemplo n.º 32
0
    def createForm(self):
        row = 0
        self.idf.append({'name':'savNormals',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Save Normals            ',
                                 'variable':self.saveNormals,
                                 'command':self.saveNormals_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':row, 'column':0}
                         })
        row+= 1
        self.idf.append({'widgetType':Tkinter.Frame,
                 'wcfg':{'relief':'sunken','borderwidth':2,'height':2},
                 'gridcfg':{'columnspan':2, 'row':row, 'column':0},
                 })

        row += 1
        self.idf.append({'name':'colorPerVertex',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'color per vertex',
                                 'variable':self.colorPerVertex,
                                 'command':self.colorPerVertex_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':row, 'column':0}
                         })
        
        row+= 1
        self.idf.append({'widgetType':Tkinter.Frame,
                 'wcfg':{'relief':'sunken','borderwidth':2,'height':2},
                 'gridcfg':{'columnspan':2, 'row':row, 'column':0},
                 })

        row+= 1
        self.idf.append({'name':'usePROTO',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Use PROTO for instance\n'+\
                                 'matrices to lower file size',
                                 'variable':self.usePROTO,
                                 'command':self.usePROTO_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':row, 'column':0}
                         })
        row+= 1
        self.idf.append({'widgetType':Tkinter.Frame,
                 'wcfg':{'relief':'sunken','borderwidth':2,'height':2},
                 'gridcfg':{'columnspan':2, 'row':row, 'column':0},
                 })

        row+= 1
        self.idf.append({'widgetType':Tkinter.Label,
                 'wcfg':{'text':'Sphere quality'},
                 'gridcfg':{'sticky':'w','columnspan':2, 'row':row,
                            'column':0},
                 })
        
        self.idf.append({'name':'inpSphQual',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'2',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.sphInput,
                                 'command':self.sphereQuality_cb,
                                 },
                         'gridcfg':{'sticky':'e',
                                    'columnspan':2, 'row':row, 'column':1 }
                         })
        row+= 1
        self.idf.append({'widgetType':Tkinter.Label,
                 'wcfg':{'text':'Cylinder quality'},
                 'gridcfg':{'sticky':'w','columnspan':2, 'row':row,
                            'column':0},
                 })

        self.idf.append({'name':'inpCylQual',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'10',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.cylInput,
                                 'command':self.cylinderQuality_cb,
                                 },
                         'gridcfg':{'sticky':'e',
                                    'columnspan':2, 'row':row, 'column':1 }
                         })

        row+= 1
	self.idf.append({'widgetType':Tkinter.Button,
                         'text':'OK',
                         'wcfg':{},
                         'gridcfg':{'sticky':'wens',
                                    'columnspan':1, 'row':row, 'column':0},
                         'command': self.OK_cb})


	self.idf.append({'widgetType':Tkinter.Button,
                         'text':'Cancel',
                         'wcfg':{},
                         'gridcfg':{'sticky':'wens',
                                    'columnspan':1, 'row':row, 'column':1},
                         'command': self.Cancel_cb})
Exemplo n.º 33
0
    def __init__(self, master=None, title=None):
        self.master = master
        self.root = None

        self.title = title
        if self.title is None:
            self.title = 'Options Panel'

        if self.master is None: # this is to test this widget without a widget
            self.master = Tkinter.Tk()
            self.master.continuous = 1

            def configure(**kw):
                pass

            self.master.configure = configure
            self.master.min = None        # min value allowed for val
            self.master.max = None        # max value allowed for val
            self.master.increment = None  # discrete value allowed for val
            self.master.incrementOld = 0.0
            self.master.oneTurn = 1.0
            self.master.value = 0.0
            self.master.type = float
            self.master.precision = 3
            self.master.showLabel = 0
            self.master.labelFormat = "%d"
            self.master.minOld = 0
            self.master.maxOld = 0
            self.master.lockContinuous = 0
            self.master.lockMin = 0
            self.master.lockMax = 0
            self.master.lockBMin = 0
            self.master.lockBMax = 0
            self.master.lockIncrement = 1
            self.master.lockBIncrement = 0
            self.master.lockValue = 0
            self.master.lockOneTurn = 0
            self.master.lockShowLabel = 0
            self.master.lockType = 0
            self.master.lockPrecision = 0
            self.master.opPanel = self
            #self.master.withdraw()
            
        self.flag = 0     # this flag toggles display/undisplay
                          # used in the various GUIs
                          
        self.type = float # can be float or int
        
        self.toggleMin  =  Tkinter.IntVar()
        self.minInput   =  Tkinter.StringVar()
        self.min_entry  =  None

        self.toggleMax  =  Tkinter.IntVar()
        self.maxInput   =  Tkinter.StringVar()
        self.max_entry  =  None

        self.toggleIncr =  Tkinter.IntVar()
        self.incrInput  =  Tkinter.StringVar()
        self.incr_entry =  None

        self.valInput   =  Tkinter.StringVar()
        self.sensInput  =  Tkinter.StringVar()

        self.toggleMin.set(0)
        self.toggleMax.set(0)
        self.toggleIncr.set(0)
       
        self.idf = InputFormDescr(title=self.title)
        
        self.idf.append({'widgetType':Tkinter.Label,
                         'wcfg':{'text': '\n'},
                         'gridcfg':{'columnspan':3, 'row':0, 'column':0},
                         })


        self.idf.append({'name':'togCont',
                         'widgetType':Pmw.OptionMenu,
                         'wcfg':{'labelpos':'w',
                                 'label_text':'Continuous    ',
                                 'menubutton_width':3,
                                 'items':('on', 'off'),
                                 'command': self.toggleCont_cb},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':1, 'column':0},
                         })


        self.idf.append({'name':'togMin',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Minimum',
                                 'variable':self.toggleMin,
                                 'command':self.toggleMin_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':2, 'column':0}
                         })


        self.idf.append({'name':'inpMin',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'0.0',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5, 'textvariable':self.minInput,
                                 'command':self.inputMin_cb,
                                 'eventType':'<Return>'},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':2, 'column':1 }
                         })


        self.idf.append({'name':'togMax',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Maximum',
                                 'variable':self.toggleMax,
                                 'command':self.toggleMax_cb,
                                 },
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':3, 'column':0}
                         })


        self.idf.append({'name':'inpMax',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'0.0',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.maxInput,
                                 'command':self.inputMax_cb,},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':3, 'column':1 }
                         })

        
        self.idf.append({'name':'togIncr',
                         'widgetType':Tkinter.Checkbutton,
                         'wcfg':{'text':'Increment',
                                 'variable':self.toggleIncr,
                                 'command':self.toggleIncr_cb},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':4, 'column':0}
                         })


        self.idf.append({'name':'inpIncr',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'0.1',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.incrInput,
                                 'command':self.inputIncr_cb,
                                 },
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':4, 'column':1 }
                         })


        self.idf.append({'widgetType':Tkinter.Label,
                         'wcfg':{'text': 'Value'},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':5, 'column':0},
                         })


        self.idf.append({'name':'inpVal',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':'0.0',
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.valInput,
                                 'command':self.inputVal_cb,
                                 },
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':5, 'column':1 }
                         })


        self.idf.append({'widgetType':Tkinter.Label,
                         'wcfg':{'text': 'Sensitivity'},
                         'gridcfg':{'sticky':'w',
                                    'columnspan':2, 'row':6, 'column':0},
                         })


        self.idf.append({'name':'inpSens',
                         'widgetType':Tkinter.Entry,
                         'defaultValue':self.master.oneTurn,
                         'wcfg':{'font':(ensureFontCase('Courier'),10),
                                 'width':5,'textvariable':self.sensInput,
                                 'command':self.inputSens_cb,
                                 },
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2, 'row':6, 'column':1 }
                         })


        self.idf.append({'name':'togLabel',
                         'widgetType':Pmw.OptionMenu,
                         'wcfg':{'labelpos':'w',
                                 'label_text':'Show label',
                                 'menubutton_width':5,
                                 'items':('never', 'always', 'move'),
                                 'command': self.toggleLabel_cb},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2},
                         })


        self.idf.append({'name':'togIntFloat',
                         'widgetType':Pmw.OptionMenu,
                         'wcfg':{'labelpos':'w',
                                 'label_text':'Type',
                                 'menubutton_width':3,
                                 'items':('float', 'int'),
                                 'command': self.toggleIntFloat_cb},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2},
                         })


        self.idf.append({'name':'selPrec',
                         'widgetType':Pmw.OptionMenu,
                         'wcfg':{'labelpos':'w',
                                 'label_text':'Precision',
                                 'menubutton_width':3,
                                 'items':("1", '2', '3', '4', '5', '6', '7', '8',
                                          '9', '10' ),
                                 'command': self.selPrec_cb},
                         'gridcfg':{'sticky':'we',
                                    'columnspan':2},
                         })


#########Buttons##########

        self.idf.append({'name':'OKButton',
                         'widgetType':Tkinter.Button,
                         'text':'  OK  ',
                         'wcfg':{'bd':3},
                         'gridcfg':{'sticky':'we', 'row':10,'column':0},
                         'command': self.OK_cb})
        
	self.idf.append({'name':'ApplyButton',
                         'widgetType':Tkinter.Button,
                         'text':'Apply',
                         'wcfg':{'bd':3},
                         'gridcfg':{'sticky':'we', 'row':10,'column':1},
                         'command': self.Apply_cb})

	self.idf.append({'name':'CancelButton',
                         'widgetType':Tkinter.Button,
                         'text':'Dismiss',
                         'wcfg':{'bd':3},
                         'gridcfg':{'sticky':'we', 'row':11, 'column':0,
                                    'columnspan':2},
                         'command': self.Dismiss_cb})
    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)
Exemplo n.º 35
0
    def createSpinGui(self):
        #print "createSpinGui"
        
        self.spinGui = Tkinter.Toplevel()
        self.spinGui.title('Spin Settings')
        self.spinGui.protocol('WM_DELETE_WINDOW', self.spinGui.withdraw )

        mainFrame = Tkinter.Frame(self.spinGui, relief='ridge', borderwidth=3)

        lLabelSpinBold = Tkinter.Label(mainFrame,
                      text="Spinning only occurs in \"Object\" transform mode",
                      font=(ensureFontCase('helvetica'),10,'bold'))
        lLabelSpinBold.pack(side='top')

        lLabelSpin = Tkinter.Label(mainFrame,
                      font=(ensureFontCase('helvetica'),'9'),
                      justify='left',
                      text="""start: release the middle button while the mouse is still moving
stop: left click
"""
                     )
        lLabelSpin.pack(side='top')

        anglesFrame = Tkinter.Frame(mainFrame, relief='ridge', borderwidth=3)
        # off/spin/rock radio buttons
        radioFrame = Tkinter.Frame(anglesFrame)#, relief='ridge', borderwidth=3)

        radioOff = Tkinter.Radiobutton(
            radioFrame,
            text='Off',
            value=0,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.resetSpinValues,
            )
        radioOff.grid(row=0, column=0, sticky='we')
        radioSpin = Tkinter.Radiobutton(
            radioFrame,
            text='Spin',
            value=1,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioSpin.grid(row=0, column=1, sticky='we')
        radioBounce = Tkinter.Radiobutton(
            radioFrame,
            text='Bounce',
            value=2,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioBounce.grid(row=0, column=2, sticky='we')
        radioOscillate = Tkinter.Radiobutton(
            radioFrame,
            text='Oscillate',
            value=3,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioOscillate.grid(row=0, column=3, sticky='we')
        radioFrame.pack(side='top')

        self.spinGui.anglePerFrameThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Angular speed (degrees per frame)', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=.01, 
                                    max=10.,
                                    type=float, 
                                    value=self.spinAnglePerFrame,
                                    callback=self.setWithSpinGui,
                                    continuous=True,
                                    oneTurn=5,
                                    wheelPad=0,
                                    )
        self.spinGui.anglePerFrameThumbwheel.pack(side='top', anchor='e')
        self.spinGui.rockAngleThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Rock angle (degrees)', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=1, 
                                    max=360,
                                    type=int, 
                                    value=self.rockAngle,
                                    callback=self.setWithSpinGui,
                                    continuous=True,
                                    oneTurn=60,
                                    wheelPad=0,
                                    )
        self.spinGui.rockAngleThumbwheel.pack(side='top', anchor='e')
        def shiftRockCenter(val):
            lSpinRotMat = self.makeSpinRotationMat(self.spinAxis, -val)
            c = self.camera()
            c.viewer.rootObject.ConcatRotation(lSpinRotMat)
            c.Redraw()
            vi.afterRedraw()
            shiftRockCenterThumbwheel.set(0, update=0)
        shiftRockCenterThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Shift rock center', 'side':'left'},
                                    showLabel=0, 
                                    width=90,
                                    height=14,
                                    min=-100, 
                                    max=100,
                                    type=int, 
                                    value=0,
                                    callback=shiftRockCenter,
                                    continuous=True,
                                    oneTurn=90,
                                    wheelPad=0,
                                    )
        shiftRockCenterThumbwheel.pack(side='top', anchor='e')
        anglesFrame.pack(side='top')

        self.spinGui.vectorGUI = vectorGUI(mainFrame,
                                           size=150,
                                           vector=self.spinAxis,
                                           callback=self.setWithSpinGui,
                                           )

        mainFrame.pack(side='top')
Exemplo n.º 36
0
    def gui(self):
        "GUI for MGLTools updates"
        import tkinter
        self.master = tkinter.Tk()
        self.master.lift()
        self.master.title("Update MGLTools")
        self.master.option_add('*font', "Times 12 bold")
        text = "Update Manager"
        tkinter.Label(self.master,
                      text=text,
                      bg='white',
                      font=(ensureFontCase('helvetica'),
                            16)).grid(column=0,
                                      row=0,
                                      columnspan=3,
                                      sticky='snew')

        tested_rc = self.updates_rc_dir + os.sep + "tested"
        nightly_rc = self.updates_rc_dir + os.sep + "nightly"
        tested_dir = None
        nightly_dir = None

        if os.path.exists(tested_rc):
            tested_dir = open(tested_rc).read()

        if os.path.exists(nightly_rc):
            nightly_dir = open(nightly_rc).readlines()

        text = "You are running MGLTools " + self.Version
        if nightly_dir:
            tmp = nightly_dir[0]
            text += " with nightly update from " + tmp.split()[1]
            if len(nightly_dir) > 1:
                text += "\nOlder installed updates:\n"
                for item in nightly_dir[1:]:
                    text += "    nightly " + item.split('\t')[1] + "\n"
                if tested_dir:
                    text += "    tested  " + tested_dir.split('\t')[1]
            elif tested_dir:
                text += "\nOlder installed updates:\n"
                text += "    tested " + tested_dir.split('\t')[1]
        elif tested_dir:
            text += " with tested update from " + tested_dir.split()[1]

        tkinter.Label(self.master, text=text, bg='white',
                      justify='left').grid(row=1,
                                           column=0,
                                           columnspan=3,
                                           sticky='snew')

        self.notebook = Pmw.NoteBook(self.master)
        self.notebook.grid(row=2, column=0, columnspan=3, sticky='snew')
        webPage = self.notebook.add('Online')
        self.webPage = webPage
        self.updateCheckbutton = tkinter.Checkbutton(webPage,
                                                     text="Check for Updates",
                                                     command=self.checkUpdates)
        self.updateCheckbutton.grid(row=0, column=0, columnspan=3, sticky='nw')

        self.tk_latest = tkinter.IntVar()

        from mglutil.gui.BasicWidgets.Tk.progressBar import ProgressBar
        self.frame = tkinter.Frame(self.master, relief='groove')
        self.frame.grid(row=4, column=0, columnspan=3, sticky='ew')
        self.progressBar = ProgressBar(master=self.frame,
                                       labelside=None,
                                       width=200,
                                       height=20,
                                       mode='percent')
        self.progressBar.setLabelText('Progress...')
        self.frame.grid_forget()
        self.waitTk = tkinter.IntVar()
        if tested_dir or nightly_dir:
            tkinter.Button(self.master,
                           text="Revert to " + self.Version,
                           command=self.clearUpdatesGUI).grid(row=5, column=0)
        if nightly_dir:
            if len(nightly_dir) > 1:
                tkinter.Button(self.master, text="Rollback to nightly " + \
                               nightly_dir[1].split('\t')[1],
                               command=self.rollback).grid(row=5, column=1)
            elif tested_dir:
                tkinter.Button(self.master, text="Rollback to tested " + \
                               tested_dir.split('\t')[1],
                               command=self.rollback).grid(row=5, column=1)


        tkinter.Button(self.master, text="Cancel", command=self.cancel).\
                                                           grid(row=5, column=2)

        self.tested_dir = tested_dir
        self.nightly_dir = nightly_dir

        filePage = self.notebook.add('File')
        self.localLabel = tkinter.Label(filePage,
                                        text="Update from Local File",
                                        justify='left',
                                        fg='gray45')
        self.localLabel.grid()
        self.localButton = tkinter.Button(filePage,
                                          text="Browse...",
                                          command=self.updateLocal)
        self.localButton.grid()
        self.notebook.setnaturalsize()
        return self.waitTk
Exemplo n.º 37
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
            })
Exemplo n.º 38
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
                })
Exemplo n.º 39
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")
Exemplo n.º 40
0
 def __init__(self, title="Bug Report", message="", bg=None,
              fg=None, font=(ensureFontCase('helvetica'), 10, 'bold'),):
     BugReport.__init__(self, title, message, bg, fg, font,)
Exemplo n.º 41
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=[]
Exemplo n.º 42
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)