当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.OptionMenu类代码示例

本文整理汇总了Python中tkinter.OptionMenu的典型用法代码示例。如果您正苦于以下问题:Python OptionMenu类的具体用法?Python OptionMenu怎么用?Python OptionMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OptionMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
        PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
        self.pairs = None
        
        eframe = self.eframe = LabelFrame(self,text="Options") 
        #,fg=textLightColor,bg=baseColor)
        eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 )
        
        label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor)
        label.grid(row=3,column=0,sticky=W,padx=10,pady=5)

        PipelineLabels = ['Initial QC', 
			  'Germline',
			  'Somatic Tumor-Normal',
                          'Somatic Tumor-Only']
        Pipelines=["initialqcgenomeseq",
                   "wgslow", 
		   'wgs-somatic',
                   'wgs-somatic-tumoronly']

        self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}
        PipelineLabel = self.PipelineLabel = StringVar()
        Pipeline = self.Pipeline = StringVar()
        PipelineLabel.set(PipelineLabels[0])
        
        #om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller)
        om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller)
        om.config()#bg = widgetBgColor,fg=widgetFgColor)
        om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor)
        #om.pack(side=LEFT,padx=20,pady=5)
        om.grid(row=3,column=1,sticky=W,padx=10,pady=5)
开发者ID:jlac,项目名称:Pipeliner,代码行数:31,代码来源:genomeseq.py

示例2: Example

class Example(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)

        self.dict = {'Asia': ['Japan', 'China', 'India'],
                     'Europe': ['Portugal', 'Switzerland', 'Ukraine']}

        self.var_a = StringVar(self)
        self.var_b = StringVar(self)

        self.var_a.trace('w', self.update_options)

        self.option_menu_a = OptionMenu(self, self.var_a, *self.dict.keys())
        self.option_menu_a.pack(side="top")
        self.option_menu_a["width"] = 10
        self.option_menu_b = OptionMenu(self, self.var_b, '')
        self.option_menu_b["width"] = 10
        self.option_menu_b.pack(side="top")

        self.var_a.set('Asia')

    def update_options(self, *args):
        countries = self.dict[self.var_a.get()]
        self.var_b.set(countries[0])

        menu = self.option_menu_b['menu']
        menu.delete(0, 'end')

        for c in countries:
            menu.add_command(label=c, command=lambda x=c: self.var_b.set(x))
开发者ID:dossan,项目名称:tkinter,代码行数:30,代码来源:sync_two_option_menus.py

示例3: GuiGeneratorSelect

class GuiGeneratorSelect(Frame):
    def __init__(self, parent, generators):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack()
        
        self._generators = generators
        self._generatorName = StringVar()
        self._generatorName.set(generators[0].getName())
        self._generatorName.trace("w", self._switchSettings)
        
        self._generatorLbl = Label(self, text="Generator");
        self._generatorLbl.pack(side=LEFT)
        
        param = (self, self._generatorName) + tuple(i.getName() for i in generators)
        self._generatorOpt = OptionMenu(*param)
        self._generatorOpt.pack(side=LEFT)
        
        
        self._switchSettings()
        
    def _switchSettings(self, *args):
       print("DBG: switch generator settings")
       for i in self._generators:
           if i.getName() == self._generatorName.get(): 
               i.pack()
               self._generatorGui = i
               print("pack " + str(i.getName()))
           else:
               i.pack_forget() 
               print("unpack " + str(i.getName()))
    
    def getCurrGeneratorGui(self):
        return self._generatorGui         
开发者ID:awaken1988,项目名称:pyTools,代码行数:34,代码来源:tas_bytegenerator.py

示例4: __init__

 def __init__(self, master, variable, value, *values, **kwargs):
     # TODO copy value instead of whole dict
     kwargsCopy=copy.copy(kwargs)
     if 'highlightthickness' in list(kwargs.keys()):
         del(kwargs['highlightthickness'])
     OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
     self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
     #self.menu=self['menu']
     self.variable=variable
     self.command=kwargs.get('command')
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:10,代码来源:dynOptionMenuWidget.py

示例5: GuiBasicSettings

