def __init__(self, cfg, doit):
        """ create the GUI panel widgets
            cfg -- parameter values (input and output)
            doit -- method to call to run simulations
            """

        # gather the basic parameters
        self.cfg = cfg
        self.doit = doit

        self.root = Tk()
        self.root.title('Data Reliability Model')
        t = Frame(self.root, bd=2 * self.BORDER)
        # w.iconbitmap(default='inktank.ico')   # ? windows only ?

        # left stack (DISK)
        f = Frame(t, bd=self.BORDER, relief=RIDGE)
        r = 1
        Label(f, text="Disk Type").grid(row=r)
        self.disk_type = StringVar(f)
        self.disk_type.set(self.diskTypes[0])
        OptionMenu(f, self.disk_type, *self.diskTypes,
                   command=self.diskchoice).grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Size (GiB)").grid(row=r)
        self.disk_size = Entry(f, width=self.long_wid)
        self.disk_size.delete(0, END)
        self.disk_size.insert(0, self.long_fmt % (cfg.disk_size / GiB))
        self.disk_size.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Primary FITs").grid(row=r)
        self.disk_fit = Entry(f, width=self.long_wid)
        self.disk_fit.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Secondary FITs").grid(row=r)
        self.disk_fit2 = Entry(f, width=self.long_wid)
        self.disk_fit2.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="NRE rate").grid(row=r)
        self.disk_nre = Spinbox(f, width=self.long_wid, values=self.nre_rates)
        self.disk_nre.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        while r < self.ROWS:
            Label(f).grid(row=r)
            r += 1
        Button(f, text="RELIABILITY", command=self.do_disk).grid(row=r)
        f.grid(column=1, row=1)
        self.diskchoice(self.diskTypes[0])  # set default disk type

        # second stack (RAID)
        f = Frame(t, bd=self.BORDER, relief=RIDGE)
        r = 1
        Label(f, text="RAID Type").grid(row=r)
        self.raid_type = StringVar(f)
        self.raid_type.set("RAID-1")
        OptionMenu(f, self.raid_type, *self.raidTypes,
                   command=self.raidchoice).grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Replace (hours)").grid(row=r)
        self.raid_rplc = Spinbox(f, width=self.short_wid,
                                 values=self.replace_times)
        self.raid_rplc.grid(row=r + 1)
        self.raid_rplc.delete(0, END)
        self.raid_rplc.insert(0, "%d" % cfg.raid_replace)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Rebuild (MiB/s)").grid(row=r)
        self.raid_speed = Spinbox(f, width=self.med_wid,
                                  values=self.rebuild_speeds)
        self.raid_speed.grid(row=r + 1)
        self.raid_speed.delete(0, END)
        self.raid_speed.insert(0, "%d" % (cfg.raid_recover / MiB))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Volumes").grid(row=r)
        self.raid_vols = Spinbox(f, from_=1, to=10, width=self.short_wid)
        self.raid_vols.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        self.raidchoice("RAID-1")   # set default number of volumes
        r += 3
        while r < self.ROWS:
            Label(f).grid(row=r)
            r += 1
        Button(f, text="RELIABILITY", command=self.do_raid).grid(row=r)
        f.grid(column=2, row=1)

        # third stack (RADOS)
        f = Frame(t, bd=self.BORDER, relief=RIDGE)
        r = 1
        Label(f, text="RADOS copies").grid(row=r)
        self.rados_cpys = Spinbox(f, values=(1, 2, 3, 4, 5, 6),
                                  width=self.short_wid)
        self.rados_cpys.grid(row=r + 1)
        self.rados_cpys.delete(0, END)
        self.rados_cpys.insert(0, "%d" % cfg.rados_copies)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Mark-out (min)").grid(row=r)
        self.rados_down = Spinbox(f, values=self.markout_times,
                                  width=self.short_wid)
        self.rados_down.grid(row=r + 1)
        self.rados_down.delete(0, END)
        self.rados_down.insert(0, "%d" % (cfg.rados_markout * 60))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Recovery (MiB/s)").grid(row=r)
        self.rados_speed = Spinbox(f, width=self.med_wid,
                                   values=self.rebuild_speeds)
        self.rados_speed.grid(row=r + 1)
        self.rados_speed.delete(0, END)
        self.rados_speed.insert(0, "%d" % (cfg.rados_recover / MiB))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Space Usage (%)").grid(row=r)
        self.rados_fullness = Spinbox(f, values=self.fullness,
                                      width=self.med_wid)
        self.rados_fullness.grid(row=r + 1)
        self.rados_fullness.delete(0, END)
        self.rados_fullness.insert(0, "%d" % (cfg.rados_fullness * 100))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Declustering (pg)").grid(row=r)
        self.rados_pgs = Entry(f, width=self.med_wid)
        self.rados_pgs.delete(0, END)
        self.rados_pgs.insert(0, self.med_fmt % cfg.rados_decluster)
        self.rados_pgs.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Stripe Length").grid(row=r)
        self.stripe_length = Entry(f, width=self.med_wid)
        self.stripe_length.delete(0, END)
        self.stripe_length.insert(0, self.med_fmt % cfg.stripe_length)
        self.stripe_length.grid(row=r + 1)
        Label(f).grid(row=r + 2)
        r += 3
        while r < self.ROWS:
            Label(f).grid(row=r)
            r += 1
        Button(f, text="RELIABILITY", command=self.do_rados).grid(row=r)
        f.grid(column=3, row=1)

        # fourth stack (remote site)
        r = 1
        f = Frame(t, bd=self.BORDER, relief=RIDGE)
        Label(f, text="RADOS Sites").grid(row=r)
        self.site_num = Spinbox(f, values=self.site_count,
                                width=self.short_wid)
        self.site_num.grid(row=r + 1)
        self.site_num.delete(0, END)
        self.site_num.insert(0, "%d" % cfg.remote_sites)
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Rep Latency (s)").grid(row=r)
        self.remote_latency = Spinbox(f, values=self.async_latencies,
                                      width=self.long_wid)
        self.remote_latency.grid(row=r + 1)
        self.remote_latency.delete(0, END)
        self.remote_latency.insert(0, "%d" % (cfg.remote_latency * 60 * 60))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Recovery (MiB/s)").grid(row=r)
        self.remote_speed = Spinbox(f, values=self.remote_speeds,
                                    width=self.med_wid)
        self.remote_speed.grid(row=r + 1)
        self.remote_speed.delete(0, END)
        self.remote_speed.insert(0, "%d" % (cfg.remote_recover / MiB))
        Label(f).grid(row=r + 2)
        r += 3
        Label(f, text="Disaster (years)").grid(row=r)
        self.remote_fail = Spinbox(f, values=self.site_destroy,
                                   width=self.long_wid)
        self.remote_fail.grid(row=r + 1)
        self.remote_fail.delete(0, END)
        self.remote_fail.insert(0, "1000")
        # FIX - get this from cfg ... but translate from FITS
        Label(f).grid(column=2, row=r + 2)
        r += 3
        Label(f, text="Site Recover (days)").grid(row=r)
        self.remote_avail = Spinbox(f, values=self.site_recover,
                                    width=self.long_wid)
        self.remote_avail.grid(row=r + 1)
        self.remote_avail.delete(0, END)
        self.remote_avail.insert(0, "30")
        # FIX - get this from cfg ... but translate from FITS
        Label(f).grid(row=r + 2)
        r += 3
        while r < self.ROWS:
            Label(f).grid(row=r)
            r += 1
        Button(f, text="RELIABILITY", command=self.do_sites).grid(row=r)
        f.grid(column=4, row=1)

        # and the control panel
        r = 2
        c = 1
        Label(t).grid(column=c, row=r)
        Label(t, text="NRE model").grid(column=c, row=r + 1)
        self.nre_model = StringVar(t)
        self.nre_model.set(self.cfg.nre_model)
        OptionMenu(t, self.nre_model, *self.nreTypes).grid(column=c, row=r + 2)

        c = 2
        Label(t).grid(column=c, row=r)
        Label(t, text="Period (years)").grid(column=c, row=r + 1)
        self.period = Spinbox(t, from_=1, to=10, width=self.short_wid)
        self.period.grid(column=c, row=r + 2)

        c = 3
        Label(t).grid(column=c, row=r)
        Label(t, text="Object size").grid(column=c, row=r + 1)
        # generate object sizes dynamically from parameters
        os = self.min_obj_size
        while os <= self.max_obj_size:
            if os < MB:
                s = "%dKB" % (os / KB)
            elif os < GB:
                s = "%dMB" % (os / MB)
            elif os < TB:
                s = "%dGB" % (os / GB)
            else:
                s = "%dTB" % (os / TB)
            self.object_sizes.append(s)
            os *= self.step_obj_size
        self.obj_size = Spinbox(t, values=self.object_sizes,
                                width=self.long_wid)
        self.obj_size.grid(column=c, row=r + 2)
        self.obj_size.delete(0, END)
        self.obj_size.insert(0, self.object_sizes[0])

        c = 4
        Label(t).grid(column=c, row=r)
        Label(t, text="Verbosity").grid(column=c, row=r + 1)
        self.verbosity = StringVar(t)
        self.verbosity.set(cfg.verbose)
        OptionMenu(t, self.verbosity, *self.verbosities).grid(column=c,
                                                              row=r + 2)

        # and then finalize everything
        t.grid()
    def make_entry(self,master,field,field_spec,values,bar):
        # print 'make entry',self.field_index,field,field_spec
        if field_spec['shape']=='tab':
            self.current_tab = Tab(master, field_spec['name'])
            bar.add(self.current_tab,field_spec['text'])
            self.tab_row=1
            return None
        elif field_spec['shape']=='sep':
            Label(self.current_tab,text='', anchor=W).grid(row=self.tab_row,column=0,sticky=W)
            self.tab_row+=1
            return None

        else:

            # print 'replace param in make entry',field
            # print 'content', field, self.field_content[field]
            # is it in the field content dictionary
            if not field in self.field_content:
                self.mon.log(self,"Value for field not found in opened file: " + field)
                return None
            else:
                if field_spec['must']=='yes':
                    bg='pink'
                else:
                    bg='white'
                    
                # write the label
                Label(self.current_tab,text=field_spec['text'], anchor=W).grid(row=self.tab_row,column=0,sticky=W)
                
                # make the editable field
                if field_spec['shape']in ('entry','colour','browse','font'):
                    obj=Entry(self.current_tab,bg=bg,width=40,font='arial 11')
                    obj.insert(END,self.field_content[field])
                    
                elif field_spec['shape']=='text':
                    obj=ScrolledText(self.current_tab,bg=bg,height=8,width=40,font='arial 11')
                    obj.insert(END,self.field_content[field])
                    
                elif field_spec['shape']=='spinbox':
                    obj=Spinbox(self.current_tab,bg=bg,values=values,wrap=True)
                    obj.insert(END,self.field_content[field])
                    
                elif field_spec['shape']=='option-menu': 
                    self.option_val = StringVar(self.current_tab)    
                    self.option_val.set(self.field_content[field])
                    obj = apply(OptionMenu, [self.current_tab, self.option_val] + values)
                    self.entries.append(self.option_val)
                    
                else:
                    self.mon.log(self,"Uknown shape for: " + field)
                    return None
                
                if field_spec['read-only']=='yes':
                    obj.config(state="readonly",bg='dark grey')
                    
                obj.grid(row=self.tab_row,column=1,sticky=W)

                # display buttons where required
                if field_spec['shape']=='browse':
                    but=Button(self.current_tab,width=1,height=1,bg='dark grey',command=(lambda o=obj: self.browse(o)))
                    but.grid(row=self.tab_row,column=2,sticky=W)
                    
                elif field_spec['shape']=='colour':
                    but=Button(self.current_tab,width=1,height=1,bg='dark grey',command=(lambda o=obj: self.pick_colour(o)))
                    but.grid(row=self.tab_row,column=2,sticky=W)
                    
                elif field_spec['shape']=='font':
                    but=Button(self.current_tab,width=1,height=1,bg='dark grey',command=(lambda o=obj: self.pick_font(o)))
                    but.grid(row=self.tab_row,column=2,sticky=W)

                self.tab_row+=1    
                return obj
