Example #1
0
        def askSpan(orient='v'):
            win = Toplevel()
            pxmin = ParamItem(win)
            pxmin.pack()
            pxmin.labelText = 'xmin' if orient == 'v' else 'ymin'
            pxmax = ParamItem(win)
            pxmax.pack()
            pxmax.labelText = 'xmax' if orient == 'v' else 'ymax'

            def formatter(val):
                val = float(val)
                val /= 100.
                return '{0:0.2f}'.format(val)

            alphaScale = LabeledScale(win,
                                      from_=0,
                                      to=100,
                                      name='alpha',
                                      formatter=formatter)
            alphaScale.set(50.0)
            alphaScale.pack()
            win.protocol('WM_DELETE_WINDOW', win.quit)
            win.focus_set()
            win.grab_set()
            win.mainloop()
            xmin = pxmin.entry.get()
            xmax = pxmax.entry.get()
            alpha = alphaScale.get() / 100.
            win.destroy()
            return map(float, (xmin, xmax, alpha))
Example #2
0
    def __init__(self, *args, **kwargs):
        self._app = Application.instance    
        self.__topwin = kwargs.pop('topwin')

        super(OptimizeGroup, self).__init__(*args, **kwargs)
        
      
        
        paramFrm    = Frame(self)
        paramFrm.pack(side=LEFT, expand=YES, fill=Y)
        self.__num = ParamItem(paramFrm)
        setMultiAttr(self.__num,
            labelText   = 'num',
            entryText   = '1',
            labelWidth  = 5,
            entryWidth  = 8,
            checkFunc   = self._app.checkInt
        )
        self.__num.entry.bind('<Return>', lambda event: self.onSolveClick())
        self.__num.pack(side=TOP)

     

        self.__pci  = ParamItem(paramFrm)
        setMultiAttr(self.__pci,
            labelText   = 'PCI',
            entryText   = '100',
            labelWidth  = 5,
            entryWidth  = 8,
            checkFunc   = self._app.checkInt
        )
        self.__pci.pack(side=TOP)
        
        self.__bParallel    = IntVar()
        self.__chkParallel  = Checkbutton(paramFrm, text="Parallel", variable=self.__bParallel)
        self.__chkParallel.pack()
        
        progfrm = Frame(self)
        progfrm.pack(side=LEFT, expand=YES, fill=Y)

        self.__genbtn = Button(progfrm, text='Generate', command=self.onSolveClick)
        self.__genbtn.pack(side=TOP)  
        Button(progfrm, text='Stop', command=self.onStopBtnClick).pack(side=TOP)         
        
        self.__progress = IntVar()
        self.__finishedwav = IntVar()        
        self.__progbar = Progressbar(progfrm, orient='horizontal', variable=self.__progress, maximum=100)
        self.__progbar.pack(side=LEFT)
        self.__progbar.config(length=55)   
        self.__finishedwavbar = Progressbar(progfrm, orient='horizontal', variable=self.__finishedwav)
        self.__finishedwavbar.pack(side=LEFT)
        self.__finishedwavbar.config(length=30)  


        self.name = 'Generate'

        self.getparams = None
        self.__stopflag = False
Example #3
0
 def __init__(self, *args, **kwargs):
     #self._app = app = Application.instance
     self.__topwin = kwargs.pop('topwin')
     Group.__init__(self, *args, **kwargs)
     Button(self, text='Load *.mat', command=self.onLoadClick).pack()
     paramX = ParamItem(self)
     paramX.labelText = 'x = '
     paramX.entryWidth = 6
     paramX.pack()
     self.__paramX = paramX
     paramY = ParamItem(self)
     paramY.labelText = 'y = '
     paramY.entryWidth = 6
     paramY.pack()
     self.__paramY = paramY
     self.name = 'Load'