class GuiBasicSettings(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack()
        
        #Unit
        self.sizeUnits = {"Byte": 1, "KiB":1024, "MiB":1024**2, "GiB":1024**3}
        
        self._initFile()
        self._initSize()

    def _initFile(self):
        self._fileLbl = Label(self, text="File:       ")
        self._fileTxt = Entry(self)
        self._fileTxt.insert(0, "/tmp/out.txt")
        self._fileBtn = Button(self, text="Create", command=self._callbackFun)
        self._fileLbl.grid(row=0, column=0)
        self._fileTxt.grid(row=0, column=1)
        self._fileBtn.grid(row=0, column=2)
    
    def _initSize(self):
        self._sizeLbl = Label(self, text="FileSize:  ")
        self._sizeTxt = Entry(self)
        self._sizeTxt.insert(0, "1024")
        
        self._sizeVar    = StringVar()
        self._sizeVar.set("Byte")       #FIXME: replace "Byte" with variable
        sizeOptParam = (self, self._sizeVar) + tuple(self.sizeUnits.keys()) 
        self._sizeOptMen = OptionMenu(*sizeOptParam)
        
        self._sizeLbl.grid(row=1, column=0)
        self._sizeTxt.grid(row=1, column=1)
        self._sizeOptMen.grid(row=1, column=2)
    
    def _callbackFun(self):
        print("_callbackBtn")
        self.outerCallback()
    
    def enableButton(self, enabled=True):
        if enabled:
            self._fileBtn.config(state="normal")
        else:
            self._fileBtn.config(state="disabled")
    def getFileName(self):
        return self._fileTxt.get()
        
    def getFileSize(self):
        mult = int(self.sizeUnits[self._sizeVar.get()])
        val  = int(self._sizeTxt.get())
        return val * mult   
    
    def setCallback(self, aCallback):
        self.outerCallback = aCallback
开发者ID:awaken1988,项目名称:pyTools,代码行数:54,代码来源:tas_bytegenerator.py

示例6: _init_corpus_select

    def _init_corpus_select(self, parent):
        innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
        self.var = StringVar(innerframe)
        self.var.set(self.model.DEFAULT_CORPUS)
        Label(innerframe, justify=LEFT, text=' Corpus: ', background=self._BACKGROUND_COLOUR, padx = 2, pady = 1, border = 0).pack(side='left')

        other_corpora = list(self.model.CORPORA.keys()).remove(self.model.DEFAULT_CORPUS)
        om = OptionMenu(innerframe, self.var, self.model.DEFAULT_CORPUS, command=self.corpus_selected, *self.model.non_default_corpora())
        om['borderwidth'] = 0
        om['highlightthickness'] = 1
        om.pack(side='left')
        innerframe.pack(side='top', fill='x', anchor='n')
开发者ID:CaptainAL,项目名称:Spyder,代码行数:12,代码来源:collocations_app.py

示例7: AccountDialog

class AccountDialog(gui.tksimpledialog.Dialog):
    def __init__(self, parent, title="", login_name="", password="", path="", dx="dx11"):
        self.login_name = login_name
        self.password = password
        self.path = path
        self.dx = dx
        self.entry_ln = None
        self.variable = None
        self.entry_pw = None
        self.entry_path = None
        self.entry_dx = None
        super().__init__(parent, title)

    def body(self, master):
        Label(master, text="Login Name:").grid(row=0)
        Label(master, text="Password:").grid(row=1)
        Label(master, text="Eve Path:").grid(row=2)
        Label(master, text="DirectX:").grid(row=3)

        self.entry_ln = Entry(master)
        self.entry_pw = Entry(master, show="*")
        self.entry_path = Entry(master)
        self.variable = StringVar(master)
        self.variable.set(self.dx)
        self.entry_dx = OptionMenu(master, self.variable, "dx9", "dx11")

        self.entry_ln.insert(END, self.login_name)
        self.entry_pw.insert(END, self.password)
        self.entry_path.insert(END, self.path)

        # self.entry_path.bind("<FocusIn>", self.select_eve_path)

        self.entry_ln.grid(row=0, column=1)
        self.entry_pw.grid(row=1, column=1)
        self.entry_path.grid(row=2, column=1)
        self.entry_dx.grid(row=3, column=1)
        return self.entry_ln

        # def select_eve_path(self, event):

    # if event.widget == self.entry_path:
    #            self.path
    #            res = os.path.normpath(askdirectory(initialdir=self.path))
    #           self.path = res
    #            self.entry_path.insert(END, res)

    def apply(self):
        login_name = self.entry_ln.get()
        password = self.entry_pw.get()
        path = self.entry_path.get()
        dx = self.variable.get()
        self.result = [login_name, password, path, dx]
开发者ID:SpeedProg,项目名称:PveLauncher,代码行数:52,代码来源:newaccountdialog.py

示例8: makelist

 def makelist(self):
     if havePMW:
         self.list = ComboBox(self.list_frame,
                 selectioncommand = self.onSelChange,
                 scrolledlist_items = self.files,
         )
         self.list.grid(row=0, column=0, padx=0, pady=0, sticky="NEWS")
         self.list.component('entryfield').component('entry').configure(state = 'readonly', relief = 'raised')
         self.picked_name = self.list
     else:
         self.list = OptionMenu(*(self.list_frame, self.picked_name) + tuple(self.files))
         self.list.grid(row=0, column=0, sticky="NEW")
         self.picked_name.trace("w", self.onSelChange)
开发者ID:bbferka,项目名称:pracmln,代码行数:13,代码来源:widgets.py

示例9: __init__

    def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
        PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
        self.info = None
        
        eframe = self.eframe = LabelFrame(self,text="Options") 
        #,fg=textLightColor,bg=baseColor)
        eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 )
        
        label = Label(eframe,text="Pipeline:")#,fg=textLightColor,bg=baseColor)
        label.grid(row=3,column=0,sticky=W,padx=10,pady=5)
        Pipelines=["InitialChIPseqQC", "ChIPseq" ]
        Pipeline = self.Pipeline = StringVar()
        Pipeline.set(Pipelines[0])
        
        om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller)
        om.config()#bg = widgetBgColor,fg=widgetFgColor)
        om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor)
        #om.pack(side=LEFT,padx=20,pady=5)
        om.grid(row=3,column=1,sticky=W,padx=20,pady=5)

        readtypes = ['Single', 'Paired']
        self.readtype = readtype = StringVar()
        readtype.set(readtypes[0])
        readtype_menu = OptionMenu(eframe, readtype, *readtypes)
        readtype_menu.grid(row=3, column=3, sticky=E, pady=5)
        readtype_label = Label(eframe, text="-end   ")
        readtype_label.grid( row=3, column=4, stick=W, pady=5)

        self.add_info(eframe)
        self.option_controller()
        self.peakinfo_fn = 'peakcall.tab'
        self.contrast_fn = 'contrast.tab'