Exemple #3
0
    def modifyUI(self):
        frame_bottom = self.frame_bottom
        frame_main = self.frame_main
        self.sliceView = [
            ImshowMplCanvas(frame_main) for k in range(self.shape[2])
        ]
        self.sliceSpin = [
            MySpinBox(frame_main, k) for k in range(self.shape[2])
        ]

        #Layout
        self.parent.title('CreateMask')

        max_spin = 0
        if self.mask4d:
            max_spin = self.shape[3] - 1
        self.spin_volume = Spinbox(frame_bottom,
                                   from_=0,
                                   to=max_spin,
                                   increment=1,
                                   command=self.change_volume,
                                   width=8)
        self.reset_box(self.spin_volume, 0)

        buttonMask = Button(frame_bottom,
                            text='B0 from Bval...',
                            command=self.createBaseImage)
        buttonMaskCreate = Button(frame_bottom,
                                  text='Create',
                                  command=self.createMaskAll)
        buttonSave = Button(frame_bottom, text='Save', command=self.saveMask)

        self.drawmask = BooleanVar()
        buttonDrawMask = Checkbutton(frame_bottom,
                                     text='Draw Mask',
                                     variable=self.drawmask,
                                     command=self.drawSlice)

        num_col = 3
        num_row = 6
        for col in range(self.shape[2] / num_row):
            for k in range(num_row):
                ind = col * num_row + k
                if ind >= self.shape[2]:
                    break
                self.sliceView[ind].get_tk_widget().grid(row=k,
                                                         column=col * num_col,
                                                         sticky=NSEW)
                self.sliceSpin[ind].grid(row=k, column=col * num_col + 1)
            self.frame_main.grid_columnconfigure(col * num_col, weight=1)

        for k in range(num_row):
            self.frame_main.grid_rowconfigure(k, weight=1)

        self.spin_volume.grid(row=0, column=0)
        buttonMask.grid(row=0, column=1)
        buttonMaskCreate.grid(row=0, column=2)
        buttonSave.grid(row=0, column=3)
        buttonDrawMask.grid(row=0, column=5)

        frame_bottom.pack(side=BOTTOM)
        frame_main.pack(fill=BOTH, expand=TRUE)
        self.pack(fill=BOTH, expand=True)
Exemple #4
0
qlep.bind("<Enter>", on_enterlep)
qlep.bind("<Leave>", on_leavelep)

#Everything concerning jets:

minnjet_val = IntVar()
minnjet_val.set(0)  # initialize integer for min number of jets
maxnjet_val = IntVar()
maxnjet_val.set(9)  # initialize integer for max number of jets

labelminjet = Label(frame1, text="Minimum:")
labelmaxjet = Label(frame1, text="Maximum:")  #Some labels for the entries

minjet_entry = Spinbox(frame1,
                       textvariable=minnjet_val,
                       from_=0,
                       to=9,
                       width=4)  #Entry for min number of jets
maxjet_entry = Spinbox(frame1,
                       textvariable=maxnjet_val,
                       from_=0,
                       to=9,
                       width=4)  #Entry for max number of jets

btagmin_val = IntVar()
btagmin_val.set(0)  #Initialise minimum b-jets
btagmax_val = IntVar()
btagmax_val.set(9)  #Initialise maximum b-jets

