コード例 #1
0
ファイル: app.py プロジェクト: SCOTPAUL/shift-calc
    def __setup_menus(self):
        self.menu = Menu(self.root, relief=FLAT)
        file_menu = Menu(self.menu, tearoff=0)
        file_menu.add_command(label="Add holiday",
                              command=self.holiday_manager.add_holiday_gui)

        file_menu.add_command(label="Reset holidays", command=self.holiday_manager.reset_holidays_gui)
        file_menu.add_command(label="Goto month", command=self.goto_date_gui)
        self.menu.add_cascade(label="File", menu=file_menu)

        # Contains about option, giving application information
        help_menu = Menu(self.menu, tearoff=0)
        help_menu.add_command(label="About", command=self.about_info_gui)
        self.menu.add_cascade(label="Help", menu=help_menu)

        # Display on screen
        self.root.config(menu=self.menu)

        # Toolbar
        toolbar = Frame(self.root)

        # Add holiday button calls add_new_holiday with args to refresh window
        add_holiday = Button(toolbar, text="Add Holiday",
                             command=self.holiday_manager.add_holiday_gui)
        add_holiday.grid(row=0, column=0)
        tooltip.createToolTip(add_holiday, "Adds a new holiday to the calendar")

        # Reset button clears holidays, resets to current date
        reset_holidays = Button(toolbar, text="Reset Holidays", command=self.holiday_manager.reset_holidays_gui)
        reset_holidays.grid(row=0, column=1)
        tooltip.createToolTip(reset_holidays, "Resets all of the user set holidays")

        toolbar.grid(row=0, sticky="W")
コード例 #2
0
ファイル: trgui.py プロジェクト: pyIPP/trgui
    def slice(self):

        if hasattr(self, 'fitframe'):
            self.fitframe.destroy()
        self.fitframe = ttk.Frame(self.topprof)
        self.fitframe.pack(side=tk.TOP, anchor=tk.W)

        methodframe = ttk.Frame(self.fitframe)
        butframe    = ttk.Frame(self.fitframe)
        for frame in methodframe, butframe:
            frame.pack(side=tk.TOP, anchor=tk.W, pady=10)

        ttk.Label(methodframe, text='Fitting method', width=14).pack(side=tk.LEFT)
        self.fit_method = tk.StringVar()
        self.fit_method.set('rec_spl')
        fit_rb1 = ttk.Radiobutton(methodframe, text='Rec. spline', variable=self.fit_method, value='rec_spl')
        fit_rb2 = ttk.Radiobutton(methodframe, text='Gauss', variable=self.fit_method, value='gauss')
        fit_rb3 = ttk.Radiobutton(methodframe, text='Fit 2D', variable=self.fit_method, value='fit_2d')
        for rb in fit_rb1, fit_rb2, fit_rb3:
            rb.pack(side=tk.LEFT, padx=10)
        createToolTip(fit_rb1, 'Cubic spline of single profiles')
        createToolTip(fit_rb3, 'Fast 2d spline fitting of the profiles')

        ttk.Button(butframe, text='Fit', width=13, command=self.dw2fit).pack(side=tk.TOP, anchor=tk.W)

        self.slice_data()
コード例 #3
0
ファイル: read_sgr.py プロジェクト: pyIPP/trgui
    def __init__(self, dw2_dic):

        if __name__ == '__main__':
            myframe = tk.Tk()
        else:
            myframe = tk.Toplevel()

        myframe.title(' 2d profiles')

# Get initial values

        fbm_target = 'MTHDAVG=2'
        runid = ''

        dw2init = {}
        dw2init['exp'] = 'AUGD'
        dw2init['ed']  = '0'
        dw2init['Dt_average'] = '0.0'
        dw2init['Map_exp']  = 'AUGD'
        dw2init['Map_diag'] = 'EQH'
        dw2init['Map_ed']   = '0'
        dw2init.update(dw2_dic)
        self.status = [False, ]

        self.dw2_d    = {}
        self.dwpl_d   = {}
        self.opt_dict = {}
# Toolbar

        okfig = tk.PhotoImage(file=tksty.icon_dir+'ed_execute.gif')
        qtfig = tk.PhotoImage(file=tksty.icon_dir+'bld_exit.gif')

        toolframe = sty.myToolbar(myframe)
        dw2frame  = sty.mySubframe(myframe)

        btok = sty.myButton(toolframe, 'load', self.myddww, nrow=0)
        btqt = sty.myButton(toolframe, 'exit', myframe.destroy, nrow=0, ncol=1)

        n_row = 0
        for key in ('shot', 'tbeg', 'tend', 'exp', 'diag', 'sig', 'err', \
                    'ed', 'Dt_average', 'Map_exp', 'Map_diag', 'Map_ed'):
            lbl = sty.myLabel(dw2frame, key, nrow=n_row)
            var = sty.myEntry(dw2frame, dw2init[key], nrow=n_row, ncol=1)
            self.dw2_d[key]=var
            n_row += 1

# Output: rho_pol or rho_tor
        lbl = sty.myLabel(dw2frame, 'U-file coord', nrow=n_row)
        rho_lbl = tk.StringVar()
        rho_lbl.set('rho_tor')
        n_col=1
        for val in ('rho_pol', 'rho_tor'):
            a=sty.myRb(dw2frame, var=rho_lbl, val=val, txt=val, nrow=n_row, ncol=n_col)
            createToolTip(a, 'The difference between rho_pol from TRANSP and CLISTE can be significant!')

            n_col += 1
        self.dw2_d['rho_lbl'] = rho_lbl
        n_row += 1
コード例 #4
0
ファイル: trguij.py プロジェクト: pyIPP/trgui
    def slice(self):


        if hasattr(self, 'fitframe'):
            self.fitframe.destroy()
        self.fitframe = ttk.Frame(self.topprof)
        self.fitframe.pack(side=tk.TOP, anchor=tk.W)

        methodframe = ttk.Frame(self.fitframe)
        butframe    = ttk.Frame(self.fitframe)
        for frame in methodframe, butframe:
            frame.pack(side=tk.TOP, anchor=tk.W, pady=10)

# Create wish time grid

        nshot = int(self.shot_but.get())
        self.dtav = float(self.dtav_val.get())

        tbeg = 1e3
        tend = -1e3
        for diag in self.raw_data.keys():
            tbeg = min(tbeg, self.raw_data[diag]['tgrid'][0])
            tend = max(tend, self.raw_data[diag]['tgrid'][-1])
        tbeg = max(tbeg, float(self.tbeg_but.get()))
        tend = min(tend, float(self.tend_but.get()))

        nt = int((tend - tbeg)/ self.dtav)
        self.red_data = {}
        tgrid = tbeg + self.dtav*np.arange(nt)

# Store mapped data into dict
        self.red_data = {}
        for diag in self.raw_data.keys():
            self.red_data[diag] = {}
            x_red, y_red, err_red = time_slice.map2tgrid( \
                self.raw_data[diag], tgrid, nshot=nshot, noELMs=self.no_elm.get())
            self.red_data[diag]['rhop']     = x_red
            self.red_data[diag]['data']     = y_red
            self.red_data[diag]['data_err'] = err_red
            self.red_data[diag]['tgrid']    = tgrid

        ttk.Label(methodframe, text='Fitting method', width=14).pack(side=tk.LEFT)
        self.fit_method = tk.StringVar()
        self.fit_method.set('rec_spl')
        fit_rb1 = ttk.Radiobutton(methodframe, text='Rec. spline', variable=self.fit_method, value='rec_spl')
        fit_rb2 = ttk.Radiobutton(methodframe, text='Gauss', variable=self.fit_method, value='gauss')
        fit_rb3 = ttk.Radiobutton(methodframe, text='Fit 2D', variable=self.fit_method, value='fit_2d')
        for rb in fit_rb1, fit_rb2, fit_rb3:
            rb.pack(side=tk.LEFT, padx=10)
        createToolTip(fit_rb1, 'Cubic spline of single profiles')
        createToolTip(fit_rb3, 'Fast 2d spline fitting of the profiles')

        ttk.Button(butframe, text='Fit', width=13, command=self.dw2fit).pack(side=tk.TOP, anchor=tk.W)
コード例 #5
0
    def create_spinbox(self, ctn):
        def _spin():
            value = self.spin.get()
            print(value)
            self.scr.insert(tk.INSERT, value + '\n')

        self.spin = tk.Spinbox(
            ctn,
            values=('abc', 12, "大街上发的", 0.45),
            relief=tk.RIDGE,  #tk.SUNKEN tk.RAISED tk.FLAT tk.GROOVE tk.RIDGE
            width=10,
            bd=8,
            command=_spin)
        self.spin.grid(column=0, row=6)
        ttp.createToolTip(self.spin, "这是一个spin控件")  #add a ToolTip
コード例 #6
0
ファイル: receive.py プロジェクト: petedaws/udp-transfer
 def __init__(self,master=None,file_detail=None):
     Frame.__init__(self,master)
     self._file_detail = file_detail
     self.master.title(self._file_detail['name'])
     self.grid()
     self.buttons = []
     button_count = 0
     for row in xrange(SQUARESIZE):
         for col in xrange(SQUARESIZE):
             button = Button(self,text='%04d' % (button_count),anchor=W)
             button.grid(row=row,column=col)
             tooltip.createToolTip(button, '%d to %d' %(self.get_block_range(button_count)[0],self.get_block_range(button_count)[1]))
             self.buttons.append(button)
             button_count+=1
             if button_count > self._file_detail['total_blocks']:
                 break
         if button_count > self._file_detail['total_blocks']:
                 break
コード例 #7
0
ファイル: mainWindow.py プロジェクト: Tomasmed18/TP-inv-op
    def insertarToolTips(self):

        stringCategorias = "Este boton sirve para cargar las categorias que ligan un campo de los dataset a unas palabras claves.\n Por ejemplo Economia se define a partir del campo 'titulo_secundario' con la palabra clave 'Administracion'\n"
        stringFiltros = "Este boton sirve para cargar filtros definidos en un archivo, por ejemplo que la fecha de ingreso sea en el 2017"
        stringArchivos = "Este boton permite cargar los archivos de notas y alumnos en formato excel"
        tooltip.createToolTip(self.CargarCategorias, stringCategorias)
        tooltip.createToolTip(self.CargarArchivo, stringArchivos)
        tooltip.createToolTip(self.cargarFiltros, stringFiltros)
コード例 #8
0
ファイル: send.py プロジェクト: petedaws/udp-transfer
 def __init__(self,filename,master=None):
     Frame.__init__(self,master)
     self.master.title(".")	  
     self.grid()
     self.processed_file = read_file(filename,BLOCKSIZE)
     self.buttons = []
     self.handlers = []
     button_count = 0
     for row in xrange(SQUARESIZE):
         for col in xrange(SQUARESIZE):
             button = Button(self,text='%04d' % (button_count),anchor=W)
             button.grid(row=row,column=col)
             tooltip.createToolTip(button, '%d to %d' %(self.get_block_range(button_count)[0],self.get_block_range(button_count)[1]))
             def handler(event, self=self,button_number=button_count,blockrange=self.get_block_range(button_count)):
                     return self.send_blocks(button_number,blockrange[0],blockrange[1])
             button.bind("<Button-1>", handler)
             self.buttons.append(button)
             self.handlers.append(handler)
             button_count+=1
             if button_count > self.processed_file['total_blocks']:
                 break
         if button_count > self.processed_file['total_blocks']:
                 break
コード例 #9
0
ファイル: geo_test.py プロジェクト: pyIPP/trgui
    def __init__(self, geoframe=None):

        if geoframe is None:
            if __name__ == '__main__':
                geoframe = tk.Tk()
            else:
                geoframe = tk.Toplevel()
            geoframe.geometry('1600x950')

        pol_frame = ttk.Frame(geoframe)
        butframe  = ttk.Frame(geoframe)
        toolframe = ttk.Frame(geoframe)
        for frame in (pol_frame, butframe, toolframe):
            frame.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

# Canvas frame

        self.pol_fig = Figure(figsize=(8.3, 8.3), dpi=100)
        self.pol_fig.set_facecolor(figc)
        self.pol_fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9 , top=0.94)
        self.pol_canvas = FigureCanvasTkAgg(self.pol_fig, master=pol_frame)
        self.pol_canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        axsep = self.pol_fig.add_subplot(111, aspect='equal')
        axsep.set_xlabel('R [m]')
        axsep.set_ylabel('z [m]')
        self.sepscat, = axsep.plot([], [], 'k+')
        self.sepfit,  = axsep.plot([], [], 'g-')
        gc_r, gc_z = map_equ_20180130.get_gc()
        for key in gc_r.keys():
            axsep.plot(gc_r[key], gc_z[key], 'b-')

# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig  = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig  = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig = tk.PhotoImage(file='%s/backward.gif' %locdir)

        self.play_button = ttk.Button(butframe, command=self.Play,    image=self.playfig)
        backward_button = ttk.Button(butframe, command=self.Backward,image=self.backwardfig)
        forward_button  = ttk.Button(butframe, command=self.Forward, image=self.forwardfig)

        createToolTip(forward_button  , 'Go to next timestep')
        createToolTip(backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button, 'Forward animation/pause')

        for but in backward_button, self.play_button, forward_button:
            but.pack(side=tk.LEFT)

# Entry frame

        geoinit = {'Nmom':'6', 'exp':'AUGD', 'dia':'EQH', 'ed':'0'}
        self.geodict = {}

        n_col=0
        for key in ('ed', 'dia', 'exp', 'Nmom'):
            var = ttk.Entry(butframe, width=6)
            var.insert(0, geoinit[key])
            var.pack(side=tk.RIGHT, padx='0 10')
            ttk.Label(butframe, text='%s:' %key, width=6).pack(side=tk.RIGHT, padx=5)
            self.geodict[key] = var

# Toolbar

        toolbar = NavigationToolbar2TkAgg(self.pol_canvas, toolframe)
        toolbar.config(background=tbc)
        toolbar.update()

        self.pol_canvas.draw()
        if __name__ == '__main__':
            geoframe.mainloop()