开发者ID:felloumi,项目名称:Pipeliner,代码行数:32,代码来源:epigenomeseq.py

示例10: createWidgets

 def createWidgets(self):
     self.sayHi = tk.Button(self)
     self.sayHi["text"] = "Eds Button"
     self.sayHi["command"] = self.say_Hello
     self.sayHi.pack(side="bottom")
     
     for option in options:
         f = Frame(self)
         f.pack(side="bottom")
         Label(f, text=option).pack(side="left")
         v = StringVar(self)
         o = OptionMenu(f, v, *options.get(option).values())
         o.pack(side="right")
         self.options[option] = v
开发者ID:ekozlowski,项目名称:MinecraftServerGUI,代码行数:14,代码来源:main.py

示例11: __init__

    def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
        PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
        self.pairs = None
        
        eframe = self.eframe = LabelFrame(self,text="Options") 
        #,fg=textLightColor,bg=baseColor)
        eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 )
        
        label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor)
        label.grid(row=3,column=0,sticky=W,padx=10,pady=5)
        PipelineLabels = ["Initial QC", "Germline", 'Somatic Tumor-Normal', 'Somatic Tumor-Only']
        Pipelines=["initialqc", "exomeseq-germline", "exomeseq-somatic", "exomeseq-somatic-tumoronly"]
        self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}

        Pipeline = self.Pipeline = StringVar()
        PipelineLabel = self.PipelineLabel = StringVar()
        self.Pipeline = StringVar()

        PipelineLabel.set(PipelineLabels[0])
        
        om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller)
        #om.config()#bg = widgetBgColor,fg=widgetFgColor)
        #om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor)
        #om.pack(side=LEFT,padx=20,pady=5)
        om.grid(row=3,column=1,sticky=W,padx=10,pady=5)

        targetsL=Label(eframe,
                       text="Target Capture Kit")
                       #,fg=textLightColor,bg=baseColor)
        targetsL.grid(row=5,column=0,sticky=W,padx=10,pady=5)
        targetsE = Entry(eframe,textvariable=self.targetspath, width=50)

        if self.genome=="hg19":
            self.targetspath.set( 
                "/data/CCBR_Pipeliner/db/PipeDB/lib/SS_v5_UTRs_hg19.bed" )
        elif self.genome=="hg38":
            self.targetspath.set( 
                "/data/CCBR_Pipeliner/db/PipeDB/lib/SS_v5_UTRs_hg38.bed" )
        else:
            self.targetspath.set(
                "/data/CCBR_Pipeliner/db/PipeDB/lib/SureSelect_mm10.bed")

        targetsE.grid(row=5,column=1,columnspan=6,sticky=W,padx=10,pady=5)
        self.targetspath.trace('w', lambda a,b,c,x="targetspath":self.makejson(x))
        label = Label (eframe, 
                       text = 
                       "By default, the path to the Agilent V5+UTR targets file is filled in here" ) 
        
        label.grid(row=6, column=0, columnspan=5, sticky=W, padx=10, pady=5)