labelminbjet = Label(frame1, text="Minimum:")
labelmaxbjet = Label(frame1, text="Maximum:")  #Labels for b-jets entries
Exemple #5
0
    def initUI(self):
        self.parent.title(self.title)

        self.nosearch = BooleanVar(self)
        self.noresample = BooleanVar(self)

        i = 0
        #frame_top = Frame(self)
        #frame_top.grid(row=i, column=0, columnspan=6, sticky=EW)
        #Label(frame_top, text='topframe').grid(row=0, column=0, sticky=EW)
        #Label(frame_top, text='topframe').grid(row=0, column=1, sticky=EW)
        #Label(frame_top, text='topframe').grid(row=1, column=0, sticky=EW)
        #Label(frame_top, text='topframe').grid(row=1, column=1, sticky=EW)
        #Entry(frame_top, text='topframe').grid(row=0, column=0, sticky=EW)
        #Entry(frame_top, text='topframe').grid(row=0, column=1, sticky=EW)
        #Entry(frame_top, text='topframe').grid(row=1, column=0, sticky=EW)
        #Entry(frame_top, text='topframe').grid(row=1, column=1, sticky=EW)
        #frame_top.grid_columnconfigure(0, weight=1)
        #frame_top.grid_columnconfigure(1, weight=1)

        dddWidth = 4
        labelWidth = 10
        i += 1
        Label(self, text='Working dir', width=labelWidth).grid(row=i, column=0)
        self.txt_working = Entry(self)
        self.txt_working.grid(row=i, column=1, sticky=EW)
        btn_working = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.dirnameDialog_text(self.txt_working))
        btn_working.grid(row=i, column=2, sticky=W)
        i += 1
        Label(self, text='Parameters', width=labelWidth).grid(row=i, column=0)
        self.txt_param = Entry(self)
        self.txt_param.grid(row=i, column=1, sticky=EW)
        btn_param_read = Button(self, text='Read', command=self.read_param)
        btn_param_read.grid(row=i, column=2)
        btn_param_save = Button(self, text='Save', command=self.save_param)
        btn_param_save.grid(row=i, column=3)

        i += 1
        frm_prepa = Frame(self)
        ii = 0
        Label(frm_prepa, text='Subject', width=labelWidth).grid(row=ii,
                                                                column=0)
        self.txt_subject = Entry(frm_prepa)
        self.txt_subject.grid(row=ii, column=1, sticky=EW)
        btn_prepa = Button(frm_prepa,
                           text='Prepare DWIs',
                           command=self.run_prepare)
        btn_prepa.grid(row=ii, column=3)
        #btn_update = Button(frm_prepa, text='Update filenames', command=self.update_parameter); btn_update.grid(row=ii, column=4)
        btn_update = Button(frm_prepa,
                            text='Update filenames',
                            command=self.update_text_from_param)
        btn_update.grid(row=ii, column=4)

        ii += 1
        Label(frm_prepa, text='bval', width=labelWidth).grid(row=ii, column=0)
        self.txt_bval = Entry(frm_prepa)
        self.txt_bval.grid(row=ii, column=1, sticky=EW)
        btn_bval = Button(
            frm_prepa,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_bval))
        btn_bval.grid(row=ii, column=2, sticky=W)

        Label(frm_prepa, text='b0 threshold').grid(row=ii, column=3, sticky=E)
        self.txt_b0_threshold = Entry(frm_prepa, width=10)
        self.txt_b0_threshold.grid(row=ii, column=4)

        ii += 1
        Label(frm_prepa, text='bvec', width=labelWidth).grid(row=ii, column=0)
        self.txt_bvec = Entry(frm_prepa)
        self.txt_bvec.grid(row=ii, column=1, sticky=EW)
        btn_bvec = Button(
            frm_prepa,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_bvec))
        btn_bvec.grid(row=ii, column=2, sticky=W)

        Label(frm_prepa, text='high b threshold').grid(row=ii,
                                                       column=3,
                                                       sticky=E)
        self.txt_high_b_threshold = Entry(frm_prepa, width=10)
        self.txt_high_b_threshold.grid(row=ii, column=4)

        frm_prepa.grid_columnconfigure(1, weight=1)
        frm_prepa.grid(row=i,
                       rowspan=ii + 1,
                       column=0,
                       columnspan=6,
                       sticky=NSEW)
        ii += 1

        i += ii
        # TOPUP/EDDY or Rigid registration
        i += 1
        Label(self,
              text='  TOPUP/EDDY or Rigid registration').grid(row=i,
                                                              column=0,
                                                              columnspan=2,
                                                              sticky=W)
        i += 1
        frm_eddy = Frame(self)
        width = 10
        ii = 0
        jj = 0
        Label(frm_eddy, text='TOPUP', width=width, justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        jj += 1
        self.txt_topup_app = Entry(frm_eddy, width=width)
        self.txt_topup_app.grid(row=ii, column=jj)
        jj += 1
        Label(frm_eddy, text='Configure', width=width, justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        jj += 1
        self.txt_topup_config = Entry(frm_eddy)
        self.txt_topup_config.grid(row=ii, column=jj, sticky=EW)
        jj += 1
        btn_topup_config = Button(
            frm_eddy,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_topup_config))
        btn_topup_config.grid(row=ii, column=jj, sticky=W)
        jj += 1
        Label(frm_eddy, text='EDDY', width=width, justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        jj += 1
        self.txt_eddy_app = Entry(frm_eddy, width=width)
        self.txt_eddy_app.grid(row=ii, column=jj)

        frm_eddy.grid(row=i,
                      rowspan=ii + 1,
                      column=0,
                      columnspan=6,
                      sticky=NSEW)
        frm_eddy.grid_columnconfigure(3, weight=1)

        i += ii

        i += 1
        Label(self, text='B0', width=labelWidth).grid(row=i, column=0)
        self.txt_b0 = Entry(self)
        self.txt_b0.grid(row=i, column=1, sticky=EW)
        btn_b0 = Button(self,
                        text='...',
                        width=dddWidth,
                        command=lambda: self.filenameDialog_text(self.txt_b0))
        btn_b0.grid(row=i, column=2, sticky=W)
        btn_topup = Button(self, text='TOPUP', command=self.run_topup)
        btn_topup.grid(row=i, column=4, rowspan=2, sticky=NS)
        btn_rigid = Button(self, text='Rigid\nReg', command=self.run_eddy)
        btn_rigid.grid(row=i, column=5, rowspan=4, sticky=NS)

        i += 1
        Label(self, text='B0 mask', width=labelWidth).grid(row=i, column=0)
        self.txt_b0mask = Entry(self)
        self.txt_b0mask.grid(row=i, column=1, sticky=EW)
        btn_b0mask = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_b0mask))
        btn_b0mask.grid(row=i, column=2, sticky=W)
        btn_b0mask_make = Button(
            self,
            text='Make',
            command=lambda: self.make_mask(
                self.txt_b0.get(), mask4d=True, rtn=self.txt_b0mask))
        btn_b0mask_make.grid(row=i, column=3)

        i += 1
        Label(self, text='DWI', width=labelWidth).grid(row=i, column=0)
        self.txt_dwi = Entry(self)
        self.txt_dwi.grid(row=i, column=1, sticky=EW)
        btn_dwi_eddy = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dwi))
        btn_dwi_eddy.grid(row=i, column=2, sticky=W)
        btn_eddy = Button(self, text='EDDY', command=self.run_eddy)
        btn_eddy.grid(row=i, column=4, rowspan=2, sticky=NS)

        i += 1
        Label(self, text='DWI mask', width=labelWidth).grid(row=i, column=0)
        self.txt_dwi_mask = Entry(self)
        self.txt_dwi_mask.grid(row=i, column=1, sticky=EW)
        btn_dwi_mask = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dwi_mask))
        btn_dwi_mask.grid(row=i, column=2, sticky=W)
        btn_dwi_mask_make = Button(
            self,
            text='Make',
            command=lambda: self.make_mask(self.txt_dwi.get(),
                                           rtn=self.txt_dwi_mask))
        btn_dwi_mask_make.grid(row=i, column=3)

        i += 1
        Label(self, text='Output', width=labelWidth).grid(row=i, column=0)
        self.txt_output_eddy = Entry(self)
        self.txt_output_eddy.grid(row=i, column=1, sticky=EW)
        btn_output_eddy = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_output_eddy))
        btn_output_eddy.grid(row=i, column=2, sticky=W)
        btn_output_eddy_auto = Button(self,
                                      text='Auto',
                                      command=self.gen_eddy_outputname)
        btn_output_eddy_auto.grid(row=i, column=3)

        # 2D registration
        i += 1
        Label(self,
              text='  2D registration (X-Y translation)').grid(row=i,
                                                               column=0,
                                                               columnspan=2,
                                                               sticky=W)

        i += 1
        frm_param = Frame(self)
        width = 12
        width_half = 6
        ii = 0
        jj = 0
        Label(frm_param,
              text='Multi band',
              width=width,
              justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        #jj += 1; self.txt_multiband = Entry(frm_param, width=width_half); self.txt_multiband.grid(row=ii, column=jj)
        jj += 1
        self.spin_multiband = Spinbox(frm_param,
                                      from_=0,
                                      to=1000,
                                      increment=1,
                                      width=width_half)
        self.spin_multiband.grid(row=ii, column=jj)
        jj += 1
        Label(frm_param,
              text='#iteration',
              width=width,
              justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        #jj += 1; self.txt_nitr = Entry(frm_param, width=width_half); self.txt_nitr.grid(row=ii, column=jj)
        jj += 1
        self.spin_nitr = Spinbox(frm_param,
                                 from_=0,
                                 to=1000,
                                 increment=1,
                                 width=width_half)
        self.spin_nitr.grid(row=ii, column=jj)
        jj += 1
        Label(frm_param, text='', width=width, justify=RIGHT,
              anchor=E).grid(row=ii, column=jj, sticky=E)
        jj += 1
        self.chk_nosearch = Checkbutton(frm_param,
                                        text='nosearch',
                                        variable=self.nosearch,
                                        width=width)
        self.chk_nosearch.grid(row=ii, column=jj)
        jj += 1
        self.chk_noresample = Checkbutton(frm_param,
                                          text='noresample',
                                          variable=self.noresample,
                                          width=width)
        self.chk_noresample.grid(row=ii, column=jj)
        ii += 1
        jj = 0
        Label(frm_param, text='Schedule').grid(row=ii, column=jj, sticky=E)
        jj += 1
        self.txt_reg_config = Entry(frm_param)
        self.txt_reg_config.grid(row=ii, column=jj, sticky=EW, columnspan=4)
        jj += 4
        btn_reg_config = Button(
            frm_param,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_reg_config))
        btn_reg_config.grid(row=ii, column=jj, sticky=W)

        frm_param.grid_columnconfigure(4, weight=1)
        frm_param.grid(row=i,
                       rowspan=ii + 1,
                       column=0,
                       columnspan=6,
                       sticky=NSEW)

        i += ii

        i += 1
        Label(self, text='DWI', width=labelWidth).grid(row=i, column=0)
        self.txt_dwi_eddy = Entry(self)
        self.txt_dwi_eddy.grid(row=i, column=1, sticky=EW)
        btn_dwi_eddy = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dwi_eddy))
        btn_dwi_eddy.grid(row=i, column=2, sticky=W)
        btn_dwi_eddy_copy = Button(
            self,
            text='Copy',
            command=lambda: self.reset_entry(self.txt_dwi_eddy,
                                             self.txt_output_eddy.get()))
        btn_dwi_eddy_copy.grid(row=i, column=3)
        btn_dwi_eddy = Button(self,
                              text='Save\nParam',
                              command=self.save_reg_param)
        btn_dwi_eddy.grid(row=i, column=4, rowspan=2, sticky=NSEW)
        btn_dwi_eddy = Button(self, text='XY-Reg', command=self.run_xy_reg)
        btn_dwi_eddy.grid(row=i, column=5, rowspan=2, sticky=NSEW)

        i += 1
        Label(self, text='Mask', width=labelWidth).grid(row=i, column=0)
        self.txt_reg_mask = Entry(self)
        self.txt_reg_mask.grid(row=i, column=1, sticky=EW)
        btn_reg_mask = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_reg_mask))
        btn_reg_mask.grid(row=i, column=2, sticky=W)
        btn_reg_mask_make = Button(
            self,
            text='Make',
            command=lambda: self.make_mask(self.txt_dwi_eddy.get(),
                                           rtn=self.txt_reg_mask))
        btn_reg_mask_make.grid(row=i, column=3)

        i += 1
        Label(self, text='Slices', width=labelWidth).grid(row=i, column=0)
        self.txt_reg_slices = Entry(self)
        self.txt_reg_slices.grid(row=i, column=1, sticky=EW)

        i += 1
        Label(self, text='Outlier', width=labelWidth).grid(row=i, column=0)
        self.txt_reg_outlier = Entry(self)
        self.txt_reg_outlier.grid(row=i, column=1, sticky=EW)
        btn_reg_outlier = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_reg_outlier))
        btn_reg_outlier.grid(row=i, column=2, sticky=W)
        btn_reg_outlier_calculate = Button(self,
                                           text='Calculate',
                                           command=self.run_xy_reg_outlier)
        btn_reg_outlier_calculate.grid(row=i, column=3)
        btn_reg_apply = Button(self,
                               text='Applywarp',
                               command=self.run_applywarp)
        btn_reg_apply.grid(row=i, column=4, columnspan=2, sticky=EW)

        i += 1
        Label(self, text='Output', width=labelWidth).grid(row=i, column=0)
        self.txt_output_reg = Entry(self)
        self.txt_output_reg.grid(row=i, column=1, sticky=EW)
        btn_output_reg = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_output_reg))
        btn_output_reg.grid(row=i, column=2, sticky=W)
        btn_output_reg_auto = Button(self,
                                     text='Auto',
                                     command=self.gen_reg_outputname)
        btn_output_reg_auto.grid(row=i, column=3)

        # DTI
        i += 1
        Label(self, text='  DTI map with outlier rejection').grid(row=i,
                                                                  column=0,
                                                                  columnspan=2,
                                                                  sticky=W)

        i += 1
        Label(self, text='DWI_reg', width=labelWidth).grid(row=i, column=0)
        self.txt_dwi_dti = Entry(self)
        self.txt_dwi_dti.grid(row=i, column=1, sticky=EW)
        btn_dwi_dti = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dwi_dti))
        btn_dwi_dti.grid(row=i, column=2, sticky=W)
        btn_dwi_dti_copy = Button(
            self,
            text='Copy',
            command=lambda: self.reset_entry(self.txt_dwi_dti,
                                             self.txt_output_reg.get()))
        btn_dwi_dti_copy.grid(row=i, column=3)
        btn_dti_maps = Button(self,
                              text='Generate DTI maps',
                              command=self.run_generate_dti_maps)
        btn_dti_maps.grid(row=i, column=4, columnspan=2, sticky=EW)

        i += 1
        Label(self, text='DTI', width=labelWidth).grid(row=i, column=0)
        self.txt_dti = Entry(self)
        self.txt_dti.grid(row=i, column=1, sticky=EW)
        btn_dti = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dti))
        btn_dti.grid(row=i, column=2, sticky=W)
        btn_dti_auto = Button(self, text='Auto', command=self.gen_dti_name)
        btn_dti_auto.grid(row=i, column=3)
        btn_dti_outlier_calc = Button(self,
                                      text='Calculate Outlier',
                                      command=self.run_dti_outlier)
        btn_dti_outlier_calc.grid(row=i,
                                  column=4,
                                  columnspan=2,
                                  rowspan=2,
                                  sticky=NSEW)

        i += 1
        Label(self, text='Mask', width=labelWidth).grid(row=i, column=0)
        self.txt_md_mask = Entry(self)
        self.txt_md_mask.grid(row=i, column=1, sticky=EW)
        btn_md_mask = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_md_mask))
        btn_md_mask.grid(row=i, column=2, sticky=W)
        btn_md_mask_make = Button(self, text='Make', command=self.run_md_mask)
        btn_md_mask_make.grid(row=i, column=3)

        i += 1
        Label(self, text='Outlier', width=labelWidth).grid(row=i, column=0)
        self.txt_dti_outlier = Entry(self)
        self.txt_dti_outlier.grid(row=i, column=1, sticky=EW)
        btn_dti_outlier = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dti_outlier))
        btn_dti_outlier.grid(row=i, column=2, sticky=W)
        btn_dti_maps_itr = Button(
            self,
            text='Generate DTI maps',
            command=lambda: self.run_generate_dti_maps(outlier=True))
        btn_dti_maps_itr.grid(row=i, column=4, columnspan=2, sticky=EW)

        #i += 1
        #Label(self, text='DWI'          , width=labelWidth).grid(row=i, column=0)
        #self.txt_dwi_dti_itr = Entry(self); self.txt_dwi_dti_itr.grid(row=i, column=1, sticky=EW)
        #btn_dwi_dti_itr = Button(self, text='...', width=dddWidth, command=lambda:self.filenameDialog_text(self.txt_dwi_dti_itr))
        #btn_dwi_dti_itr.grid(row=i, column=2, sticky=W)

        #i += 1; Label(self, text='Output'       , width=labelWidth).grid(row=i, column=0)
        #self.txt_output_dti = Entry(self); self.txt_output_dti.grid(row=i, column=1, sticky=EW)
        #btn_output_dti = Button(self, text='...', width=dddWidth, command=lambda:self.filenameDialog_text(self.txt_output_dti))
        #btn_output_dti.grid(row=i, column=2, sticky=W)
        #btn_output_dti_auto = Button(self, text='Auto', command=self.gen_dti_outputname); btn_output_dti_auto.grid(row=i, column=3)

        # DTI Values
        i += 1
        Label(self, text='  DTI values').grid(row=i,
                                              column=0,
                                              columnspan=2,
                                              sticky=W)

        i += 1
        Label(self, text='DTI', width=labelWidth).grid(row=i, column=0)
        self.txt_dti_value = Entry(self)
        self.txt_dti_value.grid(row=i, column=1, sticky=EW)
        btn_dti_value = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dti_value))
        btn_dti_value.grid(row=i, column=2, sticky=W)
        btn_dwi_dti_value_copy = Button(
            self,
            text='Copy',
            command=lambda: self.reset_entry(self.txt_dti_value,
                                             self.txt_dti.get()))
        btn_dwi_dti_value_copy.grid(row=i, column=3)
        btn_dti_value_get = Button(self,
                                   text='Get DTI\nValues',
                                   command=self.run_get_dti_values)
        btn_dti_value_get.grid(row=i,
                               column=4,
                               rowspan=2,
                               columnspan=2,
                               sticky=NSEW)

        i += 1
        Label(self, text='ROI', width=labelWidth).grid(row=i, column=0)
        self.txt_dti_roi = Entry(self)
        self.txt_dti_roi.grid(row=i, column=1, sticky=EW)
        btn_dti_roi = Button(
            self,
            text='...',
            width=dddWidth,
            command=lambda: self.filenameDialog_text(self.txt_dti_roi))
        btn_dti_roi.grid(row=i, column=2, sticky=W)
        btn_dti_roi = Button(self, text='Make')
        btn_dti_roi.grid(row=i, column=3)

        i += 1
        Label(self, text='Output', width=labelWidth).grid(row=i, column=0)
        self.txt_output_dti_value = Entry(self)
        self.txt_output_dti_value.grid(row=i, column=1, sticky=EW)
        btn_output_dti_value = Button(self,
                                      text='...',
                                      width=dddWidth,
                                      command=lambda: self.filenameDialog_text(
                                          self.txt_output_dti_value))
        btn_output_dti_value.grid(row=i, column=2, sticky=W)
        btn_output_dti_value_auto = Button(
            self, text='Auto', command=self.gen_dti_value_outputname)
        btn_output_dti_value_auto.grid(row=i, column=3)

        self.grid_columnconfigure(1, weight=1)
        ni = i + 1
        for i in range(ni):
            self.grid_rowconfigure(i, weight=1, minsize=20)

        self.pack(fill=BOTH, expand=True)