コード例 #10
0
    def main(self):

        # CREATING TABS
        self.tabControl = ttk.Notebook(self.win)  # Create tab control (list)
        self.tabControl.pack(expand=1, fill="both")  # Makes tab visible

        self.tab1 = ttk.Frame(self.tabControl)  # Create a tab
        self.tabControl.add(self.tab1, text="Tab 1")  # Adds the tab

        self.tab2 = ttk.Frame(self.tabControl)  # A new tab
        self.tabControl.add(self.tab2, text="Tab 2")  # Adds the tab

        # CREATING A CONTAINER FRAME IN THE WINDOW TO HOLD ALL WIDGETS
        self.monty = ttk.LabelFrame(self.tab1, text=" Monty Python ")
        self.monty.grid(column=0, row=0, padx=5, pady=5)

        # FIRST AND SECOND ROWS (LABELS AND ENTRY BOXES)
        ttk.Label(self.monty, text="Enter a name:").grid(column=0,
                                                         row=0,
                                                         sticky='W')
        self.name = tk.StringVar()
        self.nameEntered = ttk.Entry(self.monty,
                                     width=24,
                                     textvariable=self.name)
        self.nameEntered.grid(column=0, row=1, sticky='WE')
        self.action2 = ttk.Button(self.monty,
                                  text="Click me!",
                                  command=self.clickMe)
        self.action2.grid(column=2, row=1)

        # COMBOBOX
        self.aLabel2 = ttk.Label(self.monty,
                                 text="Choose a number:").grid(column=1, row=0)
        self.number = tk.StringVar()
        self.numberChosen = ttk.Combobox(
            self.monty, width=14, textvariable=self.number, state='readonly'
        )  # ...state='readonly')  does not allow the user to enter his/her own value into combo box
        self.numberChosen['values'] = (1, 2, 4, 42, 100)
        self.numberChosen.grid(column=1, row=1)
        self.numberChosen.current(0)

        # NEW LABEL FRAME FOR TAB 2
        self.monty2 = ttk.LabelFrame(self.tab2, text=" The Snake ")
        self.monty2.grid(column=0, row=0, padx=20, pady=20)

        # CHECKBOXES
        self.check1 = tk.IntVar()
        self.checkBox1 = tk.Checkbutton(self.monty2,
                                        text="Disabled",
                                        variable=self.check1,
                                        state='disabled')
        self.checkBox1.select()
        self.checkBox1.grid(
            column=0, row=0,
            sticky=tk.W)  # sticky=tk.W ... alligns west of grid
        self.check2 = tk.IntVar()
        self.checkBox2 = tk.Checkbutton(self.monty2,
                                        text="Unchecked",
                                        variable=self.check2)
        self.checkBox2.deselect()
        self.checkBox2.grid(column=1, row=0, sticky=tk.W)
        self.check3 = tk.IntVar()
        self.checkBox3 = tk.Checkbutton(self.monty2,
                                        text="Enabled",
                                        variable=self.check3)
        self.checkBox3.select()
        self.checkBox3.grid(column=2, row=0, sticky=tk.W)
        createToolTip(self.checkBox3, text="This is a checkbox")

        self.colour = ('Blue', 'Gold', 'Red')
        self.radio = tk.IntVar()
        self.radio.set(99)
        for col in range(3):
            self.radioButton = ttk.Radiobutton(self.monty2,
                                               text=self.colour[col],
                                               variable=self.radio,
                                               value=col + 1,
                                               command=self.radioButtonCall)
            self.radioButton.grid(column=0 + col, row=1, sticky=tk.W)

        # SPINBOX
        self.spin = tk.Spinbox(
            self.monty,
            values=(1, 2, 4, 6, 7, 8, 100),
            width=5,
            bd=8,
            state='readonly',
            command=self._spinBox)  # bd = borderwidth (makes it embedded)
        self.spin.grid(column=0, row=2, sticky='W')
        createToolTip(self.spin, 'This is a Spin control.')

        # SCROLLED TEXT
        self.scrolledTextWidth = 40
        self.scrolledTextHeight = 10
        self.scrText = ScrolledText.ScrolledText(
            self.monty,
            width=self.scrolledTextWidth,
            height=self.scrolledTextHeight,
            wrap=tk.WORD
        )  # wrap=tk.WORD ... wraps words so a new line doesn't start mid-word
        self.scrText.grid(column=0, row=3, columnspan=3, sticky='WE')
        createToolTip(self.scrText, 'This is a ScrolledText widget.')

        # LABEL FRAME
        labelFrame = ttk.LabelFrame(self.monty2, text=" Labels in a frame ")
        #labelFrame.grid(column=0, row=1, padx=20, pady=20, sticky='NW')
        labelFrame.grid(columnspan=3, padx=5, pady=5, sticky='W')
        ttk.Label(labelFrame, text="Label 1").grid(column=0, row=0)
        ttk.Label(labelFrame, text="Label 2").grid(column=0, row=1)
        ttk.Label(labelFrame, text="Label 3").grid(column=0, row=2)

        for subLabel in labelFrame.winfo_children():
            subLabel.grid_configure(padx=8, pady=4)

        # LEFT ALLIGNS ALL WIDGETS IN FRAME MONTY
        #for child in monty.winfo_children():
        #    child.grid_configure(sticky='W', padx=5, pady=5)

        # MENU BAR
        menuBar = tk.Menu(self.win)
        self.win.config(menu=menuBar)

        fileMenu = tk.Menu(menuBar, tearoff=0)
        fileMenu.add_command(label="New")
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self._quit)
        menuBar.add_cascade(label="File", menu=fileMenu)

        helpMenu = tk.Menu(menuBar, tearoff=0)  # Creating menu
        helpMenu.add_command(label="About",
                             command=self._aboutMsgBox)  # Adding items to menu
        helpMenu.add_command(label="Test warning", command=self._warning)
        helpMenu.add_command(label="Test error", command=self._error)
        helpMenu.add_command(label="Test question", command=self._question)
        menuBar.add_cascade(label="Help",
                            menu=helpMenu)  # Inserting menu into menu bar

        # ADDITIONS TO SECOND TAB
        # Create Manage Files Frame
        mngFilesFrame = ttk.LabelFrame(self.tab2, text=' Manage Files: ')
        mngFilesFrame.grid(column=0, row=1, sticky='WE', padx=5, pady=5)

        # Button Callback
        def getFileName():
            print('hello from getFileName')
            fDir = path.dirname(__file__)
            fName = tkFileDialog.askopenfilename(parent=self.win,
                                                 initialdir=fDir)
            self.fileEntry.config(state='write')
            self.fileEntry.delete(0, tk.END)
            self.fileEntry.insert(0, fName)
            self.fileEntry.config(width=len(fName) + 3)

        # Add Widgets to Manage Files Frame
        lb = ttk.Button(mngFilesFrame,
                        text="Browse to File...",
                        command=getFileName)
        lb.grid(column=0, row=0, sticky='WE')
        file = tk.StringVar()
        self.entryLen = self.scrolledTextWidth
        self.fileEntry = ttk.Entry(mngFilesFrame,
                                   width=self.entryLen,
                                   textvariable=file)
        self.fileEntry.grid(column=1, row=0, sticky=tk.W)
        logDir = tk.StringVar()
        self.netwEntry = ttk.Entry(mngFilesFrame,
                                   width=self.entryLen,
                                   textvariable=logDir)
        self.netwEntry.grid(column=1, row=1, sticky=tk.W)

        def copyFile():
            import shutil
            src = self.fileEntry.get()
            print(src)
            file = src.split('/')[-1]
            print(file)
            dst = self.netwEntry.get() + '/' + file
            print(dst)
            try:
                shutil.copy(src, dst)
                tkMessageBox.showinfo('Copy File to Network',
                                      'Success: File copied.')


#            except FileNotFoundError as err:
            except IOError as err:
                tkMessageBox.showerror(
                    'Copy File to Network',
                    '*** Failed to copy file! ***\n\n' + str(err))
            except Exception as ex:
                tkMessageBox.showerror(
                    'Copy File to Network',
                    '*** Failed to copy file! ***\n\n' + str(ex))

        cb = ttk.Button(mngFilesFrame,
                        text="Copy File To : ",
                        command=copyFile)
        cb.grid(column=0, row=1, sticky='WE')
        # Add some space around each label
        for child in mngFilesFrame.winfo_children():
            child.grid_configure(padx=6, pady=6)

        #self.nameEntered.focus() # Place cursor into name Entry
        self.tabControl.select(1)
コード例 #11
0
ファイル: geo.py プロジェクト: pyIPP/trgui
    def __init__(self, geoframe=None):

        if geoframe is None:
            if __name__ == '__main__':
                geoframe = tk.Tk()
                import trgui_style
            else:
                geoframe = tk.Toplevel()
            geoframe.geometry('1200x950')

        pol_frame = ttk.Frame(geoframe)
        butframe  = ttk.Frame(geoframe)
        toolframe = ttk.Frame(geoframe)
        for frame in (toolframe, butframe, pol_frame):
            frame.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1)
 
# Canvas frame

        self.pol_fig = Figure(dpi=100)
        self.pol_fig.set_size_inches(8.2, 8.2)#, forward=True)
        self.pol_fig.set_facecolor(figc)
        self.pol_fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9 , top=0.94)
        self.pol_canvas = FigureCanvasTkAgg(self.pol_fig, master=pol_frame)
        self.pol_canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.axsep = self.pol_fig.add_subplot(111, aspect='equal')
        self.axsep.set_xlim((0.8, 3.0))
        self.axsep.set_ylim((-1.4, 1.4))
        self.axsep.set_xlabel('R [m]')
        self.axsep.set_ylabel('z [m]')
        self.septxt = self.axsep.text(2.6, -1.1, 't = 0.000 s', ha='center')

        geoinit = {'Nmom': 6, 'exp': 'AUGD', 'dia': 'EQH', 'ed': 0}
        self.geodict = {}

        gc_r, gc_z = map_equ_20180130.get_gc()
        for key in gc_r.keys():
            self.axsep.plot(gc_r[key], gc_z[key], 'b-')

        self.sepscat, = self.axsep.plot([], [], 'k+')
        self.mag,     = self.axsep.plot([], [], 'ro', label='Mag. axis')
        self.u,       = self.axsep.plot([], [], 'ko')
        self.o,       = self.axsep.plot([], [], 'go')
        self.xu,      = self.axsep.plot([], [], 'bo', label='Lower X')
        self.xo,      = self.axsep.plot([], [], 'mo', label='Upper X')
        self.sepfit,  = self.axsep.plot([], [], 'g-')
        self.axsep.legend(numpoints=1, loc=1)

# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig     = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig    = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig  = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig = tk.PhotoImage(file='%s/backward.gif' %locdir)

        self.play_button = ttk.Button(butframe, command=self.Play,    image=self.playfig)
        backward_button = ttk.Button(butframe, command=self.Backward, image=self.backwardfig)
        forward_button  = ttk.Button(butframe, command=self.Forward,  image=self.forwardfig)

        createToolTip(forward_button  , 'Go to next timestep')
        createToolTip(backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button, 'Forward animation/pause')

        sliderax = self.pol_fig.add_axes([0.1, 0.01, 0.6, 0.03], axisbg='yellow')
        self.sl_time = Slider(sliderax,'Time:', 0., 1., valinit=0.)
        self.sl_time.valtext.set_text('0.0000')

        def update_time(val):
            self.update_plot(val=val)

        self.sl_time.on_changed(update_time)
        self.pol_fig.canvas.mpl_connect('button_press_event', lambda event:self.pol_fig.canvas._tkcanvas.focus_set())

        for but in backward_button, self.play_button, forward_button:
            but.pack(side=tk.LEFT)

# Entry frame

        for key in ('ed', 'dia', 'exp', 'Nmom'):
            var = ttk.Entry(butframe, width=6)
            var.insert(0, geoinit[key])
            var.pack(side=tk.RIGHT, padx='0 10')
            ttk.Label(butframe, text='%s:' %key, width=6).pack(side=tk.RIGHT, padx=5)
            self.geodict[key] = var

# Toolbar

        toolbar = NavigationToolbar2TkAgg(self.pol_canvas, toolframe)
        toolbar.config(background=tbc)
        toolbar.update()

        self.pol_canvas.draw()
        if __name__ == '__main__':
            geoframe.mainloop()
コード例 #12
0
ファイル: geo_nemec.py プロジェクト: pyIPP/trgui
    def __init__(self, nshot, fmframe=None):

        if fmframe is None:
            if __name__ == '__main__':
                fmframe = tk.Tk()
                import trgui_style
            else:
                fmframe = tk.Toplevel()

            fmframe.geometry('1300x950')

# Widgets style


# Menu bar

        menubar  = tk.Menu(fmframe)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Run NEMEC", command=self.surf)
        filemenu.add_command(label="Store u-files", command=self.store_u)
        filemenu.add_separator()
        filemenu.add_command(label="Close", command=fmframe.destroy)
        menubar.add_cascade(label  = "File", menu=filemenu)
        fmframe.config(menu = menubar)

        canvframe = ttk.Frame(fmframe, height=850)
        entframe  = ttk.Frame(fmframe)
        self.toolframe = ttk.Frame(fmframe)
        for frame in canvframe, entframe, self.toolframe:
            frame.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.nbplot = ttk.Notebook(canvframe)
        self.nbplot.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.nbplot.bind('<Button-1>', self.on_click)

        pol_frame = ttk.Frame(self.nbplot)
        mom_frame = ttk.Frame(self.nbplot)
        profframe = ttk.Frame(self.nbplot)
        self.nbplot.add(pol_frame, text='Poloidal plot')
        self.nbplot.add(mom_frame, text='Fourier moments')
        self.nbplot.add(profframe, text='EQuilibrium profiles')

        self.proffig = Figure(figsize=(4., 8.), dpi=100)
        self.pol_fig = Figure(figsize=(6., 8.), dpi=100)
        self.mom_fig = Figure(figsize=(6., 8.), dpi=100)

        self.proffig.subplots_adjust(left=0.2,  bottom=0.1, right=0.8 , top=0.9)
        self.pol_fig.subplots_adjust(left=0.06, bottom=0.1, right=0.98, top=0.9)
        self.mom_fig.subplots_adjust(left=0.08, bottom=0.1, right=0.98, top=0.9)

        self.profcanvas = FigureCanvasTkAgg(self.proffig, master=profframe)
        self.pol_canvas = FigureCanvasTkAgg(self.pol_fig, master=pol_frame)
        self.mom_canvas = FigureCanvasTkAgg(self.mom_fig, master=mom_frame)

        self.profcanvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.pol_canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.mom_canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

#-----------------
# Initialise plots
#-----------------

        self.pol_fig.text(.5, .99, r'NEMEC equilibrium, constant $\rho$ and constant $\theta$ contours', \
                     ha='center', va='top')
        self.mom_fig.text(.5, .99, 'NEMEC Fourier moments', ha='center', va='top')

# Profiles

        fsize = 16

        self.qsub = self.proffig.add_subplot(311)
        self.qsub.set_xlim(0,1)
        self.qsub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.qsub.set_ylabel('q profile')

        self.psub = self.proffig.add_subplot(312)
        self.psub.set_xlim((0, 1))
        self.psub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.psub.set_ylabel('Pressure [Pa]')

        self.rbsub = self.proffig.add_subplot(313)
        self.rbsub.set_xlim(0,1)
        self.rbsub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.rbsub.set_ylabel('R*B$_\phi$')

#---------------
# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig     = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig    = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig  = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig = tk.PhotoImage(file='%s/backward.gif' %locdir)

        backward_button  = ttk.Button(self.toolframe, command=self.Backward,image=self.backwardfig)
        self.play_button = ttk.Button(self.toolframe, command=self.Play,    image=self.playfig)
        forward_button   = ttk.Button(self.toolframe, command=self.Forward, image=self.forwardfig)

        createToolTip(forward_button  , 'Go to next timestep')
        createToolTip(backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button, 'Forward animation/pause')

        for but in backward_button, self.play_button, forward_button:
            but.pack(side=tk.LEFT)

# Entry frame
        geoinit = {'shot': nshot, 'Nmom': 7, 'ntheta': 101, 'nrho': 81, \
                   'exp': 'AUGD', 'dia': 'EQH', 'ed': 0, \
                   'tbeg': 4, 'tend': 6., 'DeltaT': 0.1}

        self.geodict = {}

        for key in ('shot', 'tbeg', 'tend', 'DeltaT', \
                    'exp', 'dia', 'ed', \
                    'Nmom', 'ntheta', 'nrho'):
            raw = ttk.Frame(entframe)
            raw.pack(side=tk.TOP)
            lbl = ttk.Label(entframe, text=key, width=5).pack(side=tk.LEFT)
            var = ttk.Entry(entframe, width=5)
            var.insert(0, geoinit[key])
            var.pack(side=tk.LEFT, padx='2 7')
            self.geodict[key] = var

        self.psep = self.pol_fig.add_subplot(111, aspect='equal')
        self.psep.set_xlim((0.8, 3.0))
        self.psep.set_ylim((-1.4, 1.4))
        self.psep.set_xlabel('R [m]')
        self.psep.set_ylabel('z [m]')

        nshot_in = int(geoinit['shot'])
        gc_r, gc_z = map_equ_20180130.get_gc(nshot_in)
        for key in gc_r.keys():
            self.psep.plot(gc_r[key], gc_z[key], 'b-')

        toolbar = NavigationToolbar2TkAgg(self.pol_canvas, pol_frame)
        toolbar.update()
        toolbar = NavigationToolbar2TkAgg(self.mom_canvas, mom_frame)
        toolbar.update()
        toolbar = NavigationToolbar2TkAgg(self.profcanvas, profframe)
        toolbar.update()

        if __name__ == '__main__':
            fmframe.mainloop()