Example #4
0
 def appendAlgorithm(self, algorithm):
     #To do: when algo is reset, the frm should be removed
     for algoName in self.__frameDict:
         self.__frameDict[algoName]['frame'].pack_forget()
     frm = Frame(self)
     frm.pack()
     paramInfo   = {}
     params = algorithm['parameters']
     for idx, name in enumerate(params):
         param = params[name]
         paramitem = ParamItem(frm)
         paramitem.labelText = name
         paramitem.labelWidth = 5
         paramitem.entryWidth = 8
         if self.balloon:
             self.balloon.bind_widget(paramitem.label, balloonmsg=param.shortdesc)
         if param.type == 'int':
             paramitem.checkFunc = self._app.checkInt
         elif param.type == 'float':
             paramitem.checkFunc = self._app.checkFloat
         paramitem.grid(row=idx%self.__MAXROW, column=idx//self.__MAXROW)
         #self.__params[param.name] = {'gui':paramitem, 'meta':param}
         paramInfo[param.name] = {'gui':paramitem, 'meta':param}
     self.__algo = algorithm
     #self.__frameDict[algorithm.meta.name]   = frm
     self.__frameDict[algorithm['name']]   = dict(frame=frm, paramInfo=paramInfo)
     self.__params   = paramInfo
Example #5
0
        def __init__(self, *args, **kwargs):
            timer = kwargs.pop('timer')
            self.__timer = timer

            Toplevel.__init__(self, *args, **kwargs)
            interval = ParamItem(self)
            interval.labelText = 'Interval (ms)'
            interval.entryText = str(timer.interval)
            interval.entryWidth = 5
            interval.pack(side=TOP)
            self.interval = interval

            self.active = IntVar(timer.active)
            Checkbutton(self,
                        text='Activate',
                        variable=self.active,
                        command=self.onActivateClick).pack(side=TOP)
            Button(self, text='OK', command=self.onOKClick).pack(side=TOP)

            def hide():
                self.visible = False

            self.protocol('WM_DELETE_WINDOW', hide)

            self.__visible = True
            self.visible = False
Example #6
0
        def askgridprop():
            win = Toplevel()
            color = ['#000000', '#000000']

            propvars = [StringVar() for i in range(4)]
            guidata = (
                {
                    'linestyle': ('Major Line Style', propvars[0], None),
                    ########################################################################################################
                    'linewidth':
                    ('Major Line Width', propvars[1], checkPositiveFloat)
                },
                {
                    'linestyle': ('Minor Line Style', propvars[2], None),
                    'linewidth':
                    ('Minor Line Width', propvars[3], checkPositiveFloat)
                    #########################################################################################################
                })

            for d in guidata:
                for key in d:
                    pitem = ParamItem(win)
                    pitem.pack()
                    pitem.labelText = d[key][0]
                    pitem.entry['textvariable'] = d[key][1]
                    if d[key][2]:
                        pitem.checkFunc = d[key][2]

            def setmajorcolor():
                c = askcolor()
                color[0] = c[1]

            def setminorcolor():
                c = askcolor()
                color[1] = c[1]

            Button(win, text='Major Line Color', command=setmajorcolor).pack()
            Button(win, text='Minor Line Color', command=setminorcolor).pack()

            win.protocol('WM_DELETE_WINDOW', win.quit)
            win.focus_set()
            win.grab_set()
            win.mainloop()
            win.destroy()
            c_major = StringVar()
            c_major.set(color[0])
            c_minor = StringVar()
            c_minor.set(color[1])
            guidata[0]['color'] = ('Major Line Color', c_major, None)
            guidata[1]['color'] = ('Minor Line Color', c_minor, None)
            return guidata
Example #7
0
    def __init__(self, *args, **kwargs):
        #        app = Application.instance
        if 'valueChecker' in kwargs:
            valueChecker = kwargs.pop('valueChecker')
            checkFloat = valueChecker.checkFloat
        else:
            checkFloat = None

        if 'balloon' in kwargs:
            balloonBindWidget = kwargs.pop('balloon').bind_widget
        else:
            balloonBindWidget = lambda *args, **kwargs: None

        super(AxisGroup, self).__init__(*args, **kwargs)
        self.__params = [StringVar() for i in range(8)]
        paramfrm = Frame(self)
        paramfrm.pack()
        names = [
            'xmin', 'xmax', 'ymin', 'ymax', 'major xtick', 'major ytick',
            'minor xtick', 'minor ytick'
        ]
        images = [
            'ViewTab_XMin.png', 'ViewTab_XMax.png', 'ViewTab_YMin.png',
            'ViewTab_YMax.png', 'ViewTab_MajorXTick.png',
            'ViewTab_MajorYTick.png', 'ViewTab_MinorXTick.png',
            'ViewTab_MinorYTick.png'
        ]
        for c in range(4):
            for r in range(2):
                temp = ParamItem(paramfrm)
                image = ImageTk.PhotoImage(file=uiImagePath(images[c * 2 + r]))
                setMultiAttr(
                    temp,
                    checkFunc=checkFloat,
                    #labelText   = names[c*2+r],
                    labelImage=image,
                    labelWidth=5 if c * 2 + r < 4 else 10,
                    entryWidth=5,
                    entryVar=self.__params[c * 2 + r])
                temp.entry.bind('<Return>', self.onConfirmClick)
                temp.grid(row=r, column=c)
                balloonBindWidget(temp, balloonmsg=names[c * 2 + r])

        btnfrm = Frame(self)
        btnfrm.pack()
        Button(btnfrm, text='Confirm',
               command=self.onConfirmClick).pack(side=LEFT)
        Button(btnfrm, text='Auto', command=self.onAutoClick).pack(side=RIGHT)
        self.name = 'Axis'
        self.__figureObserver = self.FigureObserver(self)
Example #8
0
def askClassName():
    win = Toplevel()

    moduleName = StringVar()
    className = StringVar()

    moduleItem = ParamItem(win)
    moduleItem.labelText = 'Module Name'
    moduleItem.pack()
    moduleItem.entryVar = moduleName

    classItem = ParamItem(win)
    classItem.labelText = 'Class Name'
    classItem.pack()
    classItem.entryVar = className

    Button(win, text='OK', command=win.quit).pack()

    win.protocol('WM_DELETE_WINDOW', win.quit)
    win.focus_set()
    win.grab_set()
    win.mainloop()
    win.destroy()
    return moduleName.get(), className.get()
Example #9
0
    def __init__(self, *args, **kwargs):
        self._app = Application.instance
        self.__uiImages = []
        self.__topwin = kwargs.pop('topwin')
        Group.__init__(self, *args, **kwargs)
        frm = Frame(self)
        frm.pack(side=TOP)

        imageMLbl = ImageTk.PhotoImage(file=uiImagePath('Pattern_M_Label.png'))
        self.__uiImages.append(imageMLbl)
        Label(frm, image=imageMLbl).pack(side=LEFT)

        self.__M = ParamItem(frm)
        self.__M.label.config(text='M')
        self.__M.entryWidth = 6
        self.__M.entryText = 10
        self.__M.entry.bind('<Return>', lambda dumb: self.onSolve())
        self.__M.checkFunc = self._app.checkInt
        self.__M.pack(side=RIGHT)

        self._app.balloon.bind_widget(
            frm, balloonmsg='The number of the array elements.')

        imageSolveBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Solve_Button.png'))
        self.__uiImages.append(imageSolveBtn)

        self.__btnSolve = Button(self,
                                 image=imageSolveBtn,
                                 command=self.onSolve)
        self.__btnSolve.pack(side=TOP)
        self._app.balloon.bind_widget(
            self.__btnSolve,
            balloonmsg='Launch the solver to synthesize the correlation matrix.'
        )

        frm = Frame(self)
        frm.pack(side=TOP)
        imageDisplayBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Display_Button.png'))
        self.__uiImages.append(imageDisplayBtn)
        Label(frm, image=imageDisplayBtn).pack(side=LEFT)
        self.__bDisplay = IntVar(0)
        chkDisplay = Checkbutton(frm, text="Display", variable=self.__bDisplay)
        chkDisplay.pack(side=TOP)
        self._app.balloon.bind_widget(frm, balloonmsg='Display solver output.')

        self.name = 'Optimize'
Example #10
0
    def __init__(self, *args, **kwargs):
        self._app = Application.instance
        self.__topwin = kwargs.pop('topwin')
        Group.__init__(self, *args, **kwargs)
        frm = Frame(self)

        self.__center = ParamItem(frm)
        setMultiAttr(self.__center,
                     labelText='center(deg)',
                     entryText=0,
                     checkFunc=self._app.checkInt,
                     entryWidth=5,
                     labelWidth=10)
        self.__center.pack(side=TOP)
        self._app.balloon.bind_widget(
            self.__center, balloonmsg='Specify the beam center here.')

        self.__width = ParamItem(frm)
        setMultiAttr(self.__width,
                     labelText='width(deg)',
                     entryText=20,
                     checkFunc=self._app.checkInt,
                     entryWidth=5,
                     labelWidth=10)
        self.__width.pack(side=TOP)
        self._app.balloon.bind_widget(
            self.__width, balloonmsg='Specify the beam width here.')

        self.__uiImages = []

        imageAddBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Add_Button.png'))
        self.__uiImages.append(imageAddBtn)
        btn = Button(frm, image=imageAddBtn, command=self.onAdd)
        btn.pack(side=LEFT)
        self._app.balloon.bind_widget(
            btn, balloonmsg='Add new beam to the ideal pattern.')

        imageDelBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Del_Button.png'))
        self.__uiImages.append(imageDelBtn)
        btn = Button(frm, image=imageDelBtn, command=self.onDel)
        btn.pack(side=LEFT)
        self._app.balloon.bind_widget(
            btn, balloonmsg='Remove the selected beam in the listbox.')

        imageClrBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Clear_Button.png'))
        self.__uiImages.append(imageClrBtn)
        btn = Button(frm, image=imageClrBtn, command=self.onClear)
        btn.pack(side=LEFT)
        self._app.balloon.bind_widget(
            btn, balloonmsg='Clear the listbox of the beam parameters.')

        imagePlotBtn = ImageTk.PhotoImage(
            file=uiImagePath('Pattern_Plot_Button.png'))
        self.__uiImages.append(imagePlotBtn)
        btn = Button(frm, image=imagePlotBtn, command=self.onPlotIdealPattern)
        btn.pack(side=LEFT)
        self._app.balloon.bind_widget(btn,
                                      balloonmsg='Plot the ideal pattern.')

        frm.pack(side=LEFT, fill=Y)

        self.__paramlist = ScrolledList(self)
        self.__paramlist.list.config(height=4, width=10)
        self.__paramlist.pack(side=LEFT)
        self.name = 'Edit Ideal Pattern'

        self.optgrp = None