开发者ID:jlac,项目名称:Pipeliner,代码行数:49,代码来源:exomeseq.py

示例12: createWidgets

	def createWidgets(self):
		self.title = Label(self, text="Image!", font=("Helvetica", 16))
		self.title.grid(row=0, column=1, columnspan=2)

		self.open_file = Button(self)
		self.open_file['text'] = "OPEN"
		self.open_file["command"] = self.openfile
		self.open_file.grid(row=1, column=0)

		self.save_button = Button(self, text='SAVE',
									command=self.save_file)
		self.save_button.grid(row=1, column=1)

		self.canvas = Canvas(self, width=400, height=300)
		self.canvas.grid(row=2, column=0, rowspan=5, columnspan=4)

		self.convert_grayscale_button= Button(self)
		self.convert_grayscale_button['text'] = "Convert to\n grayscale"
		self.convert_grayscale_button["command"] = self.convert_grayscale
		self.convert_grayscale_button.grid(row=7, column=0)

		self.variable = StringVar(self)
		self.variable.set("gray") 
		self.choose_color_menu = OptionMenu(self, self.variable,"gray", "blue", "green", "red")
		self.choose_color_menu['text'] = "Choose Color"
		self.choose_color_menu.grid(row=7, column=1)
					
		self.color_button = Button(self, text="COLOR", command=self.color_image)
		self.color_button.grid(row=7, column=2)

		self.quit_button = Button(self, text="QUIT", command=self.quit)
		self.quit_button.grid(row=7, column=3)
开发者ID:alexacristina,项目名称:ms_assignments,代码行数:32,代码来源:image_manipulation.py