コード例 #13
0
ファイル: plater.py プロジェクト: jbernardis/plater
	def __init__(self, master, settings):
		self.master = master
		self.settings = settings
		Frame.__init__(self, master, relief=SUNKEN, bd=2)
		self.master.protocol('WM_DELETE_WINDOW', self.quitApp)
		self.objNumber = 1
		
		self.modified = False
		self.preview = True
		
		self.lbMap = []
		self.lbSelection = None
		
		self.stlFrame =  StlFrame(self, scale=settings.scale)
		self.stlFrame.grid(row=1, column=1, rowspan=4, sticky=N)
		self.lbFrame = LabelFrame(self, text=" File List ")
		self.lbFrame.grid(row=1, column=2, padx=5, pady=5, sticky=N)
		self.bFrame = Frame(self)
		self.bFrame.grid(row=2, column=2, padx=5, sticky=N)
		
		self.lbFiles = Listbox(self.lbFrame, width=60)
		self.lbFiles.grid(row=1,column=1,sticky=N+E+W+S)
		self.sbFiles = Scrollbar(self.lbFrame, command=self.lbFiles.yview, orient="vertical")
		self.sbFiles.grid(column=2, row=1, sticky=N+S+E)
		self.lbFiles.config(yscrollcommand=self.sbFiles.set)
		self.lbFiles.bind("<ButtonRelease>", self.doClickList)
		
		self.imgAdd = self.loadImage("add.gif")
		self.bAdd = Button(self.bFrame, image=self.imgAdd, width=48, height=48, command=self.doAdd)
		self.bAdd.grid(row=1, column=1, pady=2, padx=2, sticky=N)
		createToolTip(self.bAdd, "Add an STL file to the plate")

		self.imgClone = self.loadImage("clone.gif")		
		self.bClone = Button(self.bFrame, image=self.imgClone, width=48, height=48, command=self.doClone, state=DISABLED)
		self.bClone.grid(row=1, column=2, pady=2, padx=2, sticky=N)
		createToolTip(self.bClone, "Clone the selected object")
		
		self.imgDel = self.loadImage("del.gif")
		self.bDel = Button(self.bFrame, image=self.imgDel, width=48, height=48, command=self.doDelete, state=DISABLED)
		self.bDel.grid(row=1, column=3, pady=2, padx=2, sticky=N)
		createToolTip(self.bDel, "Delete the selected object")
		
		self.imgDelAll = self.loadImage("delall.gif")
		self.bDelAll = Button(self.bFrame, image=self.imgDelAll, width=48, height=48, command=self.doDelAll, state=DISABLED)
		self.bDelAll.grid(row=1, column=4, pady=2, padx=2, sticky=N)
		createToolTip(self.bDelAll, "Delete all objects from the plate")
		
		self.imgArrange = self.loadImage("arrange.gif")
		self.bArrange = Button(self.bFrame, image=self.imgArrange, width=48, height=48, command=self.doArrange, state=DISABLED)
		self.bArrange.grid(row=2, column=1, pady=2, padx=2, sticky=N)
		createToolTip(self.bArrange, "Arrange the objects to fit")
		
		self.imgExport = self.loadImage("export.gif")
		self.bExport = Button(self.bFrame, image=self.imgExport, width=48, height=48, command=self.doExport, state=DISABLED)
		self.bExport.grid(row=2, column=4, pady=2, padx=2, sticky=N)
		createToolTip(self.bExport, "Save the plate to an STL file")
		
		self.cbPrev = IntVar()
		if self.settings.preview:
			self.cbPrev.set(1)
		else:
			self.cbPrev.set(0)
			
		self.cbPreview = Checkbutton(
            self.bFrame, text="Preview",
            variable=self.cbPrev,
            command=self.doCbPreview)
		self.cbPreview.grid(row=3, column=2, pady=5)
コード例 #14
0
ファイル: bunnysuite_gui.py プロジェクト: LiXiling/bunnysuite
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85' 
        _ana2color = '#d9d9d9' # X11 color: 'gray85' 
        self.style = ttk.Style()
        #if sys.platform == "win32":
        #    self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font="TkDefaultFont")
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("450x690+755+34")
        top.title("Bunnysuite 1.0")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")


        ### Framework selection ###

        self.frameworksFrame = ttk.Frame(top)
        self.frameworksFrame.place(relx=0.04, rely=0.03, relheight=0.2
                , relwidth=0.92)
        self.frameworksFrame.configure(relief=GROOVE,
                                       borderwidth="2",
                                       width=405)

        self.frameworksLabel = ttk.Label(self.frameworksFrame)
        self.frameworksLabel.place(relx=0.02, rely=0.05, height=19, width=86)
        self.frameworksLabel.configure(background=_bgcolor,
                                       foreground="#000000",
                                       relief=FLAT,
                                       text='''Frameworks''')

        self.possibleFrameworksLabel = ttk.Label(self.frameworksFrame)
        self.possibleFrameworksLabel.place(relx=0.02, rely=0.2, height=19
                , width=56)
        self.possibleFrameworksLabel.configure(background=_bgcolor,
                                               foreground="#000000",
                                               relief=FLAT,
                                               text='''possible''')
                                               
        self.possibleFrameworksList = ScrolledListBox(self.frameworksFrame)
        self.possibleFrameworksList.place(relx=0.02, rely=0.37, relheight=0.56
                , relwidth=0.4)
        self.possibleFrameworksList.configure(background="white",
                                              disabledforeground="#a3a3a3",
                                              font="TkFixedFont",
                                              foreground="black",
                                              highlightbackground="#d9d9d9",
                                              highlightcolor="#d9d9d9",
                                              selectbackground="#c4c4c4",
                                              selectforeground="black",
                                              selectmode=EXTENDED,
                                              width=10)

        self.chosenFrameworksLabel = ttk.Label(self.frameworksFrame)
        self.chosenFrameworksLabel.place(relx=0.59, rely=0.22, height=19
                , width=56)
        self.chosenFrameworksLabel.configure(background=_bgcolor,
                                             foreground="#000000",
                                             relief=FLAT,
                                             text='''chosen''')

        self.chosenFrameworksList = ScrolledListBox(self.frameworksFrame)
        self.chosenFrameworksList.place(relx=0.57, rely=0.37, relheight=0.56
                , relwidth=0.4)
        self.chosenFrameworksList.configure(background="white",
                                            disabledforeground="#a3a3a3",
                                            font="TkFixedFont",
                                            foreground="black",
                                            highlightbackground="#d9d9d9",
                                            highlightcolor="#d9d9d9",
                                            selectbackground="#c4c4c4",
                                            selectforeground="black",
                                            selectmode=EXTENDED,
                                            width=10)

        self.chooseButton = ttk.Button(self.frameworksFrame)
        self.chooseButton.place(relx=0.46, rely=0.44, height=25, width=24)
        self.chooseButton.configure(command=gui_support.cmdChoose,
                                    text='''>''')
        tooltip.createToolTip(self.chooseButton, "include selected frameworks in the test")

        self.unchooseButton = ttk.Button(self.frameworksFrame)
        self.unchooseButton.place(relx=0.46, rely=0.67, height=25, width=24)
        self.unchooseButton.configure(command=gui_support.cmdUnchoose,
                                      text='''<''')
        tooltip.createToolTip(self.unchooseButton, "exclude selected frameworks from the test")

                                             
        ### Modifier selection ###
                                             
        self.modifierFrame = ttk.Frame(top)
        self.modifierFrame.place(relx=0.04, rely=0.25, relheight=0.3
                , relwidth=0.92)
        self.modifierFrame.configure(borderwidth="2",
                                     relief=GROOVE,
                                     width=425)

        self.modifiersLabel = ttk.Label(self.modifierFrame)
        self.modifiersLabel.place(relx=0.34, rely=0.03, height=19, width=79)
        self.modifiersLabel.configure(background=_bgcolor,
                                      foreground="#000000",
                                      relief=FLAT,
                                      text='''Test modifiers''')
                                      
        self.style.map('TCheckbutton',background=
            [('selected', _bgcolor), ('active',_ana2color)])
        self.checkAnimation = ttk.Checkbutton(self.modifierFrame)
        self.checkAnimation.place(relx=0.34, rely=0.15, relwidth=0.21
                , relheight=0.0, height=21)
        self.checkAnimation.configure(variable=gui_support.animation,
                                      onvalue="animation",
                                      offvalue="",
                                      text='''animation''')
        tooltip.createToolTip(self.checkAnimation, "Each bunny is initialized with a random speed value in X and Y direction. Once a bunny reaches the border of the screen, its direction is reversed. It is also affected by gravity. Both X and Y speed have a max value. With each frame the position of each bunny is updated according to its speed. This gives the illusion of a jumping animation.")

        self.checkScaled = ttk.Checkbutton(self.modifierFrame)
        self.checkScaled.place(relx=0.34, rely=0.55, relwidth=0.19, relheight=0.0
                , height=21)
        self.checkScaled.configure(variable=gui_support.scaled,
                                   onvalue="scaled",
                                   offvalue="",
                                   text='''scaled''')
        tooltip.createToolTip(self.checkScaled, "Bunnies are initialized with scaled width and height, each by a random value between 0.2 and 5.")
        
        self.checkRandom = ttk.Checkbutton(self.modifierFrame)
        self.checkRandom.place(relx=0.34, rely=0.35, relwidth=0.21, relheight=0.0
                , height=21)
        self.checkRandom.configure(variable=gui_support.random,
                                   onvalue="random",
                                   offvalue="",
                                   text='''random''')
        tooltip.createToolTip(self.checkRandom, "Bunnies are initialized with a random position.")

        self.checkRotation = ttk.Checkbutton(self.modifierFrame)
        self.checkRotation.place(relx=0.34, rely=0.25, relwidth=0.2
                , relheight=0.0, height=21)
        self.checkRotation.configure(variable=gui_support.rotation,
                                    onvalue="rotation",
                                    offvalue="",
                                    text='''rotation''')
        tooltip.createToolTip(self.checkRotation, "Bunnies rotate clockwise by 1 degree each frame.")

        self.checkMultitexture = ttk.Checkbutton(self.modifierFrame)
        self.checkMultitexture.place(relx=0.66, rely=0.15, relwidth=0.24,
                                     relheight=0.0, height=21)
        self.checkMultitexture.configure(variable=gui_support.multitexture,
                                         onvalue="multitexture",
                                         offvalue="",
                                         text='''multitexture''')
        tooltip.createToolTip(self.checkMultitexture, "Adds two different colored bunnies to the texture pool.")

        self.checkTexturechange = ttk.Checkbutton(self.modifierFrame)
        self.checkTexturechange.place(relx=0.66, rely=0.55, relwidth=0.26
                , relheight=0.0, height=21)
        self.checkTexturechange.configure(variable=gui_support.texturechange,
                                          onvalue="texturechange",
                                          offvalue="",
                                          text='''texturechange''')
        tooltip.createToolTip(self.checkTexturechange, "With each frame each bunny changes its texture randomly to one of the available textures.")                                 

        self.checkAlpha = ttk.Checkbutton(self.modifierFrame)
        self.checkAlpha.place(relx=0.66, rely=0.25, relwidth=0.2, relheight=0.0
                , height=21)
        self.checkAlpha.configure(variable=gui_support.alpha,
                                  onvalue="alpha",
                                  offvalue="",
                                  text='''alpha''')
        tooltip.createToolTip(self.checkAlpha, "Adds texture with lots of alpha values to the texture pool.")

        self.checkHd = ttk.Checkbutton(self.modifierFrame)
        self.checkHd.place(relx=0.66, rely=0.35, relwidth=0.2, relheight=0.0
                , height=21)
        self.checkHd.configure(variable=gui_support.hdtexture,
                               onvalue="hdtexture",
                               offvalue="",
                               text='''hdtexture''')
        tooltip.createToolTip(self.checkHd, "Adds high resolution texture to the texture pool. The texture is downscaled before rendering.")


        self.checkTeleport = ttk.Checkbutton(self.modifierFrame)
        self.checkTeleport.place(relx=0.34, rely=0.45, relwidth=0.2
                , relheight=0.0, height=21)
        self.checkTeleport.configure(variable=gui_support.teleport)
        self.checkTeleport.configure(onvalue="teleport",
                                     offvalue="",
                                     text='''teleport''')
        tooltip.createToolTip(self.checkTeleport, "Bunnies are drawn each frame at a new, random position.")

        self.checkPulsation = ttk.Checkbutton(self.modifierFrame)
        self.checkPulsation.place(relx=0.34, rely=0.65, relwidth=0.2
                , relheight=0.0, height=21)
        self.checkPulsation.configure(variable=gui_support.pulsation,
                                      onvalue="pulsation",
                                      offvalue="",
                                      text='''pulsation''')
        tooltip.createToolTip(self.checkPulsation, "With each frame, the scale of each bunny is changed (initial growth +0.1). Once the scale >=5 or <=0.2, the growth rate is multiplied by -1.")

                                      
        self.checkTinted = ttk.Checkbutton(self.modifierFrame)
        self.checkTinted.place(relx=0.34, rely=0.75, relwidth=0.16, relheight=0.0
                , height=21)
        self.checkTinted.configure(variable=gui_support.tinted,
                                   onvalue="tinted",
                                   offvalue="",
                                   text='''tinted''',
                                   width=64)
        tooltip.createToolTip(self.checkTinted, "Each bunny is initialized with its texture tinted in a random non transparent color.") 
              
        self.checkColorchange = ttk.Checkbutton(self.modifierFrame)
        self.checkColorchange.place(relx=0.34, rely=0.85, relwidth=0.25
                , relheight=0.0, height=21)
        self.checkColorchange.configure(variable=gui_support.colorchange,
                                        onvalue="colorchange",
                                        offvalue="",
                                        text='''colorchange''',
                                        width=101)
        tooltip.createToolTip(self.checkColorchange, "Each frame each bunny is tinted in a new random color.") 
       

        self.checkThin = ttk.Checkbutton(self.modifierFrame)
        self.checkThin.place(relx=0.66, rely=0.45, relwidth=0.16, relheight=0.0
                , height=21)
        self.checkThin.configure(variable=gui_support.thin,
                                 onvalue="thin",
                                 offvalue="",
                                 text='''thin''')
        tooltip.createToolTip(self.checkThin, "Adds an alternative bunny texture to the texture pool.")

        self.checkBunnies = ttk.Checkbutton(self.modifierFrame)
        self.checkBunnies.place(relx=0.02, rely=0.15, relwidth=0.21
                , relheight=0.0, height=21)
        self.checkBunnies.configure(state=DISABLED,
                                    variable=gui_support.bunnies,
                                    command=gui_support.cmdUpdateTextureModifiers,
                                    onvalue="bunnies",
                                    offvalue="",
                                    text='''bunnies''')
        tooltip.createToolTip(self.checkBunnies, "Draws bunnies.")

        self.checkRectangles = ttk.Checkbutton(self.modifierFrame)
        self.checkRectangles.place(relx=0.02, rely=0.25, relwidth=0.24
                , relheight=0.0, height=21)
        self.checkRectangles.configure(variable=gui_support.rectangles,
                                       command=gui_support.cmdUpdateBunniesCheckbox,
                                       onvalue="rectangles",
                                       offvalue="",
                                       text='''rectangles''')
        tooltip.createToolTip(self.checkRectangles, "Draws rectangles of size 26 * 37.")

        self.checkCircles = ttk.Checkbutton(self.modifierFrame)
        self.checkCircles.place(relx=0.02, rely=0.35, relwidth=0.19
                , relheight=0.0, height=21)
        self.checkCircles.configure(variable=gui_support.circles,
                                    command=gui_support.cmdUpdateBunniesCheckbox,
                                    onvalue="circles",
                                    offvalue="",
                                    text='''circles''')
        tooltip.createToolTip(self.checkCircles, "Draws circles of random color with radius 13. Not affected by rotation (duh).")

        self.checkTriangles = ttk.Checkbutton(self.modifierFrame)
        self.checkTriangles.place(relx=0.02, rely=0.45, relwidth=0.21
                , relheight=0.0, height=21)
        self.checkTriangles.configure(variable=gui_support.triangles,                                      
                                      command=gui_support.cmdUpdateBunniesCheckbox,
                                      onvalue="triangles",
                                      offvalue="",
                                      text='''triangles''')
        tooltip.createToolTip(self.checkTriangles, "Draws triangles of random color.")

        self.checkLines = ttk.Checkbutton(self.modifierFrame)
        self.checkLines.place(relx=0.02, rely=0.55, relwidth=0.16, relheight=0.0
                , height=21)
        self.checkLines.configure(variable=gui_support.lines,
                                  command=gui_support.cmdUpdateBunniesCheckbox,
                                  onvalue="lines",
                                  offvalue="",
                                  text='''lines''')
        tooltip.createToolTip(self.checkLines, "Draws lines of random color.")

        self.checkPoints = ttk.Checkbutton(self.modifierFrame)
        self.checkPoints.place(relx=0.02, rely=0.65, relwidth=0.21
                , relheight=0.0, height=21)
        self.checkPoints.configure(variable=gui_support.points,
                                      command=gui_support.cmdUpdateBunniesCheckbox,
                                      onvalue="points",
                                      offvalue="",
                                      text='''points''')
        tooltip.createToolTip(self.checkPoints, "Draws points (single pixels) of random color. Not affected by rotation and scale (duh).")

        self.checkTexts = ttk.Checkbutton(self.modifierFrame)
        self.checkTexts.place(relx=0.02, rely=0.75, relwidth=0.16, relheight=0.0
                , height=21)
        self.checkTexts.configure(variable=gui_support.texts,
                                  command=gui_support.cmdUpdateBunniesCheckbox,
                                  onvalue="texts",
                                  offvalue="",
                                  text='''texts''')
        tooltip.createToolTip(self.checkTexts, "Draws 'Hello World!'. Not affected by rotation and scale.")

        self.textureLabel = ttk.Label(self.modifierFrame)
        self.textureLabel.place(relx=0.66, rely=0.03, height=19, width=116)
        self.textureLabel.configure(background=_bgcolor,
                                    foreground="#000000",
                                    relief=FLAT,
                                    text='''Texture modifiers''')

        self.flavoursLabel = ttk.Label(self.modifierFrame)
        self.flavoursLabel.place(relx=0.02, rely=0.03, height=19, width=116)
        self.flavoursLabel.configure(background=_bgcolor,
                                     foreground="#000000",
                                     relief=FLAT,
                                     text='''Flavour modifiers''')

        self.checkNoOutput = ttk.Checkbutton(self.modifierFrame)
        self.checkNoOutput.place(relx=0.66, rely=0.85, relwidth=0.26
                , relheight=0.0, height=21)
        self.checkNoOutput.configure(variable=gui_support.no_output,
                                          onvalue="no_output",
                                          offvalue="",
                                          text='''no_output''')
        tooltip.createToolTip(self.checkNoOutput, "Disables drawing. All calculations are still done, allowing to estimate the influence of the CPU on the result.")
                                          

        ### Arguments selection ###

        self.argumentsFrame = ttk.Frame(top)
        self.argumentsFrame.place(relx=0.04, rely=0.57, relheight=0.25
                , relwidth=0.92)
        self.argumentsFrame.configure(borderwidth="2",
                                      relief=GROOVE,
                                      width=425)
        
        self.minBunniesLabel = ttk.Label(self.argumentsFrame)
        self.minBunniesLabel.place(relx=0.02, rely=0.06, height=19, width=90)
        self.minBunniesLabel.configure(background=_bgcolor,
                                       foreground="#000000",
                                       relief=FLAT,
                                       text='''min bunnies''')
        tooltip.createToolTip(self.minBunniesLabel, "the amount of bunnies the test starts with")
        
        self.minBunniesScale = ttk.Scale(self.argumentsFrame)
        self.minBunniesScale.place(relx=0.29, rely=0.06, relwidth=0.38
                , relheight=0.0, height=26)
        self.minBunniesScale.configure(command=gui_support.cmdMinBunnies,
                                       variable=gui_support.minBunnies,
                                       to="100000",
                                       length="150")
        
        self.minBunniesEntry = ttk.Entry(self.argumentsFrame)
        self.minBunniesEntry.place(relx=0.76, rely=0.07, relheight=0.14
                , relwidth=0.21)
        self.minBunniesEntry.configure(textvariable=gui_support.minBunniesEntry,
                                       validate="all",
                                       validatecommand=(root.register(gui_support.validateMinBunnies), '%P', '%V'),
                                       width=86,
                                       cursor="xterm")
        
        self.maxBunniesLabel = ttk.Label(self.argumentsFrame)
        self.maxBunniesLabel.place(relx=0.02, rely=0.23, height=19, width=86)
        self.maxBunniesLabel.configure(background=_bgcolor,
                                       foreground="#000000",
                                       relief=FLAT,
                                       text='''max bunnies''')
        tooltip.createToolTip(self.maxBunniesLabel, "the amount of bunnies at which the test terminates")

        self.maxBunniesScale = ttk.Scale(self.argumentsFrame)
        self.maxBunniesScale.place(relx=0.29, rely=0.23, relwidth=0.38
                , relheight=0.0, height=26)
        self.maxBunniesScale.configure(command=gui_support.cmdMaxBunnies,
                                       variable=gui_support.maxBunnies,
                                       to="100000",
                                       value="20000",
                                       length="150")
        
        self.maxBunniesEntry = ttk.Entry(self.argumentsFrame)
        self.maxBunniesEntry.place(relx=0.76, rely=0.24, relheight=0.14
                , relwidth=0.21)
        self.maxBunniesEntry.configure(textvariable=gui_support.maxBunniesEntry,
                                       validate="all",
                                       validatecommand=(root.register(gui_support.validateMaxBunnies), '%P', '%V'),
                                       width=86,
                                       cursor="xterm")

        self.stepSizeLabel = ttk.Label(self.argumentsFrame)
        self.stepSizeLabel.place(relx=0.02, rely=0.4, height=19, width=56)
        self.stepSizeLabel.configure(background=_bgcolor,
                                     foreground="#000000",
                                     relief=FLAT,
                                     text='''step size''')
        tooltip.createToolTip(self.stepSizeLabel, "the amount of bunnies that is added each step")
        
        self.stepSizeScale = ttk.Scale(self.argumentsFrame)
        self.stepSizeScale.place(relx=0.29, rely=0.4, relwidth=0.38
                , relheight=0.0, height=26)
        self.stepSizeScale.configure(command=gui_support.cmdStepSize,
                                     variable=gui_support.stepSize,
                                     from_="1",
                                     to="10000",
                                     value="1000",
                                     length="150")
        
        self.stepSizeEntry = ttk.Entry(self.argumentsFrame)
        self.stepSizeEntry.place(relx=0.76, rely=0.41, relheight=0.14
                , relwidth=0.21)
        self.stepSizeEntry.configure(textvariable=gui_support.stepSizeEntry,
                                     validate="all",
                                     validatecommand=(root.register(gui_support.validateStepSize), '%P', '%V'),
                                     width=86,
                                     cursor="xterm")
                                     
        self.repetitionsLabel = ttk.Label(self.argumentsFrame)
        self.repetitionsLabel.place(relx=0.02, rely=0.57, height=19, width=60)
        self.repetitionsLabel.configure(background=_bgcolor,
                                        foreground="#000000",
                                        relief=FLAT,
                                        text='''repetitions''')
        tooltip.createToolTip(self.maxBunniesLabel, "the amount of times each step is repeated before new bunnies are added (the render time is still measured for each frame and averaged at the end of the step)")

        self.repetitionsScale = ttk.Scale(self.argumentsFrame)
        self.repetitionsScale.place(relx=0.29, rely=0.57, relwidth=0.38
                , relheight=0.0, height=26)
        self.repetitionsScale.configure(command=gui_support.cmdRepetitions,
                                        variable=gui_support.repetitions,
                                        from_="1",                                        
                                        to="100",
                                        value="10",
                                        length="150")

        self.repetitionsEntry = ttk.Entry(self.argumentsFrame)
        self.repetitionsEntry.place(relx=0.76, rely=0.58, relheight=0.12
                , relwidth=0.21)
        self.repetitionsEntry.configure(textvariable=gui_support.repetitionsEntry,
                                        validate="all",
                                        validatecommand=(root.register(gui_support.validateRepetitions), '%P', '%V'),
                                        width=86,
                                        cursor="xterm")

        self.resolutionLabel = ttk.Label(self.argumentsFrame)
        self.resolutionLabel.place(relx=0.02, rely=0.8, height=19, width=77)
        self.resolutionLabel.configure(background=_bgcolor,
                                       foreground="#000000",
                                       relief=FLAT,
                                       text='''resolution''',
                                       width=77)

        self.resCombobox = ttk.Combobox(self.argumentsFrame)
        self.resCombobox.place(relx=0.29, rely=0.8, relheight=0.14
                , relwidth=0.68)
        self.resCombobox.configure(textvariable=gui_support.resolution,
                                   background="#000000",
                                   state="readonly",
                                   values=["640x480","800x600","1280x720","1680x1050","1920x1080"])


        ### Presets selection ###

        self.presetsFrame = ttk.Frame(top)
        self.presetsFrame.place(relx=0.04, rely=0.84, relheight=0.08
                , relwidth=0.92)
        self.presetsFrame.configure(relief=GROOVE,
                                    borderwidth="2",
                                    width=425)

        self.presetsCheckbox = ttk.Checkbutton(self.presetsFrame)
        self.presetsCheckbox.place(relx=0.02, rely=0.31, relwidth=0.2
                , relheight=0.0, height=21)
        self.presetsCheckbox.configure(variable=gui_support.presets,
                                       command=gui_support.cmdTogglePresets,
                                       text='''Use presets''')

        self.presetsCombobox = ttk.Combobox(self.presetsFrame)
        self.presetsCombobox.place(relx=0.29, rely=0.30, relheight=0.40
                , relwidth=0.38)
        self.presetsCombobox.configure(state=DISABLED,
                                       textvariable=gui_support.presetsCombobox,
                                       width=153,
                                       validate="key",
                                       validatecommand=(root.register(gui_support.validatePreset), '%P'),
                                       postcommand=gui_support.updatePresets)
        self.presetsCombobox.bind("<<ComboboxSelected>>", gui_support.presetSelection)

        self.saveButton = ttk.Button(self.presetsFrame)
        self.saveButton.place(relx=0.76, rely=0.27, height=25, width=86)
        self.saveButton.configure(command=gui_support.cmdSave,
                                  text='''Save''',
                                  state=DISABLED)
                                             
                                             
                                             
        self.runButton = ttk.Button(top)
        self.runButton.place(relx=0.38, rely=0.94, height=25, width=116)
        self.runButton.configure(command=gui_support.cmdRun,
                                 text='''Run''')