Exemple #6
0
# Spinbox callback
def _spin():
    value = spin.get()
    #print(value)
    #scr.insert(tk.INSERT, value + '\n')


def _spin2():
    value = spin2.get()
    #print(value)
    #scr.insert(tk.INSERT, value + '\n')


# Adding 2 Spinbox widget using a set of values
spin = Spinbox(monty, from_=10, to=25, width=5, bd=8, command=_spin)
spin.grid(column=0, row=2)

spin2 = Spinbox(monty,
                values=('Python3入门', 'C语言', 'C++', 'Java', 'OpenCV'),
                width=13,
                bd=3,
                command=_spin2)
spin2.grid(column=1, row=2, sticky='W')

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

# Add Tooltip
Exemple #7
0
    def initUI(self):

        self.parent.title("DBLR for Dummies")
        self.pack(fill=BOTH, expand=True)

        #self.columnconfigure(0, weight=1)
        #self.rowconfigure(0, weight=1)
        # weight attibute is used to make them growable

        self.meas = IntVar()
        self.point = IntVar()
        self.base_path = StringVar()
        self.coef = DoubleVar()
        self.noise = DoubleVar()
        self.n_sigma = DoubleVar()
        self.thr1 = DoubleVar()
        self.thr2 = DoubleVar()
        self.thr3 = DoubleVar()
        self.graph_sw = BooleanVar()

        #Image
        factor = 0.65
        search = Image.open("NEXT_official_logo.jpg")
        width_org, height_org = search.size
        search_temp = search.resize(
            (int(width_org * factor), int(height_org * factor)),
            Image.ANTIALIAS)
        search_aux = ImageTk.PhotoImage(search_temp)
        label1 = Label(self, image=search_aux)
        label1.image = search_aux
        label1.grid(row=0, column=4, columnspan=2, rowspan=3, padx=5)

        #self.base_path.set("F:/DATOS_DAC/2052/pmt_0_trace_evt_")
        self.base_path.set("Argon.h5.z")
        e1 = Entry(self, textvariable=self.base_path, width=40)
        e1.grid(row=0, column=1, sticky=W, columnspan=3, pady=5, padx=5)
        e1_label = Label(self, text="Path & Name")
        e1_label.grid(row=0, column=0, columnspan=1, sticky=E, pady=5, padx=5)

        self.point.set("0")
        sb1 = Spinbox(self, from_=0, to=100, width=4, textvariable=self.point)
        sb1.grid(row=2, column=1, sticky=W, pady=5, padx=5)
        sb1_label = Label(self, text="PMT")
        sb1_label.grid(row=2, column=0, padx=5, sticky=E)

        self.meas.set("0")
        sb1 = Spinbox(self, from_=0, to=100, width=4, textvariable=self.meas)
        sb1.grid(row=2, column=3, sticky=W, pady=5, padx=5)
        sb1_label = Label(self, text="Event")
        sb1_label.grid(row=2, column=2, padx=5, sticky=E)

        #Check buttons
        #		cb1 = Checkbutton(self, text="New Graph", variable=self.graph_sw)
        #		cb1.select()
        #		cb1.grid(row=2,column=2, sticky=W)

        #PARAMETERS
        Integration_label = Label(self,
                                  text="PARAMETERS",
                                  font="Verdana 12 bold")
        Integration_label.grid(row=3,
                               column=1,
                               padx=5,
                               columnspan=2,
                               pady=10,
                               sticky=E)

        self.coef.set("1.65E-3")
        e2 = Entry(self, width=12, textvariable=self.coef)
        e2.grid(row=4, column=1, sticky=W, pady=5, padx=5)
        e2_label = Label(self, text="DBLR Coef")
        e2_label.grid(row=4, column=0, sticky=E, pady=5, padx=5)

        self.noise.set("0.75")
        e3 = Entry(self, width=12, textvariable=self.noise)
        e3.grid(row=4, column=3, sticky=W, pady=5, padx=5)
        e3_label = Label(self, text="Noise (LSB)")
        e3_label.grid(row=4, column=2, sticky=E, pady=5, padx=5)

        self.n_sigma.set("4")
        e4 = Entry(self, width=12, textvariable=self.n_sigma)
        e4.grid(row=4, column=5, sticky=W, pady=5, padx=5)
        e4_label = Label(self, text="Noise Threshold")
        e4_label.grid(row=4, column=4, sticky=E, pady=5, padx=5)

        self.thr1.set("0")
        e5 = Entry(self, width=12, textvariable=self.thr1)
        e5.grid(row=5, column=1, sticky=W, pady=5, padx=5)
        e5_label = Label(self, text="Threshold 1")
        e5_label.grid(row=5, column=0, sticky=E, pady=5, padx=5)

        self.thr2.set("0")
        e6 = Entry(self, width=12, textvariable=self.thr2)
        e6.grid(row=5, column=3, sticky=W, pady=5, padx=5)
        e6_label = Label(self, text="Threshold 2")
        e6_label.grid(row=5, column=2, sticky=E, pady=5, padx=5)

        self.thr3.set("0")
        e7 = Entry(self, width=12, textvariable=self.thr3)
        e7.grid(row=5, column=5, sticky=W, pady=5, padx=5)
        e7_label = Label(self, text="Threshold 3")
        e7_label.grid(row=5, column=4, sticky=E, pady=5, padx=5)

        # Main buttons
        obtn = Button(self, text="GO!!", command=self.DBLR_f)
        obtn.grid(row=6, column=4, sticky=E, pady=10)

        cbtn = Button(self, text="Quit", command=self.quit)
        cbtn.grid(row=6, column=5, sticky=E, pady=10)

        hbtn = Button(self, text="Help", command=self.help_f)
        hbtn.grid(row=6, column=0, sticky=W, pady=10)