示例13: create_monitor

 def create_monitor(self):
     self.monitor_frame = LabelFrame(self, text="Monitor and Transport")
     this_cycle = Scale(self.monitor_frame, label='cycle_pos', orient=HORIZONTAL,
                        from_=1, to=16, resolution=1)
     this_cycle.disable, this_cycle.enable = (None, None)
     this_cycle.ref = 'cycle_pos'
     this_cycle.grid(column=0, row=0, sticky=E + W)
     self.updateButton = Button(self.monitor_frame,
                                text='Reload all Settings',
                                command=self.request_update)
     self.updateButton.grid(row=1, sticky=E + W)
     self.ForceCaesuraButton = Button(self.monitor_frame,
                                      text='Force Caesura',
                                      command=self.force_caesura)
     self.ForceCaesuraButton.grid(row=2, sticky=E + W)
     self.saveBehaviourButton = Button(self.monitor_frame,
                                       text='Save current behaviour',
                                       command=self.request_saving_behaviour)
     self.saveBehaviourButton.grid(row=3, sticky=E + W)
     self.saveBehaviourNameEntry = Entry(self.monitor_frame)
     self.saveBehaviourNameEntry.grid(row=4, sticky=E + W)
     self.saveBehaviourNameEntry.bind('<KeyRelease>', self.request_saving_behaviour)
     self.selected_behaviour = StringVar()
     self.selected_behaviour.trace('w', self.new_behaviour_chosen)
     self.savedBehavioursMenu = OptionMenu(self.monitor_frame,
                                           self.selected_behaviour, None,)
     self.savedBehavioursMenu.grid(row=5, sticky=E + W)
     self.monitor_frame.grid(column=0, row=10, sticky=E + W)
开发者ID:kr1,项目名称:roqba,代码行数:28,代码来源:main.py

示例14: createInterface

    def createInterface(self):
        """
        Tworzenie interfejsu - nieistotne dla idei zadania
        """
        self.frame_choice = StringVar(self.parent)
        self.frame_choice.set(tuple(self.frames.keys())[0])
        self.frame_choice.trace("w", self.createBike)
        self.frame_options = OptionMenu(self.parent,self.frame_choice,
                                        *self.frames.keys())
        Label(self.parent,text="Rama:").pack()
        self.frame_options.pack(fill=BOTH, expand=1)

        self.fork_choice = StringVar(self.parent)
        self.fork_choice.set(tuple(self.forks.keys())[0])
        self.fork_choice.trace("w", self.createBike)
        self.fork_options = OptionMenu(self.parent,self.fork_choice,
                                        *self.forks.keys())
        Label(self.parent,text="Widelec:").pack()
        self.fork_options.pack(fill=BOTH, expand=1)

        self.wheelset_choice = StringVar(self.parent)
        self.wheelset_choice.set(tuple(self.wheelsets.keys())[0])
        self.wheelset_choice.trace("w", self.createBike)
        self.wheelset_options = OptionMenu(self.parent,self.wheelset_choice,
                                        *self.wheelsets.keys())
        Label(self.parent,text="Koła:").pack()
        self.wheelset_options.pack(fill=BOTH, expand=1)

        self.group_choice = StringVar(self.parent)
        self.group_choice.set(tuple(self.groups.keys())[0])
        self.group_choice.trace("w", self.createBike)
        self.group_options = OptionMenu(self.parent,self.group_choice,
                                        *self.groups.keys())
        Label(self.parent,text="Grupa osprzętu:").pack()
        self.group_options.pack(fill=BOTH, expand=1)

        self.components_choice = StringVar(self.parent)
        self.components_choice.set(tuple(self.components.keys())[0])
        self.components_choice.trace("w", self.createBike)
        self.components_options = OptionMenu(self.parent,self.components_choice,
                                        *self.components.keys())
        Label(self.parent,text="Komponenty:").pack()
        self.components_options.pack(fill=BOTH, expand=1)
开发者ID:kpiszczek,项目名称:wzorceuj,代码行数:43,代码来源:cw5b.py

示例15: __init__

    def __init__(self, master):
        Frame.__init__(self, master)

        self.dict = {'Asia': ['Japan', 'China', 'India'],
                     'Europe': ['Portugal', 'Switzerland', 'Ukraine']}

        self.var_a = StringVar(self)
        self.var_b = StringVar(self)

        self.var_a.trace('w', self.update_options)

        self.option_menu_a = OptionMenu(self, self.var_a, *self.dict.keys())
        self.option_menu_a.pack(side="top")
        self.option_menu_a["width"] = 10
        self.option_menu_b = OptionMenu(self, self.var_b, '')
        self.option_menu_b["width"] = 10
        self.option_menu_b.pack(side="top")

        self.var_a.set('Asia')
开发者ID:dossan,项目名称:tkinter,代码行数:19,代码来源:sync_two_option_menus.py


注:本文中的tkinter.OptionMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。