コード例 #15
0
ファイル: vprof.py プロジェクト: pyIPP/trgui
    def __init__(self, opt_d, rdd, myframe=None, method='rec_spl', n_spl=51):


        self.method = method

        self.ext_str = ''
        for diag_sig in sorted(opt_d.keys()):
            diag = diag_sig.split(':')[0]
            self.ext_str += diag

# Choosing last diag's info for plotting
        self.exp     = opt_d[diag_sig]['exp' ]
        self.diag    = opt_d[diag_sig]['diag']
        self.sig     = opt_d[diag_sig]['sig']
        self.eq_exp  = opt_d[diag_sig]['Map_exp' ]
        self.eq_diag = opt_d[diag_sig]['Map_diag']
        self.nshot = int(opt_d[diag_sig]['shot'])
        self.ed    = int( opt_d[diag_sig]['ed'] )
        self.eq_ed = int( opt_d[diag_sig]['Map_ed'] )
        self.tbeg  = float(opt_d[diag_sig]['tbeg' ] )
        self.tend  = float(opt_d[diag_sig]['tend' ] )

        self.ylab  = '%s %s' %(self.diag, self.sig)
        self.xlab  = r'$\rho_{pol}$'

# Combine diagnostics

        for diag_sig in rdd.keys():
            if not hasattr(self, 'xexp'):
                self.xexp = np.array(rdd[diag_sig]['rhop'])
                self.yexp = np.array(rdd[diag_sig]['data'])
                self.yerr = np.array(rdd[diag_sig]['data_err'])
            else:
                self.xexp = np.append(self.xexp, rdd[diag_sig]['rhop']    , axis=1)
                self.yexp = np.append(self.yexp, rdd[diag_sig]['data']    , axis=1)
                self.yerr = np.append(self.yerr, rdd[diag_sig]['data_err'], axis=1)

        ind_sort = np.argsort(self.xexp, axis=1)
        for jt in range(self.xexp.shape[0]):
            self.xexp[jt,:] = self.xexp[jt, ind_sort[jt]]
            self.yexp[jt,:] = self.yexp[jt, ind_sort[jt]]
            self.yerr[jt,:] = self.yerr[jt, ind_sort[jt]]

        self.tgrid = rdd[diag_sig]['tgrid']

        self.jt = 0
        self.nt = len(self.tgrid)

        self.nR = n_spl
        self.rho_out = np.linspace(0, 1, n_spl)
        self.R_out = np.linspace(1.05, 2.25, self.nR)
        self.rho12_out = np.linspace(0, 1.2, n_spl)

# Frame structure

        if myframe is None:
            myframe = tk.Toplevel()
            myframe.geometry('1200x740')
            myframe.title('View and fit profiles, method %s' %self.method)

        figframe  = ttk.Frame(myframe)
        entframe  = ttk.Frame(myframe)
        rbframe   = ttk.Frame(myframe)
        btframe   = ttk.Frame(myframe)
        lblframe  = ttk.Frame(myframe)
        toolframe = ttk.Frame(myframe)
        for box in (figframe, toolframe, entframe, \
                    rbframe, btframe, lblframe):
            box.pack(side=tk.TOP, fill=tk.X)

        figframe3 = ttk.Frame(figframe)
        figframe2 = ttk.Frame(figframe)
        for box in (figframe3, figframe2):
            box.pack(side=tk.LEFT, fill=tk.X)

        figframe1 = ttk.Frame(figframe3)
        entfframe = ttk.Frame(figframe3)
        for box in (figframe1, entfframe):
            box.pack(side=tk.TOP, fill=tk.X)

        self.nb2d = ttk.Notebook(figframe2)
        self.nb2d.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        frame2d = ttk.Frame(self.nb2d)
        ctframe = ttk.Frame(self.nb2d)
        self.nb2d.add(frame2d, text='Wired plot')
        self.nb2d.add(ctframe, text='Contour plot')