Exemple #8
0
    def initUI(self):

        self.parent.title("Drone control")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        self.parent.bind_all("<Key>", self._keyDown)
        self.parent.bind_all("<KeyRelease>", self._keyUp)

        if system() == "Linux":
            self.parent.bind_all("<Button-4>", self._onMouseWheelUp)
            self.parent.bind_all("<Button-5>", self._onMouseWheelDown)

        else:
            #case of Windows
            self.parent.bind_all("<MouseWheel>", self._onMouseWheel)

        #Commands
        commandsFrame = tkFrame(self)
        commandsFrame.grid(column=0, row=0, sticky="WE")

        self._started = IntVar()
        self._startedCB = Checkbutton(commandsFrame,
                                      text="On",
                                      variable=self._started,
                                      command=self._startedCBChanged)
        self._startedCB.pack(side=LEFT, padx=4)

        #         self._integralsCB = Checkbutton(commandsFrame, text="Int.", variable=self._integralsEnabled, \
        #                                         command=self._integralsCBChanged, state=DISABLED)
        #         self._integralsCB.pack(side=LEFT, padx=4)

        self._quitButton = Button(commandsFrame,
                                  text="Quit",
                                  command=self.exit)
        self._quitButton.pack(side=LEFT, padx=2, pady=2)

        #         self._angleLbl = Label(commandsFrame, text="Angle")
        #         self._angleLbl.pack(side=LEFT, padx=4)
        #
        #         self._angleEntry = Entry(commandsFrame, state=DISABLED)
        #         self._angleEntry.pack(side=LEFT)

        #Info
        infoFrame = tkFrame(self)
        infoFrame.grid(column=1, row=1, sticky="NE", padx=4)

        #Throttle
        Label(infoFrame, text="Throttle").grid(column=0, row=0, sticky="WE")
        self._throttleTexts = [
            StringVar(), StringVar(),
            StringVar(), StringVar()
        ]
        Entry(infoFrame,
              textvariable=self._throttleTexts[3],
              state=DISABLED,
              width=5).grid(column=0, row=1)
        Entry(infoFrame,
              textvariable=self._throttleTexts[0],
              state=DISABLED,
              width=5).grid(column=1, row=1)
        Entry(infoFrame,
              textvariable=self._throttleTexts[2],
              state=DISABLED,
              width=5).grid(column=0, row=2)
        Entry(infoFrame,
              textvariable=self._throttleTexts[1],
              state=DISABLED,
              width=5).grid(column=1, row=2)

        #Angles
        Label(infoFrame, text="Angles").grid(column=0, row=3, sticky="WE")
        self._angleTexts = [StringVar(), StringVar(), StringVar()]
        for index in range(3):
            Entry(infoFrame,
                  textvariable=self._angleTexts[index],
                  state=DISABLED,
                  width=5).grid(column=index, row=4)

        #Accels
        Label(infoFrame, text="Accels").grid(column=0, row=5, sticky="WE")
        self._accelTexts = [StringVar(), StringVar(), StringVar()]
        for index in range(3):
            Entry(infoFrame,
                  textvariable=self._accelTexts[index],
                  state=DISABLED,
                  width=5).grid(column=index, row=6)

        #Speeds
        Label(infoFrame, text="Speeds").grid(column=0, row=7, sticky="WE")
        self._speedTexts = [StringVar(), StringVar(), StringVar()]
        for index in range(3):
            Entry(infoFrame,
                  textvariable=self._speedTexts[index],
                  state=DISABLED,
                  width=5).grid(column=index, row=8)

        #Height
        Label(infoFrame, text="Height").grid(column=0, row=9, sticky="E")
        self._heightText = StringVar()
        Entry(infoFrame,
              textvariable=self._heightText,
              state=DISABLED,
              width=5).grid(column=1, row=9)

        #Loop rate
        Label(infoFrame, text="Loop @").grid(column=0, row=10, sticky="E")
        self._loopRateText = StringVar()
        Entry(infoFrame,
              textvariable=self._loopRateText,
              state=DISABLED,
              width=5).grid(column=1, row=10)
        Label(infoFrame, text="Hz").grid(column=2, row=10, sticky="W")

        #control

        controlFrame = tkFrame(self)
        controlFrame.grid(column=0, row=1, sticky="W")

        self._throttle = DoubleVar()

        if Cockpit.THROTTLE_BY_USER:

            self._thrustScale = Scale(controlFrame, orient=VERTICAL, from_=100.0, to=0.0, \
                                tickinterval=0, variable=self._throttle, resolution=Cockpit.THROTTLE_RESOLUTION, \
                                length=200, showvalue=1, \
                                state=DISABLED,
                                command=self._onThrustScaleChanged)

        else:

            self._thrustScale = Scale(controlFrame, orient=VERTICAL, from_=100.0, to=-100.0, \
                                tickinterval=0, variable=self._throttle, \
                                length=200, showvalue=1, \
                                state=DISABLED,
                                command=self._onThrustScaleChanged)

        self._thrustScale.bind("<Double-Button-1>",
                               self._onThrustScaleDoubleButton1, "+")
        self._thrustScale.grid(column=0)

        self._shiftCanvas = Canvas(controlFrame, bg="white", height=400, width=400, \
                             relief=SUNKEN)
        self._shiftCanvas.bind("<Button-1>", self._onMouseButton1)
        #self._shiftCanvas.bind("<ButtonRelease-1>", self._onMouseButtonRelease1)
        self._shiftCanvas.bind("<B1-Motion>", self._onMouseButton1Motion)
        self._shiftCanvas.bind("<Double-Button-1>", self._onMouseDoubleButton1)

        self._shiftCanvas.bind("<Button-3>", self._onMouseButton3)
        #self._shiftCanvas.bind("<ButtonRelease-3>", self._onMouseButtonRelease3)
        self._shiftCanvas.bind("<B3-Motion>", self._onMouseButton3Motion)

        self._shiftCanvas.grid(row=0, column=1, padx=2, pady=2)
        self._shiftCanvas.create_oval(1, 1, 400, 400, outline="#ff0000")
        self._shiftCanvas.create_line(200, 2, 200, 400, fill="#ff0000")
        self._shiftCanvas.create_line(2, 200, 400, 200, fill="#ff0000")
        self._shiftMarker = self._shiftCanvas.create_oval(196,
                                                          196,
                                                          204,
                                                          204,
                                                          outline="#0000ff",
                                                          fill="#0000ff")

        self._yaw = DoubleVar()
        self._yawScale = Scale(controlFrame, orient=HORIZONTAL, from_=-100.0, to=100.0, \
                            tickinterval=0, variable=self._yaw, \
                            length=200, showvalue=1, \
                            command=self._onYawScaleChanged)
        self._yawScale.bind("<Double-Button-1>", self._onYawScaleDoubleButton1,
                            "+")
        self._yawScale.grid(row=1, column=1)

        self._controlKeyActive = False

        #PID calibration

        pidCalibrationFrame = tkFrame(self)
        pidCalibrationFrame.grid(column=0, row=2, sticky="WE")

        self._pidSelected = StringVar()
        self._pidSelected.set("--")
        self._pidListBox = OptionMenu(pidCalibrationFrame, self._pidSelected, "--", \
                                      Cockpit.KEY_ANG_SPEED, Cockpit.KEY_ANGLES, Cockpit.KEY_ACCEL, \
                                       command=self._onPidListBoxChanged)
        self._pidListBox.pack(side=LEFT, padx=2)
        self._pidListBox.config(width=10)

        self._axisSelected = StringVar()
        self._axisSelected.set("--")
        self._axisListBox = OptionMenu(pidCalibrationFrame, self._axisSelected, "--", "X", "Y", "Z", \
                                       command=self._onAxisListBoxChanged)
        self._axisListBox.pack(side=LEFT, padx=2)
        self._axisListBox.config(state=DISABLED)

        Label(pidCalibrationFrame, text="P").pack(side=LEFT, padx=(14, 2))

        self._pidPString = StringVar()
        self._pidPString.set("0.00")
        self._pidPSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidPString, command=self._onPidSpinboxChanged)
        self._pidPSpinbox.pack(side=LEFT, padx=2)

        Label(pidCalibrationFrame, text="I").pack(side=LEFT, padx=(14, 2))

        self._pidIString = StringVar()
        self._pidIString.set("0.00")
        self._pidISpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidIString, command=self._onPidSpinboxChanged)
        self._pidISpinbox.pack(side=LEFT, padx=2)

        Label(pidCalibrationFrame, text="D").pack(side=LEFT, padx=(14, 2))

        self._pidDString = StringVar()
        self._pidDString.set("0.00")
        self._pidDSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidDString, command=self._onPidSpinboxChanged)
        self._pidDSpinbox.pack(side=LEFT, padx=2)

        #debug
        debugFrame = tkFrame(self)
        debugFrame.grid(column=0, row=3, sticky="WE")

        self._debugMsg = Message(debugFrame,
                                 anchor="nw",
                                 justify=LEFT,
                                 relief=SUNKEN,
                                 width=300)
        self._debugMsg.pack(fill=BOTH, expand=1)
    def __init__(self, master, max_num_features, num_frames, mser_image):
        Toplevel.__init__(self, master)

        self.protocol('WM_DELETE_WINDOW', self.withdraw)

        self.notebook = ttk.Notebook(self)
        frame_feats = ttk.Frame(self.notebook)
        frame_forest = ttk.Frame(self.notebook)
        frame_mser = ttk.Frame(self.notebook)
        frame_other = ttk.Frame(self.notebook)
        self.notebook.add(frame_feats, text="Features ")
        self.notebook.add(frame_forest, text=" Forest  ")
        self.notebook.add(frame_mser, text=" MSER  ")
        self.notebook.add(frame_other, text=" Other  ")

        self.max_num_feats = max_num_features
        self.selection = None

        self.mser_image = mser_image

        rand_row = random.randint(1, 512 - 200)
        rand_col = random.randint(1, 512 - 110)
        self.mser_area = mser_image[rand_row:rand_row + 180,
                                    rand_col:rand_col + 100]

        # read images from icons folder
        self.hf0_img = PhotoImage(file="./icons/hf0.gif")
        self.hf1_img = PhotoImage(file="./icons/hf1.gif")
        self.hf2_img = PhotoImage(file="./icons/hf2.gif")
        self.hf3_img = PhotoImage(file="./icons/hf3.gif")
        self.hf4_img = PhotoImage(file="./icons/hf4.gif")
        self.hf5_img = PhotoImage(file="./icons/hf5.gif")

        self.features_vars = list()
        for i in range(max_num_features):
            self.features_vars.append(IntVar())

        Label(frame_feats,
              text="Patch size (" + u"\N{GREEK SMALL LETTER PI}" + "):").grid(
                  row=0, column=0, pady=5)
        self.patch_size_spinbox = Spinbox(frame_feats, from_=3, to=30, width=3)
        self.patch_size_spinbox.delete(0, END)
        self.patch_size_spinbox.insert(END, 10)
        self.patch_size_spinbox.grid(row=0, column=1, padx=5)

        f1 = ttk.Labelframe(frame_feats, text='Mean filter')
        f1.grid(row=1, columnspan=2)

        Label(f1, text=u"\N{GREEK SMALL LETTER PI}").grid(row=0, column=0)
        Checkbutton(f1, text="R",
                    variable=self.features_vars[0]).grid(row=0, column=1)
        Checkbutton(f1, text="G",
                    variable=self.features_vars[1]).grid(row=0, column=2)
        Checkbutton(f1, text="B",
                    variable=self.features_vars[2]).grid(row=0, column=3)

        Label(f1, text=u"\N{GREEK SMALL LETTER PI}" + "/2").grid(row=1,
                                                                 column=0)
        Checkbutton(f1, text="R",
                    variable=self.features_vars[3]).grid(row=1, column=1)
        Checkbutton(f1, text="G",
                    variable=self.features_vars[4]).grid(row=1, column=2)
        Checkbutton(f1, text="B",
                    variable=self.features_vars[5]).grid(row=1, column=3)

        f2 = ttk.Labelframe(frame_feats, text="Gaussian filter")
        f2.grid(row=2, columnspan=2)

        Label(f2, text=str(1.0)).grid(row=0, column=0)
        Checkbutton(f2, text="R",
                    variable=self.features_vars[6]).grid(row=0, column=1)
        Checkbutton(f2, text="G",
                    variable=self.features_vars[7]).grid(row=0, column=2)
        Checkbutton(f2, text="B",
                    variable=self.features_vars[8]).grid(row=0, column=3)

        Label(f2, text=str(3.5)).grid(row=1, column=0)
        Checkbutton(f2, text="R",
                    variable=self.features_vars[9]).grid(row=1, column=1)
        Checkbutton(f2, text="G",
                    variable=self.features_vars[10]).grid(row=1, column=2)
        Checkbutton(f2, text="B",
                    variable=self.features_vars[11]).grid(row=1, column=3)

        f3 = ttk.Labelframe(frame_feats, text="Laplacian of gaussian")
        f3.grid(row=3, columnspan=2)

        Label(f3, text=str(2.0)).grid(row=0, column=0)
        Checkbutton(f3, text="R",
                    variable=self.features_vars[12]).grid(row=0, column=1)
        Checkbutton(f3, text="G",
                    variable=self.features_vars[13]).grid(row=0, column=2)
        Checkbutton(f3, text="B",
                    variable=self.features_vars[14]).grid(row=0, column=3)

        Label(f3, text=str(3.5)).grid(row=1, column=0)
        Checkbutton(f3, text="R",
                    variable=self.features_vars[15]).grid(row=1, column=1)
        Checkbutton(f3, text="G",
                    variable=self.features_vars[16]).grid(row=1, column=2)
        Checkbutton(f3, text="B",
                    variable=self.features_vars[17]).grid(row=1, column=3)

        f4 = ttk.Labelframe(frame_feats, text="Haar-like features")
        f4.grid(row=1, rowspan=2, column=3, padx=5)

        Checkbutton(f4, image=self.hf0_img,
                    variable=self.features_vars[18]).grid(row=0, column=0)
        Checkbutton(f4, image=self.hf1_img,
                    variable=self.features_vars[19]).grid(row=0, column=1)
        Checkbutton(f4, image=self.hf2_img,
                    variable=self.features_vars[20]).grid(row=1, column=0)
        Checkbutton(f4, image=self.hf3_img,
                    variable=self.features_vars[21]).grid(row=1, column=1)
        Checkbutton(f4, image=self.hf4_img,
                    variable=self.features_vars[22]).grid(row=2, column=0)
        Checkbutton(f4, image=self.hf5_img,
                    variable=self.features_vars[23]).grid(row=2, column=1)

        buttons_paned_window = PanedWindow(frame_feats, orient=VERTICAL)
        buttons_paned_window.grid(row=3, column=3)

        self.select_all_button = Button(buttons_paned_window,
                                        text="Select all",
                                        command=self._select_all)
        buttons_paned_window.add(self.select_all_button)

        self.clear_selection_button = Button(buttons_paned_window,
                                             text="Clear selection",
                                             command=self._clear_selection)
        buttons_paned_window.add(self.clear_selection_button)

        # default values
        for j in [0, 1, 3, 6, 7, 9, 15, 21, 23]:
            self.features_vars[j].set(1)

        # FOREST FRAMES
        # number of trees
        f5 = ttk.Labelframe(frame_forest, text="Number of trees")
        f5.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f5, text="N").grid(row=1, column=0)
        self.num_trees_scale = Scale(f5,
                                     from_=5,
                                     to=500,
                                     resolution=5,
                                     orient=HORIZONTAL)
        self.num_trees_scale.set(300)
        self.num_trees_scale.grid(row=0, column=1, rowspan=2)

        # depth single tree
        f6 = ttk.Labelframe(frame_forest, text="Depth single tree")
        f6.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f6, text="d").grid(row=1, column=0)
        self.depth_tree_scale = Scale(f6, from_=2, to=20, orient=HORIZONTAL)
        self.depth_tree_scale.set(3)
        self.depth_tree_scale.grid(row=0, column=1, rowspan=2)

        # percentage number of features
        f7 = ttk.Labelframe(frame_forest, text="% subset of features")
        f7.grid(row=2, columnspan=2, pady=5, padx=5)
        Label(f7, text="m").grid(row=1, column=0)
        self.percentage_feats_scale = Scale(f7,
                                            from_=0.0,
                                            to=1,
                                            resolution=0.05,
                                            orient=HORIZONTAL)
        self.percentage_feats_scale.set(0.5)
        self.percentage_feats_scale.grid(row=0, column=1, rowspan=2)

        # mser frame
        # delta
        f8 = ttk.Labelframe(frame_mser, text="Delta")
        f8.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f8, text=u"\N{GREEK SMALL LETTER DELTA}").grid(row=1, column=0)
        self.delta_scale = Scale(f8,
                                 from_=1,
                                 to=10,
                                 resolution=1,
                                 orient=HORIZONTAL)
        self.delta_scale.set(2)
        self.delta_scale.grid(row=0, column=1, rowspan=2)

        # min area
        f9 = ttk.Labelframe(frame_mser, text="Minimum area")
        f9.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f9, text="m").grid(row=1, column=0)
        self.min_area_scale = Scale(f9, from_=2, to=200, orient=HORIZONTAL)
        self.min_area_scale.set(10)
        self.min_area_scale.grid(row=0, column=1, rowspan=2)

        # percentage number of features
        f10 = ttk.Labelframe(frame_mser, text="Maximum area")
        f10.grid(row=2, columnspan=2, pady=5, padx=5)
        Label(f10, text="M").grid(row=1, column=0)
        self.max_area_scale = Scale(f10,
                                    from_=50,
                                    to=1000,
                                    resolution=5,
                                    orient=HORIZONTAL)
        self.max_area_scale.set(350)
        self.max_area_scale.grid(row=0, column=1, rowspan=2)

        # mser image
        f11 = ttk.Labelframe(frame_mser)
        f11.grid(row=0, rowspan=3, column=2, padx=5)

        self.mser_img_array = Image.fromarray(self.mser_area, "RGB")
        self.mser_img = ImageTk.PhotoImage(self.mser_img_array)

        img_label = Label(f11, image=self.mser_img)
        img_label.grid(row=0, column=0)

        buttons_p_w_mser = PanedWindow(f11, orient=HORIZONTAL)
        try_button = Button(f11, text="Try", command=self.try_mser)
        buttons_p_w_mser.add(try_button)
        change_button = Button(f11, text="New img", command=self.change_mser)
        buttons_p_w_mser.add(change_button)
        buttons_p_w_mser.grid(row=1, column=0)

        # other frame
        f12 = ttk.Labelframe(frame_other, text="Refinement")
        f12.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f12, text=u"\N{GREEK CAPITAL LETTER PHI}_l").grid(row=1,
                                                                column=0)
        self.low_thresh_scale = Scale(f12,
                                      from_=0,
                                      to=1,
                                      resolution=0.05,
                                      orient=HORIZONTAL,
                                      length=90)
        self.low_thresh_scale.set(0.45)
        self.low_thresh_scale.grid(row=0, column=1, rowspan=2)
        Label(f12, text=u"\N{GREEK CAPITAL LETTER PHI}_h").grid(row=3,
                                                                column=0)
        self.high_thresh_scale = Scale(f12,
                                       from_=0,
                                       to=1,
                                       resolution=0.05,
                                       orient=HORIZONTAL,
                                       length=90)
        self.high_thresh_scale.set(0.65)
        self.high_thresh_scale.grid(row=2, column=1, rowspan=2)

        f13 = ttk.Labelframe(frame_other, text="Dots distance")
        f13.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f13, text=u"     \N{GREEK SMALL LETTER SIGMA}").grid(row=1,
                                                                   column=0)
        self.dots_distance_scale = Scale(f13,
                                         from_=1,
                                         to=20,
                                         resolution=1,
                                         orient=HORIZONTAL,
                                         length=90)
        self.dots_distance_scale.set(6)
        self.dots_distance_scale.grid(row=0, column=1, rowspan=2)

        f14 = ttk.Labelframe(frame_other, text="Tracks")
        f14.grid(row=0, column=3, pady=5, padx=5)
        Label(f14, text="N").grid(row=1, column=0)
        self.num_frames_tracks_spinbox = Spinbox(f14,
                                                 from_=2,
                                                 to=num_frames,
                                                 width=10)
        self.num_frames_tracks_spinbox.delete(0, END)
        self.num_frames_tracks_spinbox.insert(END, num_frames)
        self.num_frames_tracks_spinbox.grid(row=0, column=1, rowspan=2)

        Label(f14, text=u"\N{GREEK SMALL LETTER TAU}").grid(row=3, column=0)
        self.gaps_scale = Scale(f14,
                                from_=1,
                                to=10,
                                resolution=1,
                                orient=HORIZONTAL,
                                length=90)
        self.gaps_scale.set(2)
        self.gaps_scale.grid(row=2, column=1, rowspan=2)

        self.notebook.pack(padx=1, pady=1)

        save_button = Button(self,
                             text=" Save and Close window ",
                             command=self.withdraw)
        save_button.pack(pady=2)