# Plot settings

        fig1d = Figure(figsize=(5.6, 4.9), dpi=100)
        self.fig2d = Figure(figsize=(6.2, 5.1), dpi=100)
        self.figct = Figure(figsize=(6.2, 5.1), dpi=100)

        self.can_1d = FigureCanvasTkAgg(fig1d, master=figframe1)
        self.can_2d = FigureCanvasTkAgg(self.fig2d, master=frame2d)
        self.can_ct = FigureCanvasTkAgg(self.figct, master=ctframe)
        self.can_1d._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.can_2d._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.can_ct._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        toolbar = NavigationToolbar2TkAgg( self.can_1d, toolframe)
        toolbar.update()

        self.ax1d = fig1d.add_subplot(1, 1, 1)
        fig1d.subplots_adjust(left=0.15, bottom=0.16, right=0.95, top=0.9)

        self.ylab  = '%s %s' %(self.diag, self.sig)
        self.rho_lab  = r'$\rho_{pol}$'
        self.ax1d.set_xlim([0, 1.1])
        self.ax1d.set_xlabel(self.rho_lab, fontsize=fsize)
        self.ax1d.set_ylabel(self.ylab   , fontsize=fsize)

        self.ok, self.caplines, self.barlinecols = \
            self.ax1d.errorbar(0, 0, 0, fmt='g.')
        self.rej,    = self.ax1d.plot([], [], 'ro')
        self.del_pt, = self.ax1d.plot([], [], 'bo')
        self.pfit,   = self.ax1d.plot([], [], 'm-')
        self.sep_line, = self.ax1d.plot([1, 1], [0, 1], 'k--')

# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig  = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig    = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig   = tk.PhotoImage(file='%s/backward.gif' %locdir)

        self.backward_button = ttk.Button(entfframe, command=self.Backward, image=self.backwardfig)
        self.play_button     = ttk.Button(entfframe, command=self.Play,     image=self.playfig)
        self.forward_button  = ttk.Button(entfframe, command=self.Forward,  image=self.forwardfig)

        createToolTip(self.forward_button  , 'Go to next timestep')
        createToolTip(self.backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button     , 'Forward animation/pause')

        sliderax = fig1d.add_axes([0.2, 0.02, 0.6, 0.03], axisbg='yellow')
        self.sl_time = Slider(sliderax,'Time:', 0., 1., valinit=0.)
        self.sl_time.valtext.set_text('0.0000')

        def update_time(val):
            self.update_plot(val=val)

        self.sl_time.on_changed(update_time)
        fig1d.canvas.mpl_connect('button_press_event', self.MouseInteraction)
        fig1d.canvas.mpl_connect('key_press_event'   , self.on_key)
        fig1d.canvas.mpl_connect('key_release_event' , self.off_key)
        fig1d.canvas.mpl_connect('button_press_event', lambda event:fig1d.canvas._tkcanvas.focus_set())

        for but in self.backward_button, self.play_button, self.forward_button:
            but.pack(side=tk.LEFT)

# Fit entries

        sigma_init = 1
        if self.diag in ['IDA']:
            erbar_init = 0.
        else:
           erbar_init = .3

        ttk.Label(entframe, text='Fit tolerance', width=11).pack(side=tk.LEFT, padx=2)
        self.cfit_val = ttk.Entry(entframe, width=8)
        self.cfit_val.insert(0, erbar_init)
        self.cfit_val.pack(side=tk.LEFT)

        if self.method == 'rec_spl':
            ttk.Label(entframe, text='# sigmas').pack(side=tk.LEFT, padx='10 2')
            self.sigma_val = ttk.Entry(entframe, width=8)
            self.sigma_val.insert(0, sigma_init)
            self.sigma_val.pack(side=tk.LEFT)

        ttk.Label(rbframe, text='U-file coord', width=11).pack(side=tk.LEFT, padx=2)
        self.rho_event = tk.StringVar()
        self.rho_event.set('rho_tor')
        for val in ('rho_pol', 'rho_pol12', 'rho_tor', 'R_hor'):
            ttk.Radiobutton(rbframe, variable=self.rho_event, value=val, text=val).pack(side=tk.LEFT)

        btfit = ttk.Button(btframe, text='Fit', command=self.fit)
        btfit.pack(side=tk.LEFT, padx=2)

        lblframe1 = ttk.Frame(lblframe)
        lblframe2 = ttk.Frame(lblframe)
        lblframe1.pack(side=tk.LEFT)
        lblframe2.pack(side=tk.RIGHT)

        scat_help  = tk.Label(lblframe1, text='Left plot, scatter points:')
        scat_blue  = tk.Label(lblframe1, text='Blue: hand-deleted', fg='blue')
        scat_red   = tk.Label(lblframe1, text='Red: rejected by spline', fg='red')
        scat_green = tk.Label(lblframe1, text='Green: valid points', fg='#00a000')
        for w in (scat_help, scat_blue, scat_red, scat_green):
            w.pack(side=tk.TOP, anchor=tk.W)

        del_lb  = ttk.Label(lblframe2, text='Mouse-L: deletes points')
        del_all = ttk.Label(lblframe2, text='Ctrl+Mouse-L: deletes frame')
        undolb  = ttk.Label(lblframe2, text='Mouse-Mid: un-delete points for this frame')
        righlb  = ttk.Label(lblframe2, text='Mouse-R: move to next frame plot')
        for w in (del_lb, del_all, undolb, righlb):
            w.pack(side=tk.TOP, anchor=tk.W)

# Create GUI

        self.update_plot1d()
        self.stop  = True
        self.ctrl  = False
コード例 #16
0
ファイル: gui.py プロジェクト: JeromePrevotat/ProjectM
    def init_gui(self):
        self.win.title(self.i18n.title)
        self.win.lift()
        #Forces the win window to be on Foreground
        self.win.attributes('-topmost', True)
        #Allows the win window to pass Backgroud after idle
        self.win.after_idle(self.win.attributes, '-topmost', False)

        #TAB PANNELS
        self.tabControl = ttk.Notebook(self.win)
        self.tabControl.pack(expand=1, fill="both")

        self.tab1 = ttk.Frame(self.tabControl)
        self.tabControl.add(self.tab1, text='MySQL')
        self.tab2 = ttk.Frame(self.tabControl)
        self.tabControl.add(self.tab2, text=self.i18n.WIDGET_LABEL)

        #MySQL TAB
        #MAIN FRAMES
        self.pydb = ttk.LabelFrame(self.tab1, text='Python Database')
        self.pydb.rowconfigure(0, weight=1)
        self.pydb.columnconfigure(0, weight=1)
        self.pydb.grid(row=0, column=0, padx=8, pady=4)

        self.book_quote = ttk.LabelFrame(self.tab1, text='Book Quotations')
        self.book_quote.rowconfigure(1, weight=1)
        self.book_quote.columnconfigure(0, weight=1)
        self.book_quote.grid(row=1, column=0, padx=8, pady=4, sticky='WE')

        #LABELS
        ttk.Label(self.pydb, text='Book Title :').grid(row=0,
                                                       column=0,
                                                       sticky='W')
        ttk.Label(self.pydb, text='Page :').grid(row=0, column=1, sticky='W')

        #BUTTONS
        self.insert_button = ttk.Button(self.pydb,
                                        text='Insert Quote',
                                        command=self.callbacks.insertQuote,
                                        width=15)
        self.insert_button.grid(row=1, column=2, sticky='NSWE')
        self.get_button = ttk.Button(self.pydb,
                                     text='Get Quote',
                                     command=self.callbacks.getQuote,
                                     width=15)
        self.get_button.grid(row=2, column=2, sticky='NSWE')
        self.modify_button = ttk.Button(self.pydb,
                                        text='Modify Quote',
                                        command=self.callbacks.click_me,
                                        width=15)
        self.modify_button.grid(row=3, column=2, sticky='NSWE')

        #ENTRY
        #TITLE ENTRY
        self.insert_title = tk.StringVar()
        self.insert_title_entry = ttk.Entry(self.pydb,
                                            width=35,
                                            textvariable=self.insert_title)
        self.insert_title_entry.grid(row=1, column=0, sticky='W')
        self.insert_title_entry.delete(0, tk.END)
        self.insert_title_entry.insert(0, '< Enter a Title >')

        self.get_title = tk.StringVar()
        self.get_title_entry = ttk.Entry(self.pydb,
                                         width=35,
                                         textvariable=self.get_title)
        self.get_title_entry.grid(row=2, column=0, sticky='W')
        self.get_title_entry.delete(0, tk.END)
        self.get_title_entry.insert(0, '< Enter a Title >')

        self.modify_title = tk.StringVar()
        self.modify_title_entry = ttk.Entry(self.pydb,
                                            width=35,
                                            textvariable=self.modify_title)
        self.modify_title_entry.grid(row=3, column=0, sticky='W')
        self.modify_title_entry.delete(0, tk.END)
        self.modify_title_entry.insert(0, '< Enter a Title >')

        #PAGE ENTRY
        self.insert_page = tk.StringVar()
        self.insert_page_entry = ttk.Entry(self.pydb,
                                           width=10,
                                           textvariable=self.insert_page)
        self.insert_page_entry.grid(row=1, column=1, sticky='W')
        self.insert_page_entry.delete(0, tk.END)
        self.insert_page_entry.insert(0, '< N° Page >')

        self.get_page = tk.StringVar()
        self.get_page_entry = ttk.Entry(self.pydb,
                                        width=10,
                                        textvariable=self.get_page)
        self.get_page_entry.grid(row=2, column=1, sticky='W')
        self.get_page_entry.delete(0, tk.END)
        self.get_page_entry.insert(0, '< N° Page >')

        self.modify_page = tk.StringVar()
        self.modify_page_entry = ttk.Entry(self.pydb,
                                           width=10,
                                           textvariable=self.modify_page)
        self.modify_page_entry.grid(row=3, column=1, sticky='W')
        self.modify_page_entry.delete(0, tk.END)
        self.modify_page_entry.insert(0, '< N° Page >')

        #SCROLLEDTEXT
        scrolW = 40
        scrolH = 10
        self.scr = scrolledtext.ScrolledText(self.book_quote,
                                             width=scrolW,
                                             height=scrolH,
                                             wrap=tk.WORD)
        for child in self.book_quote.winfo_children():
            child.grid_configure(sticky='W')
        self.scr.grid(row=5, column=0, columnspan=3, sticky='WE')

        #DIVERS
        #MENUBAR
        self.menuBar = Menu(self.win)
        self.win.config(menu=self.menuBar)
        self.fileMenu = Menu(self.menuBar, tearoff=0)
        self.fileMenu.add_command(label=self.i18n.new)
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label=self.i18n.exit,
                                  command=self.callbacks._quit)
        self.menuBar.add_cascade(label=self.i18n.file, menu=self.fileMenu)
        self.helpMenu = Menu(self.menuBar, tearoff=0)
        self.helpMenu.add_command(label=self.i18n.about,
                                  command=self.callbacks._msgBox)
        self.menuBar.add_cascade(label=self.i18n.help, menu=self.helpMenu)

        #TOOLTIPS
        tips.createToolTip(self.book_quote, 'This is a Spin control.')
        #tips.createToolTip(self.scr, 'This is a ScrolledText Widget.')
        tips.createToolTip(self.insert_title_entry, 'This is a Entry control.')
        tips.createToolTip(self.insert_button, 'This is a Button control.')
        tips.createToolTip(self.get_button, 'This is a Button control.')
        tips.createToolTip(self.modify_button, 'This is a Button control.')

        self.tab2Content = tab2.Tab2(self)
        self.mySQL = mysql_test.MySQL()
コード例 #17
0
ファイル: tkmpl.py プロジェクト: pyIPP/trgui
    def __init__(self, opt_d, rdd, myframe=None):


        if hasattr(self, 'can_frame'):
            self.can_frame.destroy()
        if myframe is None:
            myframe = tk.Toplevel()
            myframe.title('View and edit profiles')
            myframe.geometry('900x700')


# Prepare + merge data

        self.ext_str = ''
        for diag_sig in sorted(opt_d.keys()):
            diag = diag_sig.split(':')[0]
            self.ext_str += diag
        self.nshot = int(opt_d[diag_sig]['shot'])
        self.diag = opt_d[diag_sig]['diag']  
        self.sig  = opt_d[diag_sig]['sig'] 
        self.exp  = opt_d[diag_sig]['exp'] 
        self.ed   = int(opt_d[diag_sig]['ed'])

        self.eq_ed   = int(opt_d[diag_sig]['Map_ed'])
        self.eq_diag = opt_d[diag_sig]['Map_diag']
        self.eq_exp  = opt_d[diag_sig]['Map_exp']

        for diag_sig in rdd.keys():
            if not hasattr(self, 'xexp'):
                self.xexp = np.array(rdd[diag_sig]['rhop'])
                self.yexp = np.array(rdd[diag_sig]['data'])
                self.yerr = np.array(rdd[diag_sig]['data_err'])
            else:
                self.xexp = np.append(self.xexp, rdd[diag_sig]['rhop']    , axis=1)
                self.yexp = np.append(self.yexp, rdd[diag_sig]['data']    , axis=1)
                self.yerr = np.append(self.yerr, rdd[diag_sig]['data_err'], axis=1)

        self.tgrid = rdd[diag_sig]['tgrid']

        self.rho_lbl = 'rho_pol'

        self.name = ', '.join('-'.join(s) for s in zip(self.diag, self.sig))
        self.perturb_freq = 0

        self.channel = range(self.xexp.shape[1])

        tbeg = np.min(self.tgrid)
        tend = np.max(self.tgrid)

        self.jt = 0

        self.nr_fit = 41
        self.eta = 0
        self.lam = 4

#        dt = self.tgrid[1] - self.tgrid[0]
#        self.nt = int((tend - tbeg)/dt) + 1
        self.nt = len(self.tgrid)

        self.ylab = ', '.join(self.diag)
        self.xlab = r'$\rho_{%s}$'%self.rho_lbl[4:]

        rho  = self.xexp.ravel()
        y    = self.yexp.ravel()
        yerr = self.yerr.ravel()
        tvec = np.repeat(self.tgrid, self.xexp.shape[1])

# Create object of the fitting routine
        self.m2g = map2grid(rho, tvec, y, yerr, self.nr_fit, self.nt, \
            name=self.name)

        self.fit_prepared = False

# Canvas frame
        self.fig = Figure(figsize=(10., 5.5), dpi=100)
        self.ax1 = self.fig.add_subplot(1, 2, 1)
        self.ax2 = self.fig.add_subplot(1, 2, 2)

        self.can_frame = ttk.Frame(myframe)
        self.can_frame.pack(side=tk.TOP)

        self.canvas = FigureCanvasTkAgg(self.fig, master=self.can_frame)
        toolbar = NavigationToolbar2TkAgg(self.canvas, myframe)
        toolbar.update()

        self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        fsize = 12

# Plots in the frame
        self.plotline, self.caplines, self.barlinecols=self.ax1.errorbar( \
            0,0,0, fmt='g.', label='measured data')
        self.replot_plot, = self.ax1.plot([], [], 'b+', label='retrofit')
        self.fit_plot,    = self.ax1.plot([], [], 'k-', linewidth=.5)

        self.ax1.set_xlim(0, 1.05)
        self.ax1.legend()
        self.ax1.xaxis.set_major_formatter( plt.NullFormatter() )

        title_template = '%s, time: %.3fs'    # prints running simulation time
        self.time_text = self.ax1.text(.05, .9, '', transform=self.ax1.transAxes)

        self.ax2.set_title('Numerical inverted diffusion')
        self.k_plot, = self.ax2.plot([], [], 'r-', label='$1/\chi_N$')
        self.confidence_plot = self.ax2.fill_between(self.m2g.r_new[0, :-1], \
            np.ones(self.nr_fit-1)*1.5, np.ones(self.nr_fit-1), \
            alpha=.2, facecolor='b', edgecolor='None', \
            label='68% confidence interval')
        self.ax2.set_xlim(0, 1.05)

        self.ax2.set_xlabel(self.xlab, fontsize=fsize)
        self.ax1.set_xlabel(self.xlab, fontsize=fsize)
        self.ax1.set_ylabel(self.ylab, fontsize=fsize)

        hbox1 = tk.Frame(myframe)
        hbox2 = tk.Frame(myframe)
        hbox3 = tk.Frame(myframe)
        for box in hbox1, hbox2, hbox3:
            box.pack(side=tk.TOP, fill=tk.X)
# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig  = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig  = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig = tk.PhotoImage(file='%s/backward.gif' %locdir)

        backward_button  = ttk.Button(hbox1, command=self.Backward, image=self.backwardfig)
        self.play_button = ttk.Button(hbox1, command=self.Play    , image=self.playfig)
        forward_button   = ttk.Button(hbox1, command=self.Forward , image=self.forwardfig)
        backward_button.pack( side=tk.LEFT)
        self.play_button.pack(side=tk.LEFT)
        forward_button.pack(  side=tk.LEFT)

# Commands

        btfit = tk.Button(hbox2, text='Fit', command=self.fit)
        btplo = tk.Button(hbox2, text='Plot 3D', command=self.plot3d)
        for but in btfit, btplo:
            but.pack(side=tk.LEFT)

# User instructions

        mouse_help = tk.Label(hbox3, text='Mouse: ')
        mouse_left = tk.Label(hbox3, text='Left (+Ctrl): del point (Channel)  ', \
                              fg="#900000")
        mouse_mid   = tk.Label(hbox3, text='Mid: re-fit ', fg="#009000")
        mouse_right = tk.Label(hbox3, text='Right: next ', fg="#000090")

        for w in (mouse_help, mouse_left, mouse_mid, mouse_right):
            w.pack(side=tk.LEFT)

        self.stop  = True
        self.ctrl  = False
        self.shift = False

        def stop_handler(event=None, self=self):
            self.stop  = True

        forward_button.bind( "<Button-1>", stop_handler)
        backward_button.bind("<Button-1>", stop_handler)

        self.entr_per_freq = tk.Entry(hbox2, width=2)
        self.entr_per_freq.insert(0, self.perturb_freq)
        self.entr_per_freq.pack(side=tk.RIGHT)
        cfit_lbl = tk.Label(hbox2, text='Perturbation freq. [Hz]')
        cfit_lbl.pack(side=tk.RIGHT)

        axcolor = 'lightgoldenrodyellow'

        self.fig.subplots_adjust(left=.15, bottom=.25, right=.95, top=.95, \
                                 hspace=.1, wspace=0)

        self.sl_ax_time = self.fig.add_axes([.2, .12, .7, .05], axisbg=axcolor)
        self.sl_time = Slider(self.sl_ax_time, 'Time:', tbeg, tend, valinit=tbeg)

        sl_ax = self.fig.add_axes([.2, .03, .3, .05], axisbg=axcolor)
        self.sl_eta = Slider(sl_ax , '', -3, 3, valinit=self.eta)

        sl_ax2 = self.fig.add_axes([.6, .03, .3, .05], axisbg=axcolor)
        self.sl_lam = Slider(sl_ax2, '', 0, 7, valinit=self.lam)

        self.fig.text(.2, .095, 'Time smoothing -->:')
        self.fig.text(.6, .095, 'Total smoothing -->:')

        createToolTip(forward_button, 'Go forward by one timestep')
        createToolTip(backward_button, 'Go backward by one timestep')
        createToolTip(self.play_button, 'Go step by step forward, pause by second press')
        createToolTip(self.entr_per_freq, 'Frequency of the periodic plasma perturbations (it is slow!).')

        def update_eta(val):
            self.fit_prepared=False
            stop_handler()

        def update_lam(val):
            stop_handler()

        def update_time(val):
            self.jt = int((val - self.tgrid[0])/(self.tgrid[1] - self.tgrid[0]) + 0.5)
            self.plot_step()
            self.updateTimeSlider(val)
            
        self.sl_time.on_changed(update_time)

        self.fig.canvas.mpl_connect('button_press_event', self.MouseInteraction)
        self.fig.canvas.mpl_connect('key_press_event',   self.on_key)
        self.fig.canvas.mpl_connect('key_release_event', self.off_key)
        self.fig.canvas.mpl_connect('button_press_event', lambda event:self.fig.canvas._tkcanvas.focus_set())

        self.sl_eta.on_changed(update_eta)
        self.sl_lam.on_changed(update_lam)

        self.PreparePloting()
コード例 #18
0
ファイル: trcmd.py プロジェクト: pyIPP/trgui
    def __init__(self):

        dbgui = tk.Tk()
        dbgui.geometry('900x770')
        dbgui.title('DB GUI')

# Widgets style

        import trgui_style

# Menubar

        menubar  = tk.Menu(dbgui)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Run", command=self.run)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=sys.exit)

        helpmenu = tk.Menu(menubar, tearoff=0)
        helpmenu.add_command(label="About", command=about)

        menubar.add_cascade(label = "File", menu=filemenu)
        menubar.add_cascade(label = "Help", menu=helpmenu)

        menubar.configure(bg=trgui_style.tbc)
        dbgui.config(menu = menubar)

# Frame structure

        mainframe = ttk.Frame(dbgui)
        mainframe.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        shotframe = ttk.Frame(mainframe)
        geoframe  = ttk.Frame(mainframe)
        scalframe = ttk.Frame(mainframe)
        profframe = ttk.Frame(mainframe)
        nmlframe  = ttk.Frame(mainframe)
        jobframe  = ttk.Frame(mainframe)
        for frame in shotframe, geoframe, scalframe, profframe, nmlframe, jobframe:
            frame.pack(side=tk.TOP, fill=tk.BOTH, pady=5)

        self.nmlgui_d = {}

# Shotlist file

        ttk.Label(shotframe, text='Shot list', width=12).pack(side=tk.LEFT, padx=2)
        self.shotlist_but = ttk.Entry(shotframe, width=60)
        self.shotlist_but.insert(0, '%s/tr_client/shot_list' %os.getenv('HOME'))
        self.shotlist_but.pack(side=tk.LEFT)

# Separatrix

        geoinit = {'Nmom': 6, 'exp': 'AUGD', 'dia': 'EQH', 'ed': 0}
        self.nmlgui_d['mry'] = tk.BooleanVar()
        self.nmlgui_d['mry'].set(True)
        cbt = ttk.Checkbutton(geoframe, text='Separatrix u-file', variable=self.nmlgui_d['mry'], width=16)
        cbt.pack(side=tk.LEFT, fill=tk.X)

        for key in ('dia', 'exp', 'ed', 'Nmom'):
            ttk.Label(geoframe, text='%s:' %key, width=6).pack(side=tk.LEFT, padx='0 10')
            var = ttk.Entry(geoframe, width=6)
            var.insert(0, geoinit[key])
            var.pack(side=tk.LEFT, padx=2)
            self.nmlgui_d[key] = var

# 1d ufiles
        self.nmlgui_d['1d'] = tk.BooleanVar()
        self.nmlgui_d['1d'].set(True)
        cbt = ttk.Checkbutton(scalframe, text='1D u-files', variable=self.nmlgui_d['1d'], width=16)
        cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)

# Profile choice

        prof_l = ttk.Frame(profframe)
        prof_r = ttk.Frame(profframe)
        for frame in prof_l, prof_r:
            frame.pack(side=tk.LEFT, anchor=tk.NW, fill=tk.X)
        
# 2d ufiles
        self.nmlgui_d['2d'] = tk.BooleanVar()
        self.nmlgui_d['2d'].set(True)
        cbt = ttk.Checkbutton(prof_l, text='2D u-files', variable=self.nmlgui_d['2d'], width=16)
        cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)

        expframe  = ttk.Frame(prof_r)
        diagframe = ttk.Frame(prof_r)
        dtframe   = ttk.Frame(prof_r)
        elmframe  = ttk.Frame(prof_r)
        mapframe  = ttk.Frame(prof_r)
        rhoframe  = ttk.Frame(prof_r)
        fitframe  = ttk.Frame(prof_r)

        for frame in expframe, diagframe, dtframe, elmframe, mapframe, rhoframe, fitframe:
            frame.pack(side=tk.TOP, anchor=tk.NW, pady=5)

        ttk.Label(expframe, text='Exp', width=12).pack(side=tk.LEFT)
        self.exp_val = ttk.Entry(expframe, width=8)
        self.exp_val.insert(0, 'AUGD')
        self.exp_val.pack(side=tk.LEFT, padx=5)

# Diag choice

        diags, sigs, pre = \
            np.genfromtxt('/afs/ipp/home/g/git/python/trgui/diags.dat', dtype='str', skip_header=2, unpack=True, usecols=(0, 1, 2))

        self.cbvar = {}
        line_flg = False
        for prefix in pre_list:
            lineframe = ttk.Frame(diagframe)
            lineframe.pack(side=tk.TOP, anchor=tk.W, pady=2)
            rbframe = ttk.Frame(lineframe)
            rbframe.pack(side=tk.LEFT, anchor=tk.W)
            diagsframe = ttk.Frame(lineframe)
            diagsframe.pack(side=tk.LEFT, anchor=tk.W)

            ttk.Label(rbframe, text='%-7s' %lbl_d[prefix][0], width=3).pack(side=tk.LEFT, anchor=tk.W, padx=5)
            diaframe = ttk.Frame(diagsframe)
            diaframe.pack(side=tk.TOP, anchor=tk.W)
            self.cbvar[prefix] = {}
            jcol = 0
            for jdia, diag in enumerate(diags):
                if pre[jdia] == prefix:
                    sig = sigs[jdia]
                    diag_sig = '%s:%s' %(diag, sig)
                    self.cbvar[prefix][diag_sig] = tk.BooleanVar()
                    self.cbvar[prefix][diag_sig].set(False)
                    if (diag_sig in lbl_d[prefix][1:]):
                        self.cbvar[prefix][diag_sig].set(True)
                    cbt = ttk.Checkbutton(diaframe, text=diag_sig, variable=self.cbvar[prefix][diag_sig], width=9)
                    cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)
                    if jcol%7 == 6:
                        diaframe = ttk.Frame(diagsframe)
                        diaframe.pack(side=tk.TOP, anchor=tk.W)
                    jcol += 1

# Options for profile processing

        ttk.Label(dtframe, text='Dt average', width=12).pack(side=tk.LEFT, pady=5)
        self.dtav_val = ttk.Entry(dtframe, width=8)
        self.dtav_val.insert(0, 0.01)
        self.dtav_val.pack(side=tk.LEFT, padx=5)

        self.no_elm = tk.BooleanVar()
        self.no_elm.set(True)
        cbt = ttk.Checkbutton(elmframe, text='No ELMs', variable=self.no_elm)
        cbt.pack(side=tk.LEFT, anchor=tk.W)


# Profile mapping

        mexpframe = ttk.Frame(mapframe)
        mdiaframe = ttk.Frame(mapframe)
        mexpframe.pack(side=tk.TOP, anchor=tk.W, padx='0 10', pady=5)
        mdiaframe.pack(side=tk.TOP, anchor=tk.W, padx='0 10', pady=5)

# Output grid for u-files

        self.rho_event = tk.StringVar()
        self.rho_event.set('rho_tor')
        rhofr1 = ttk.Frame(rhoframe)
        rhofr2 = ttk.Frame(rhoframe)
        for frame in rhofr1, rhofr2:
            frame.pack(side=tk.TOP, anchor=tk.W, pady=5)
        ttk.Label(rhofr1, text='U-file coordinate', width=20).pack(side=tk.LEFT)
        for val in ('rho_pol', 'rho_tor'):
            ttk.Radiobutton(rhofr1, variable=self.rho_event, value=val, text=val).pack(side=tk.LEFT)
        ttk.Label(rhofr2, text='# radial points', width=14).pack(side=tk.LEFT)
        self.n_spl_val = ttk.Entry(rhofr2, width=10)
        self.n_spl_val.insert(0, 51)
        self.n_spl_val.pack(side=tk.LEFT)

# Fit

        fitfr1 = ttk.Frame(fitframe)
        fitfr2 = ttk.Frame(fitframe)
        fitfr3 = ttk.Frame(fitframe)
        for frame in fitfr1, fitfr2, fitfr3:
            frame.pack(side=tk.TOP, anchor=tk.W, pady=5)

        ttk.Label(fitfr1, text='Fit', width=6).pack(side=tk.LEFT)
        ttk.Label(fitfr2, text='Method', width=8).pack(side=tk.LEFT)
        self.fit_method = tk.StringVar()
        self.fit_method.set('rec_spl')
        fit_rb1 = ttk.Radiobutton(fitfr2, text='Rec. spline', variable=self.fit_method, value='rec_spl')
        fit_rb2 = ttk.Radiobutton(fitfr2, text='Gauss', variable=self.fit_method, value='gauss')
#        fit_rb3 = ttk.Radiobutton(fitfr2, text='Fit 2D', variable=self.fit_method, value='fit_2d')
        for rb in fit_rb1, fit_rb2: #, fit_rb3:
            rb.pack(side=tk.LEFT, padx=10)
        createToolTip(fit_rb1, 'Cubic spline of single profiles')
        createToolTip(fit_rb2, 'Gaussian kernels of single profiles')
#        createToolTip(fit_rb3, 'Fast 2d spline fitting of the profiles')

        ttk.Label(fitfr3, text='sigma').pack(side=tk.LEFT)
        self.sigma = ttk.Entry(fitfr3, width=6)
        self.sigma.insert(0, 1)
        self.sigma.pack(side=tk.LEFT)
        ttk.Label(fitfr3, text='fit_tol').pack(side=tk.LEFT)
        self.fit_tol = ttk.Entry(fitfr3, width=6)
        self.fit_tol.insert(0, 1)
        self.fit_tol.pack(side=tk.LEFT)

# Namelist options

        nml_l = ttk.Frame(nmlframe)
        nml_r = ttk.Frame(nmlframe)
        for frame in nml_l, nml_r:
            frame.pack(side=tk.LEFT, anchor=tk.W, fill=tk.X)

        self.nmlgui_d['nml'] = tk.BooleanVar()
        self.nmlgui_d['nml'].set(False)
        cbt = ttk.Checkbutton(nml_l, text='Namelist', variable=self.nmlgui_d['nml'], width=16)
        cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)

        nml_init = {'tres': '0.01', 'dtbeam': '0.01', 'nmc': '50000'}
        for key in ('tres', 'dtbeam', 'nmc'):
            ttk.Label(nml_r, text=key, width=7).pack(side=tk.LEFT)
            self.nmlgui_d[key] = ttk.Entry(nml_r, width=6)
            self.nmlgui_d[key].insert(0, nml_init[key])
            self.nmlgui_d[key].pack(side=tk.LEFT, padx='1 10')

# job manager

        self.nmlgui_d['job'] = tk.BooleanVar()
        self.nmlgui_d['job'].set(False)
        cbt = ttk.Checkbutton(jobframe, text='Send jobs', variable=self.nmlgui_d['job'], width=16)
        cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)
# TK widget

        dbgui.mainloop()