from Tkinter import Tk, Spinbox
from ttk import Style, Label, Button, Combobox

top = Tk()
Style().configure("TButton", foreground = 'white', background = 'red')

Label(top, text = 'Animals(in pairs; min: pair, ' 'max: dozen)').pack()
Label(top, text='Number:').pack()

Spinbox(top, from_= 2, to = 12, increment=2, font = 'Helvetica -14 bold').pack()

Label(top, text = 'Type:').pack()

Combobox(top, values=('dog', 'cat', 'hamster', 'python', 'Java')).pack()

Button(top, text='QUIT', command=top.quit, style="TButton").pack()

top.mainloop()
Exemple #11
0
    def initUI(self):

        self.parent.title("FIND SPE VALUE")
        self.pack(fill=BOTH, expand=True)

        self.columnconfigure(0, weight=1)
        #self.rowconfigure(0, weight=1)
        # weight attibute is used to make them growable

        self.graph_cb = BooleanVar()
        self.bins = IntVar()
        self.path = StringVar()
        self.n_files = IntVar()
        self.start_s = IntVar()
        self.end_s = IntVar()
        self.guess = IntVar()

        search = Image.open("next_logo.jpg")
        search_temp = search.resize((160, 200), Image.ANTIALIAS)
        search_aux = ImageTk.PhotoImage(search_temp)
        label1 = Label(self, image=search_aux)
        label1.image = search_aux
        label1.grid(row=0,
                    column=0,
                    columnspan=10,
                    rowspan=10,
                    sticky=E + W + S + N)

        #Number of Files and Bins. Spin Box
        self.n_files.set("2000")
        sb1 = Spinbox(self,
                      from_=1,
                      to=10000,
                      width=6,
                      textvariable=self.n_files)
        sb1.grid(row=1, column=4, sticky=W)
        sb1_label = Label(self, text="Files")
        sb1_label.grid(row=1, column=3, padx=5, sticky=E)

        self.bins.set("50")
        sb2 = Spinbox(self, from_=10, to=200, width=6, textvariable=self.bins)
        sb2.grid(row=1, column=6, sticky=W)
        sb2_label = Label(self, text="Hist. Bins")
        sb2_label.grid(row=1, column=5, padx=5, sticky=E)

        # INTEGRATION LIMITS
        Integration_label = Label(self,
                                  text="INTEGRATION",
                                  font="Verdana 12 bold")
        Integration_label.grid(row=3, column=4, padx=5, columnspan=2)
        self.start_s.set("1732")
        sb3 = Spinbox(self,
                      from_=1,
                      to=10000,
                      width=6,
                      textvariable=self.start_s)
        sb3.grid(row=4, column=4, sticky=W)
        sb3_label = Label(self, text="StartPoint")
        sb3_label.grid(row=4, column=3, padx=5, sticky=E)

        self.end_s.set("1752")
        sb4 = Spinbox(self,
                      from_=1,
                      to=10000,
                      width=6,
                      textvariable=self.end_s)
        sb4.grid(row=4, column=6, sticky=W)
        sb4_label = Label(self, text="EndPoint")
        sb4_label.grid(row=4, column=5, padx=5, sticky=E)
        sb4_label = Label(self, text="")
        sb4_label.grid(row=4, column=7, padx=5, sticky=E)

        # FITTING PARAMETERS
        Integration_label = Label(self, text="FITTING", font="Verdana 12 bold")
        Integration_label.grid(row=6, column=4, padx=5, columnspan=2)
        self.guess.set("-20")
        sb5 = Spinbox(self, from_=-50, to=-1, width=6, textvariable=self.guess)
        sb5.grid(row=7, column=4, sticky=W)
        sb5_label = Label(self, text="SPE guess")
        sb5_label.grid(row=7, column=5, padx=5, sticky=W)

        #Check buttons
        cb1 = Checkbutton(self,
                          text="MultiGraph Output",
                          variable=self.graph_cb)
        cb1.select()
        cb1.grid(row=7, column=6, sticky=W)

        #Text Box
        #self.path.set("F:/DATOS_DAC/spe_1230/2046/pmt_0_trace_evt_")
        self.path.set("spe_1230_2046.h5.z")
        e1 = Entry(self, textvariable=self.path, width=45)
        e1.grid(row=10, column=3, sticky=W, columnspan=10, padx=10, pady=5)
        e1_label = Label(self, text="DataSet path (including name file)")
        e1_label.grid(row=9, column=3, sticky=W, columnspan=10, padx=10)

        # Main buttons
        obtn = Button(self, text="GO!!", command=self.SPE_f)
        obtn.grid(row=14, column=5, sticky=E, pady=5)

        cbtn = Button(self, text="Quit", command=self.quit)
        cbtn.grid(row=14, column=6, sticky=E, pady=5)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=14, column=0, sticky=W, pady=5)