コード例 #19
0
    def init_fit_frame(self):

        #frame with the navigation bar for the main plot

        fit_frame_up = tk.Frame(self.fit_frame)
        fit_frame_down = tk.LabelFrame(self.fit_frame, relief='groove')
        fit_frame_up.pack(side=tk.TOP, fill=tk.BOTH)
        fit_frame_down.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=tk.Y)

        self.plot_type = tk.IntVar(master=self.fit_frame)
        self.plot_type.set(1)
        r_buttons = 'Radial slice', 'Time slice', 'Gradient'
        for nbutt, butt in enumerate(r_buttons):
            button = tk.Radiobutton(fit_frame_up,
                                    text=butt,
                                    variable=self.plot_type,
                                    command=self.changed_fit_slice,
                                    value=nbutt)
            button.pack(anchor='w', side=tk.LEFT, pady=2, padx=2)

        # canvas frame

        self.fig = Figure(figsize=(10, 10), dpi=75)
        self.fig.patch.set_facecolor((.93, .93, .93))
        self.ax_main = self.fig.add_subplot(111)

        self.canvasMPL = tkagg.FigureCanvasTkAgg(self.fig,
                                                 master=fit_frame_down)
        self.toolbar = NavigationToolbar2Tk(self.canvasMPL, fit_frame_down)

        def print_figure(filename, **kwargs):
            #cheat print_figure function to save only the plot without the sliders.
            if 'bbox_inches' not in kwargs:
                fig = self.ax_main.figure
                extent = self.ax_main.get_tightbbox(
                    fig.canvas.renderer).transformed(
                        fig.dpi_scale_trans.inverted())
                extent.y1 += .3
                extent.x1 += .3
                kwargs['bbox_inches'] = extent
            self.canvas_print_figure(filename, **kwargs)

        self.canvas_print_figure = self.toolbar.canvas.print_figure
        self.toolbar.canvas.print_figure = print_figure

        self.canvasMPL.get_tk_widget().pack(side=tk.TOP,
                                            fill=tk.BOTH,
                                            expand=1)
        self.canvasMPL._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.lcfs_line = self.ax_main.axvline(1, ls='--', c='k', visible=False)
        self.zero_line = self.ax_main.axhline(0, ls='--', c='k', visible=False)

        hbox1 = tk.Frame(fit_frame_down)
        hbox1.pack(side=tk.BOTTOM, fill=tk.X)
        mouse_help = tk.Label(hbox1, text='Mouse: ')
        mouse_left = tk.Label(hbox1,
                              text='Left (+Ctrl): del point (Channel)  ',
                              fg="#900000")
        mouse_mid = tk.Label(hbox1, text='Mid: re-fit  ', fg="#009000")
        mouse_right = tk.Label(hbox1,
                               text='Right: undelete point  ',
                               fg="#000090")
        mouse_wheel = tk.Label(hbox1, text='Wheel: shift', fg="#905090")

        for w in (mouse_help, mouse_left, mouse_mid, mouse_right, mouse_wheel):
            w.pack(side=tk.LEFT)

        hbox2 = tk.Frame(fit_frame_down)
        hbox2.pack(side=tk.BOTTOM, fill=tk.X)

        helv36 = tkinter.font.Font(family='Helvetica', size=10, weight='bold')
        calc_button = tk.Button(hbox2,
                                text='Fit',
                                bg='red',
                                command=self.calculate,
                                font=helv36)
        calc_button.pack(side=tk.LEFT)

        self.playfig = tk.PhotoImage(file=icon_dir + 'play.gif',
                                     master=self.fit_frame)
        self.pausefig = tk.PhotoImage(file=icon_dir + 'pause.gif',
                                      master=self.fit_frame)
        self.forwardfig = tk.PhotoImage(file=icon_dir + 'forward.gif',
                                        master=self.fit_frame)
        self.backwardfig = tk.PhotoImage(file=icon_dir + 'backward.gif',
                                         master=self.fit_frame)

        self.backward_button = tk.Button(hbox2,
                                         command=self.Backward,
                                         image=self.backwardfig)
        self.backward_button.pack(side=tk.LEFT)
        self.play_button = tk.Button(hbox2,
                                     command=self.Play,
                                     image=self.playfig)
        self.play_button.pack(side=tk.LEFT)
        self.forward_button = tk.Button(hbox2,
                                        command=self.Forward,
                                        image=self.forwardfig)
        self.forward_button.pack(side=tk.LEFT)

        self.button_3d = tk.Button(hbox2,
                                   command=self.plot3d,
                                   text='3D',
                                   font=helv36)
        self.button_3d.pack(side=tk.LEFT)

        self.stop = True
        self.ctrl = False
        self.shift = False

        def stop_handler(event=None, self=self):
            self.stop = True

        self.forward_button.bind("<Button-1>", stop_handler)
        self.backward_button.bind("<Button-1>", stop_handler)

        vcmd = hbox2.register(self.isfloat)

        self.view_step = tk.Entry(hbox2,
                                  width=4,
                                  validate="key",
                                  validatecommand=(vcmd, '%P'),
                                  justify=tk.CENTER)
        self.view_step_lbl = tk.Label(hbox2, text='Plot step [ms]')
        self.view_step.pack(side=tk.RIGHT, padx=10)
        self.view_step_lbl.pack(side=tk.RIGHT)

        axcolor = 'lightgoldenrodyellow'

        self.fig.subplots_adjust(left=.10,
                                 bottom=.20,
                                 right=.95,
                                 top=.95,
                                 hspace=.1,
                                 wspace=0)
        from numpy.lib import NumpyVersion
        kargs = {
            'facecolor': axcolor
        } if NumpyVersion(
            matplotlib.__version__) > NumpyVersion('2.0.0') else {
                'axisbg': axcolor
            }
        self.sl_ax_main = self.fig.add_axes([.1, .10, .8, .03], **kargs)
        self.main_slider = Slider(self.sl_ax_main,
                                  '',
                                  self.tbeg,
                                  self.tend,
                                  valinit=self.tbeg)

        sl_ax = self.fig.add_axes([.1, .03, .35, .03], **kargs)
        self.sl_eta = Slider(sl_ax, '', 0, 1, valinit=self.options['eta'])

        sl_ax2 = self.fig.add_axes([.55, .03, .35, .03], **kargs)
        self.sl_lam = Slider(sl_ax2, '', 0, 1, valinit=self.options['lam'])

        self.fig.text(.1, .075, 'Time smoothing -->:')
        self.fig.text(.55, .075, 'Radial smoothing -->:')

        createToolTip(self.forward_button, 'Go forward by one step')
        createToolTip(self.backward_button, 'Go backward by one step')
        createToolTip(self.play_button,
                      'Go step by step forward, pause by second press')
        createToolTip(
            self.view_step,
            'Plotting time/radial step, this option influences only the plotting, not fitting!'
        )

        createToolTip(calc_button, 'Calculate the 2d fit of the data')

        def update_eta(eta):
            self.options['eta'] = eta
            stop_handler()

        def update_lam(lam):
            stop_handler()
            self.options['lam'] = lam

        def update_slider(val):
            try:
                if self.plot_type.get() in [1, 2]:
                    self.plt_time = val
                if self.plot_type.get() in [0]:
                    self.plt_radius = val

                self.updateMainSlider()
                self.plot_step()
            except:
                print(
                    '!!!!!!!!!!!!!!!!!!!!!main_slider error!!!!!!!!!!!!!!!!!!!!!!!!!!!'
                )
                raise

        self.main_slider.on_changed(update_slider)

        self.cid1 = self.fig.canvas.mpl_connect('button_press_event',
                                                self.MouseInteraction)
        self.cid2 = self.fig.canvas.mpl_connect('scroll_event',
                                                self.WheelInteraction)
        self.cid3 = self.fig.canvas.mpl_connect('key_press_event', self.on_key)
        self.cid4 = self.fig.canvas.mpl_connect('key_release_event',
                                                self.off_key)
        self.cid5 = self.fig.canvas.mpl_connect(
            'button_press_event',
            lambda event: self.fig.canvas._tkcanvas.focus_set())
        self.cid6 = self.fig.canvas.mpl_connect('pick_event', self.legend_pick)

        self.sl_eta.on_changed(update_eta)
        self.sl_lam.on_changed(update_lam)
コード例 #20
0
ファイル: trguij.py プロジェクト: pyIPP/trgui
    def prof_gui(self, prof_frame):

        nshot = int(self.shot_but.get())
        tok = self.etok.get().strip()

        if hasattr(self, 'topprof'):
            self.topprof.destroy()
        self.topprof   = ttk.Frame(prof_frame, height=400)
        self.topprof.pack(side=tk.TOP, anchor=tk.W, padx=5)
        leftframe = ttk.Frame(self.topprof)
        leftframe.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        ttk.Label(leftframe, text='Diagnostics for u-files', width=20).pack(side=tk.TOP, anchor=tk.W, pady=10)

        fitframe  = ttk.Frame(leftframe)
        butframe  = ttk.Frame(leftframe)

# Diag choice

        if tok == 'AUGD':
            diags, sigs, pre, coord, rnam, znam, err_sig = \
                np.genfromtxt('/afs/ipp/home/g/git/python/trgui/diags.dat', dtype='str', skip_header=2, unpack=True)
        elif tok == 'JET':
            diags, sigs, pre, err_sig = \
                np.genfromtxt('/afs/ipp/home/g/git/python/trgui/diags_jet.dat', dtype='str', skip_header=2, unpack=True)
        self.dia_list = {}
        for prefix in pre_list:
            self.dia_list[prefix] = np.unique(diags[pre == prefix])
            
        self.cbvar = {}
        self.ufsel = tk.StringVar()
        self.ufsel.set('I')
        line_flg = False
        for prefix in pre_list:
            lineframe = ttk.Frame(leftframe)
            lineframe.pack(side=tk.TOP, anchor=tk.W, pady=2)
            rbframe = ttk.Frame(lineframe)
            rbframe.pack(side=tk.LEFT, anchor=tk.W)
            diagsframe = ttk.Frame(lineframe)
            diagsframe.pack(side=tk.LEFT, anchor=tk.W)

            ttk.Radiobutton(rbframe, width=3, text='%-7s' %lbl_d[prefix][0], variable=self.ufsel, value=prefix).pack(side=tk.LEFT, anchor=tk.W, padx=5)
            diaframe = ttk.Frame(diagsframe)
            diaframe.pack(side=tk.TOP, anchor=tk.W)
            self.cbvar[prefix] = {}
            for jdia, diag in enumerate(self.dia_list[prefix]):
                self.cbvar[prefix][diag] = tk.BooleanVar()
                self.cbvar[prefix][diag].set(False)
                if (diag in lbl_d[prefix]):
                    self.cbvar[prefix][diag].set(True)
                cbt = ttk.Checkbutton(diaframe, text=diag, variable=self.cbvar[prefix][diag])
                cbt.pack(side=tk.LEFT, fill=tk.X, expand=1)
                if jdia%7 == 6:
                    diaframe = ttk.Frame(diagsframe)
                    diaframe.pack(side=tk.TOP, anchor=tk.W)

        for frame in fitframe, butframe:
            frame.pack(side=tk.TOP, anchor=tk.W, pady=10)
                    

        but = ttk.Button(butframe, text='Load profiles', command=self.dw2read)
        but.pack(side=tk.LEFT)
        createToolTip(but, 'Method dw2read')
コード例 #21
0
ファイル: PGUI2.py プロジェクト: miloshIra/Collatz
    def createWidgets(self):
        # Tab Control introduced here --------------------------------------
        tabControl = ttk.Notebook(self.win)     # Create Tab Control

        tab1 = ttk.Frame(tabControl)            # Create a tab
        tabControl.add(tab1, text='Tab 1')      # Add the tab

        tab2 = ttk.Frame(tabControl)            # Add a second tab
        tabControl.add(tab2, text='Tab 2')      # Make second tab visible

        tabControl.pack(expand=1, fill="both")  # Pack to make visible
        # ~ Tab Control introduced here -----------------------------------------

        # We are creating a container frame to hold all other widgets
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)

        # Changing our Label
        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')

        # Adding a Textbox Entry widget
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=24, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')
        nameEntered.delete(0, tk.END)
        nameEntered.insert(0, '< default name >')

        # Adding a Button
        self.action = ttk.Button(self.monty, text="Click Me!", command=self.clickMe)
        self.action.grid(column=2, row=1)

        ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        numberChosen = ttk.Combobox(self.monty, width=14, textvariable=number)
        numberChosen['values'] = (1, 2, 4, 42, 100)
        numberChosen.grid(column=1, row=1)
        numberChosen.current(0)

        # Adding a Spinbox widget using a set of values
        self.spin = Spinbox(self.monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command=self._spin)
        self.spin.grid(column=0, row=2, sticky='W')

        # Using a scrolled Text control
        scrolW  = 40; scrolH  =  10
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)




        # Tab Control 2 refactoring  ---------------------------------------------------
        # We are creating a container frame to hold all other widgets -- Tab2
        self.monty2 = ttk.LabelFrame(tab2, text=' The Snake ')
        self.monty2.grid(column=0, row=0, padx=8, pady=4)



        # Creating three checkbuttons
        chVarDis = tk.IntVar()
        check1 = tk.Checkbutton(self.monty2, text="Disabled", variable=chVarDis, state='disabled')
        check1.select()
        check1.grid(column=0, row=0, sticky=tk.W)

        self.chVarUn = tk.IntVar()
        self.check2 = tk.Checkbutton(self.monty2, text="UnChecked", variable=self.chVarUn)
        self.check2.deselect()
        self.check2.grid(column=1, row=0, sticky=tk.W )

        self.chVarEn = tk.IntVar()
        self.check3 = tk.Checkbutton(self.monty2, text="Toggle", variable=self.chVarEn)
        self.check3.deselect()
        self.check3.grid(column=2, row=0, sticky=tk.W)

        # trace the state of the two checkbuttons
        self.chVarUn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())
        self.chVarEn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())
        # ~ Tab Control 2 refactoring  -----------------------------------------

        # Radiobutton list
        colors = ["Blue", "Gold", "Red"]

        self.radVar = tk.IntVar()

        # Selecting a non-existing index value for radVar
        self.radVar.set(99)

        # Creating all three Radiobutton widgets within one loop
        for col in range(3):
            curRad = 'rad' + str(col)
            curRad = tk.Radiobutton(self.monty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall)
            curRad.grid(column=col, row=6, sticky=tk.W, columnspan=3)
            # And now adding tooltips
            tt.createToolTip(curRad, 'This is a Radiobutton control.')

        # Create a container to hold labels
        labelsFrame = ttk.LabelFrame(self.monty2, text=' Labels in a Frame ')
        labelsFrame.grid(column=0, row=7)

        # Place labels into the container element - vertically
        ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
        ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)

        # Add some space around each label
        for child in labelsFrame.winfo_children():
            child.grid_configure(padx=8)

        # Create Manage Files Frame ------------------------------------------------
        mngFilesFrame = ttk.LabelFrame(tab2, text=' Manage Files: ')
        mngFilesFrame.grid(column=0, row=1, sticky='WE', padx=10, pady=5)

        # Button Callback
        def getFileName():
            print('hello from getFileName')
            fDir  = path.dirname(__file__)
            fName = fd.askopenfilename(parent=self.win, initialdir=fDir)
            print(fName)
            self.fileEntry.config(state='enabled')
            self.fileEntry.delete(0, tk.END)
            self.fileEntry.insert(0, fName)

            if len(fName) > self.entryLen:
                self.fileEntry.config(width=len(fName) + 3)

        # Add Widgets to Manage Files Frame
        lb = ttk.Button(mngFilesFrame, text="Browse to File...", command=getFileName)
        lb.grid(column=0, row=0, sticky=tk.W)

        #-----------------------------------------------------
        file = tk.StringVar()
        self.entryLen = scrolW - 4
        self.fileEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=file)
        self.fileEntry.grid(column=1, row=0, sticky=tk.W)

        #-----------------------------------------------------
        logDir = tk.StringVar()
        self.netwEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=logDir)
        self.netwEntry.grid(column=1, row=1, sticky=tk.W)


        def copyFile():
            import shutil
            src = self.fileEntry.get()
            file = src.split('/')[-1]
            dst = self.netwEntry.get() + '\\'+ file
            try:
                shutil.copy(src, dst)
                mBox.showinfo('Copy File to Network', 'Succes: File copied.')
            except FileNotFoundError as err:
                mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(err))
            except Exception as ex:
                mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(ex))

        cb = ttk.Button(mngFilesFrame, text="Copy File To :   ", command=copyFile)
        cb.grid(column=0, row=1, sticky=tk.E)

        # Add some space around each label
        for child in mngFilesFrame.winfo_children():
            child.grid_configure(padx=6, pady=6)


        # Creating a Menu Bar ==========================================================
        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)

        # Add menu items
        fileMenu = Menu(menuBar, tearoff=0)
        fileMenu.add_command(label="New")
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self._quit)
        menuBar.add_cascade(label="File", menu=fileMenu)

        # Add another Menu to the Menu Bar and an item
        helpMenu = Menu(menuBar, tearoff=0)
        helpMenu.add_command(label="About")
        menuBar.add_cascade(label="Help", menu=helpMenu)

        # Change the main windows icon
        self.win.iconbitmap(r'C:\Users\milos.aritonski\Desktop\Vitek.ico')

        # Using tkinter Variable Classes
        strData = tk.StringVar()
        strData.set('Hello StringVar')

        # It is not necessary to create a tk.StringVar()
        strData = tk.StringVar()
        strData = self.spin.get()

        # Place cursor into name Entry
#         nameEntered.focus()
        # Set focus to Tab 2
#         tabControl.select(1)

        # Add a Tooltip to the Spinbox
        tt.createToolTip(self.spin, 'This is a Spin control.')

        # Add Tooltips to more widgets
        tt.createToolTip(nameEntered, 'This is an Entry control.')
        tt.createToolTip(self.action, 'This is a Button control.')
        tt.createToolTip(self.scr,    'This is a ScrolledText control.')
コード例 #22
0
    def main(self):

        # CREATING TABS
        self.tabControl = ttk.Notebook(self.win)  # Create tab control (list)
        self.tabControl.pack(expand=1, fill="both")  # Makes tab visible

        self.tab1 = ttk.Frame(self.tabControl)  # Create a tab
        self.tabControl.add(self.tab1, text="Tab 1")  # Adds the tab

        self.tab2 = ttk.Frame(self.tabControl)  # A new tab
        self.tabControl.add(self.tab2, text="Tab 2")  # Adds the tab

        # CREATING A CONTAINER FRAME IN THE WINDOW TO HOLD ALL WIDGETS
        self.monty = ttk.LabelFrame(self.tab1, text=" Monty Python ")
        self.monty.grid(column=0, row=0, padx=20, pady=20)

        # FIRST AND SECOND ROWS (LABELS AND ENTRY BOXES)
        ttk.Label(self.monty, text="Enter a name:").grid(column=0,
                                                         row=0,
                                                         sticky='W')
        self.name = tk.StringVar()
        self.nameEntered = ttk.Entry(self.monty,
                                     width=12,
                                     textvariable=self.name)
        self.nameEntered.grid(column=0, row=1, sticky='WE')
        self.action2 = ttk.Button(self.monty,
                                  text="Click me!",
                                  command=self.clickMe2)
        self.action2.grid(column=2, row=1)

        # COMBOBOX
        self.aLabel2 = ttk.Label(self.monty,
                                 text="Choose a number:").grid(column=1, row=0)
        self.number = tk.StringVar()
        self.numberChosen = ttk.Combobox(
            self.monty, width=12, textvariable=self.number, state='readonly'
        )  # ...state='readonly')  does not allow the user to enter his/her own value into combo box
        self.numberChosen['values'] = (1, 2, 4, 42, 100)
        self.numberChosen.grid(column=1, row=1)
        self.numberChosen.current(0)

        # NEW LABEL FRAME FOR TAB 2
        self.monty2 = ttk.LabelFrame(self.tab2, text=" The Snake ")
        self.monty2.grid(column=0, row=0, padx=20, pady=20)

        # CHECKBOXES
        self.check1 = tk.IntVar()
        self.checkBox1 = tk.Checkbutton(self.monty2,
                                        text="Disabled",
                                        variable=self.check1,
                                        state='disabled')
        self.checkBox1.select()
        self.checkBox1.grid(
            column=0, row=0,
            sticky=tk.W)  # sticky=tk.W ... alligns west of grid
        self.check2 = tk.IntVar()
        self.checkBox2 = tk.Checkbutton(self.monty2,
                                        text="Unchecked",
                                        variable=self.check2)
        self.checkBox2.deselect()
        self.checkBox2.grid(column=1, row=0, sticky=tk.W)
        self.check3 = tk.IntVar()
        self.checkBox3 = tk.Checkbutton(self.monty2,
                                        text="Enabled",
                                        variable=self.check3)
        self.checkBox3.select()
        self.checkBox3.grid(column=2, row=0, sticky=tk.W)
        createToolTip(self.checkBox3, text="This is a checkbox")

        self.colour = ('Blue', 'Gold', 'Red')
        self.radio = tk.IntVar()
        self.radio.set(99)
        for col in range(3):
            self.radioButton = ttk.Radiobutton(self.monty2,
                                               text=self.colour[col],
                                               variable=self.radio,
                                               value=col + 1,
                                               command=self.radioButtonCall)
            self.radioButton.grid(column=0 + col, row=1, sticky=tk.W)

        # SPINBOX
        self.spin = tk.Spinbox(
            self.monty,
            values=(1, 2, 4, 6, 7, 8, 100),
            width=5,
            bd=8,
            state='readonly',
            command=self._spinBox)  # bd = borderwidth (makes it embedded)
        self.spin.grid(column=0, row=2)
        createToolTip(self.spin, 'This is a Spin control.')

        # ANOTHER SPINBOX
        self.spin2 = tk.Spinbox(
            self.monty,
            width=5,
            bd=8,
            state='readonly',
            command=self._spinBox,
            relief=tk.RIDGE
        )  # Types of boarders: tk.SUNKEN tk.RAISED tk.FLAT tk.GROOVE tk.RIDGE
        self.spin2['values'] = (1, 2, 3)
        self.spin2.grid(column=1, row=2)
        createToolTip(self.spin2, 'This is another Spin control.')

        # SCROLLED TEXT
        scrolledTextWidth = 30
        scrolledTextHeight = 3
        scrText = ScrolledText.ScrolledText(
            self.monty,
            width=scrolledTextWidth,
            height=scrolledTextHeight,
            wrap=tk.WORD
        )  # wrap=tk.WORD ... wraps words so a new line doesn't start mid-word
        scrText.grid(column=0, row=3, columnspan=3, sticky='WE')
        createToolTip(scrText, 'This is a ScrolledText widget.')

        # LABEL FRAME
        labelFrame = ttk.LabelFrame(self.tab2, text=" Labels in a frame ")
        labelFrame.grid(column=0, row=1, padx=20, pady=20, sticky='NW')
        ttk.Label(labelFrame, text="Label 1").grid(column=0, row=0)
        ttk.Label(labelFrame, text="Label 2").grid(column=0, row=1)
        ttk.Label(labelFrame, text="Label 3").grid(column=0, row=2)

        for subLabel in labelFrame.winfo_children():
            subLabel.grid_configure(padx=8, pady=4)

        # LEFT ALLIGNS ALL WIDGETS IN FRAME MONTY
        #for child in monty.winfo_children():
        #    child.grid_configure(sticky='W', padx=5, pady=5)

        # MENU BAR
        menuBar = tk.Menu(self.win)
        self.win.config(menu=menuBar)

        fileMenu = tk.Menu(menuBar, tearoff=0)
        fileMenu.add_command(label="New")
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self._quit)
        menuBar.add_cascade(label="File", menu=fileMenu)

        helpMenu = tk.Menu(menuBar, tearoff=0)  # Creating menu
        helpMenu.add_command(label="About",
                             command=self._aboutMsgBox)  # Adding items to menu
        helpMenu.add_command(label="Test warning", command=self._warning)
        helpMenu.add_command(label="Test error", command=self._error)
        helpMenu.add_command(label="Test question", command=self._question)
        menuBar.add_cascade(label="Help",
                            menu=helpMenu)  # Inserting menu into menu bar

        # A NEW TAB
        self.tab3 = ttk.Frame(self.tabControl)  # A new tab
        self.tabControl.add(self.tab3, text="Tab 3")  # Adds the tab
        self.tab33 = tk.Frame(self.tab3, bg='blue')
        self.tab33.pack()
        for orangeColor in range(2):
            canvas = tk.Canvas(self.tab33,
                               width=150,
                               height=80,
                               highlightthickness=0,
                               bg='orange')
            canvas.grid(row=orangeColor, column=orangeColor)

        strData = self.spin.get()
        print("Spinbox value: " + strData)

        self.nameEntered.focus()  # Place cursor into name Entry
コード例 #23
0
 def create_scrolled_text(self, ctn):
     self.scr = scrolledtext.ScrolledText(ctn, wrap=tk.WORD)
     self.scr.grid(column=0, row=4, columnspan=3, padx=3, pady=3)
     self.scr.insert("insert", "i like python...\n ")
     ttp.createToolTip(self.scr, "这是一个scrolled text控件")  #add a ToolTip
コード例 #24
0
ファイル: geo_full.py プロジェクト: pyIPP/trgui
    def __init__(self, sshot):

        if __name__ == '__main__':
            fmframe = tk.Tk()
        else:
            fmframe = tk.Toplevel()

        fmframe.geometry('1600x950')

# Menu bar

        menubar  = tk.Menu(fmframe)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Run & fit", command=self.surf)
        filemenu.add_command(label="Store u-files", command=self.store_u)
        filemenu.add_command(label="Plot surfaces", command=self.plot_sur)
        filemenu.add_command(label="Plot moments" , command=self.plot_mom)
        filemenu.add_separator()
        filemenu.add_command(label="Close", command=fmframe.destroy)
        menubar.add_cascade(label  = "File", menu=filemenu)
        fmframe.config(menu = menubar)

        canvframe = tk.Frame(fmframe, width=1600, height=800)
        butframe  = tk.Frame(fmframe)
        entframe  = tk.Frame(fmframe)
        for frame in canvframe, butframe, entframe:
            frame.pack(side=tk.TOP)

        profframe = tk.Frame(canvframe, width=590)
        pol_frame = tk.Frame(canvframe, width=1000)
        for frame in profframe, pol_frame:
            frame.pack(side=tk.TOP)

        canvframe.pack_propagate(0)
        entframe.pack_propagate(0)
        profframe.pack_propagate(0)
        pol_frame.pack_propagate(0)

        self.proffig = Figure()
        self.pol_fig = Figure((4, 7))
        self.proffig.subplots_adjust(left=0.15, bottom=0.05, right=0.9 , top=0.9)
        self.pol_fig.subplots_adjust(left=0.06, bottom=0.05, right=0.98, top=0.95)

        self.profcanvas = FigureCanvasTkAgg(self.proffig, master=profframe)
        self.pol_canvas = FigureCanvasTkAgg(self.pol_fig, master=pol_frame)

        pol_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        profframe.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        canvframe.pack(side=tk.TOP,  fill=tk.BOTH, expand=1)
        butframe.pack (side=tk.TOP,  fill=tk.BOTH, expand=1)
        entframe.pack (side=tk.TOP,  fill=tk.BOTH, expand=1)
        self.profcanvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.pol_canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

#-----------------
# Initialise plots
#-----------------

# Profiles
        self.proffig.clf()
        fsize = 16

        self.qsub = self.proffig.add_subplot(311)
        self.qsub.set_xlim(0,1)
        self.qsub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.qsub.set_ylabel('q profile')
        self.qplot, = self.qsub.plot([], [], 'g-')

        self.psub = self.proffig.add_subplot(312)
        self.psub.set_xlim((0, 1))
        self.psub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.psub.set_ylabel('Pressure [Pa]')
        self.pplot, = self.psub.plot([], [], 'm-')

        self.rbsub = self.proffig.add_subplot(313)
        self.rbsub.set_xlim(0,1)
        self.rbsub.set_xlabel(r'$\rho_{tor}$',fontsize=fsize)
        self.rbsub.set_ylabel('R*B$_\phi$')
        self.rbplot, = self.rbsub.plot([], [], 'm-')

#---------------
# Player buttons

        locdir = os.path.dirname(os.path.realpath(__file__))
        self.playfig     = tk.PhotoImage(file='%s/play.gif'     %locdir)
        self.pausefig    = tk.PhotoImage(file='%s/pause.gif'    %locdir)
        self.forwardfig  = tk.PhotoImage(file='%s/forward.gif'  %locdir)
        self.backwardfig = tk.PhotoImage(file='%s/backward.gif' %locdir)

        backward_button  = ttk.Button(self.toolframe, command=self.Backward,image=self.backwardfig)
        self.play_button = ttk.Button(self.toolframe, command=self.Play,    image=self.playfig)
        forward_button   = ttk.Button(self.toolframe, command=self.Forward, image=self.forwardfig)

        createToolTip(forward_button  , 'Go to next timestep')
        createToolTip(backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button, 'Forward animation/pause')

        for but in backward_button, self.play_button, forward_button:
            but.pack(side=tk.LEFT)

        plot_sur_btn     = tk.Button(butframe, command=self.plot_sur, text='Surfaces')
        plot_mom_btn     = tk.Button(butframe, command=self.plot_mom, text='Moments')

        createToolTip(forward_button  , 'Go to next timestep')
        createToolTip(backward_button , 'Go backward by one timestep')
        createToolTip(self.play_button, 'Forward animation/pause')

        sliderax = self.pol_fig.add_axes([0.1, 0.01, 0.6, 0.03], axisbg='yellow')
        self.sl_time = Slider(sliderax,'Time:', 0., 1., valinit=0.)
        self.sl_time.valtext.set_text('0.0000')

        def update_time(val):
            self.update_plot(val=val)

        self.sl_time.on_changed(update_time)
        self.cid2 = self.pol_fig.canvas.mpl_connect('scroll_event' , self.WheelInteraction)
        self.cid5 = self.pol_fig.canvas.mpl_connect('button_press_event', lambda event:self.pol_fig.canvas._tkcanvas.focus_set())

        for but in backward_button, self.play_button, forward_button, plot_sur_btn, plot_mom_btn:
            but.pack(side=tk.LEFT)

# Entry frame

        geoinit = {'shot':sshot, 'Nmom':7, 'ntheta':101, 'nrho':41, \
                   'exp':'AUGD', 'dia':'EQH', 'ed':0, \
                 'tbeg':4, 'tend':4.1, 'DeltaT':0.1}

        self.geodict = {}

        for key in ('shot', 'tbeg', 'tend', 'DeltaT', \
                    'exp', 'dia', 'ed', \
                    'Nmom', 'ntheta', 'nrho'):
            raw = ttk.Frame(entframe)
            raw.pack(side=tk.TOP)
            lbl = ttk.Label(entframe, text=key, width=5).pack(side=tk.LEFT)
            var = ttk.Entry(entframe, width=5)
            var.insert(0, geoinit[key])
            var.pack(side=tk.LEFT, padx='2 7')
            self.geodict[key] = var

        self.psep = self.pol_fig.add_subplot(111, aspect='equal')
        self.psep.set_xlim((0.8, 3.0))
        self.psep.set_ylim((-1.4, 1.4))
        self.psep.set_xlabel('R [m]')
        self.psep.set_ylabel('z [m]')

        gc_r, gc_z = map_equ_20180130.get_gc()
        for key in gc_r.iterjeys():
            self.psep.plot(gc_r[key], gc_z[key], 'b-')

        toolbar1 = NavigationToolbar2TkAgg(self.pol_canvas, pol_frame)
        toolbar1.update()

        toolbar2 = NavigationToolbar2TkAgg(self.profcanvas, profframe)
        toolbar2.update()

        self.pol_canvas.draw()

        fmframe.mainloop()