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


Python Tkinter.OptionMenu类代码示例

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


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

示例1: initUI

    def initUI(self):
        self.parent.title("Buttons")
        self.style = Style()
        self.style.theme_use("default")

        frame = Frame(self, relief=GROOVE, borderwidth=5)
        frame.pack(fill=BOTH, expand=1)
        self.pack(fill = BOTH, expand = 1)

        self.imageLabel = Label(frame, image = "")
        self.imageLabel.pack(fill=BOTH, expand=1)

        closeButton = Button(self, text="Close")
        closeButton.pack(side=RIGHT)
        okButton = Button(self, text="OK")
        okButton.pack(side=RIGHT)

        options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")]
        option = OptionMenu(self, self.key, *options)
        self.key.set(options[0])
        option.pack(side="left")

        spin = Spinbox(self, from_=0, to=1, increment=0.05)
        self.val = spin.get()
        spin.pack(side="left")
开发者ID:fredericgo,项目名称:PyCV-Processing,代码行数:25,代码来源:frame.py

示例2: __init__

 def __init__(self, parent, variable=None, values=None, **kwargs):
     if values is None:
         values = []
     self._var = variable or StringVar()
     OptionMenu.__init__(self, parent, self._var, *values, **kwargs)
     if values:
         self._var.set(values[0])
开发者ID:hobbitzero,项目名称:calculations,代码行数:7,代码来源:gui_elements.py

示例3: build_word

    def build_word(self):

        row = Frame(self.exportWord, width=30)
        row.pack(side=RIGHT)

        row_font = Frame(row, width=30)
        row_font.pack()

        lst1 = OPTIONS
        self.var1 = StringVar()
        self.var1.set(OPTIONS[1])
        self.font_name_box = OptionMenu(row_font, self.var1, *lst1)
        self.font_name_box.config(width=28)
        self.font_name_box.pack()


        row_size = Frame(row, width=30)
        row_size.pack()

        lst2 = OPTIONS_SIZE
        self.var2 = StringVar()
        self.var2.set(OPTIONS_SIZE[-1])
        self.font_size_box = OptionMenu(row_font, self.var2, *lst2)
        self.font_size_box.config(width=28)
        self.font_size_box.pack()

        row_button = Frame(row, width=30)
        row_button.pack()
        button_export = Button(row_button, width=30, height=2, text="EXPORT", command=self.choose_file_name)
        button_export.pack()
开发者ID:viktorijat,项目名称:etw,代码行数:30,代码来源:interface.py

示例4: WheelEntry

class WheelEntry(LabelFrame):
    DIA_UNITS = [dist.mm, dist.cm, dist.inch]

    def __init__(self, **kwargs):
        master = None if 'master' not in kwargs else kwargs['master']
        LabelFrame.__init__(self, master, text='Wheel')
        self.unitopts = ['%s (%s)' % (x.name, x.symbol)
                         for x in WheelEntry.DIA_UNITS]
        self.__val = WheelEntry.DIA_UNITS[0]
        self.createSpin()
        self.create_unit_opts()

    def create_unit_opts(self):
        self.unitoptselected = StringVar()
        self.unitoptselected.set(self.unitopts[2])
        self.unitopt = OptionMenu(self, self.unitoptselected, *self.unitopts)
        self.unitopt.grid(row=1, column=1, in_=self)
        self.val()

    def val(self, val=None):
        if val is not None:
            self.__val.value = val
        else:
            sel = self.unitoptselected.get().split()[0]
            for u in WheelEntry.DIA_UNITS:
                if sel in u.name:
                    self.__val = u
                    self.__val.value = int(self.Spin.val.get())
        return self.__val

    def createSpin(self):
        self.Spin = LabeledSpin(title='Dia')
        self.Spin.val.set(27)
        self.Spin.Spin.config(from_=10, to=1000, width=4)
        self.Spin.grid(row=1, column=0, in_=self)
开发者ID:WillBickerstaff,项目名称:pycycle,代码行数:35,代码来源:wheel.py

示例5: convertChoice

	def convertChoice(self):

		#Las partes que integran el primer submenu llamado "DE", labelFrame,menu, entrada.
		self.labelFrameFrom=LabelFrame(self.master,text="De",background=R.Bgcolor)
		self.labelFrameFrom.grid(row=1,column=0,padx=5,pady=3)

		self.menuFrom=OptionMenu(self.labelFrameFrom,self.fromLabel,"",)
		self.menuFrom.configure(bg=R.White,fg=R.Black,activebackground=R.hoverBtnColor,highlightbackground=R.Bgcolor,
								indicatoron=0,image=self.btnFlechaimg, compound='right')
		self.menuFrom.grid(row=0,column=0,padx=3,pady=2,sticky=E)

		self.entryFrom=Entry(self.labelFrameFrom,justify='center',textvariable=self.fromNumber)
		self.entryFrom.grid(row=2,column=0,padx=5,pady=5)

		#Las partes que integran el segundo submenu llamado "Hasta", labelFrame, menu, entrada.

		self.labelFrameTo=LabelFrame(self.master,text="Hacia",background=R.Bgcolor)
		self.labelFrameTo.grid(row=1,column=1,padx=5,pady=3)

		self.menuTo=OptionMenu(self.labelFrameTo,self.toLabel,"",)
		self.menuTo.configure(bg=R.White,fg=R.Black, activebackground=R.hoverBtnColor,highlightbackground=R.Bgcolor,
					indicatoron=0,image=self.btnFlechaimg, compound='right')
		self.menuTo.grid(row=0,column=0, padx=3, pady=2, sticky=E)

		self.entryTo=Entry(self.labelFrameTo,justify='center',textvariable=self.toNumber,state="readonly")
		self.entryTo.configure(bg="red", readonlybackground=R.Bgcolor)
		self.entryTo.grid(row=2,column=0,padx=3,pady=5)
开发者ID:riojano0,项目名称:Python_Scripts,代码行数:27,代码来源:main.py

示例6: VelocitySelect

class VelocitySelect(Frame):
    VELOCITIES = [speeds.kmh, speeds.mih, speeds.ms]

    def __init__(self, **kwargs):
        master = None if 'master' not in kwargs else kwargs['master']
        Frame.__init__(self, master)
        Label(text='Output Velocity').grid(row=0, column=0, sticky=W,
                                           in_=self)
        self.vel = VelocitySelect.VELOCITIES[0]
        self.vel_selected = StringVar()
        vel_opts = ['%s (%s)' % (sp.name, sp.symbol)
                    for sp in VelocitySelect.VELOCITIES]
        self.velopt = OptionMenu(self, self.vel_selected, *vel_opts)
        self.vel_selected.set('%s (%s)' % (self.vel.name, self.vel.symbol))
        self.velopt.grid(row=0, column=1, sticky=W)

    def val(self, val=None):
        if val is not None:
            self.vel.value = val
        else:
            sel = self.vel_selected.get().split()[0]
            for v in VelocitySelect.VELOCITIES:
                if sel in v.name:
                    self.vel = v
        return self.vel
开发者ID:WillBickerstaff,项目名称:pycycle,代码行数:25,代码来源:outputopts.py

示例7: __init__

 def __init__(self, master, variable, value, *values, **kwargs):
     kwargsCopy = copy.copy(kwargs)
     if 'highlightthickness' in kwargs.keys():
         del kwargs['highlightthickness']
     OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
     self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
     self.variable = variable
     self.command = kwargs.get('command')
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:8,代码来源:dynoptionmenuwidget.py

示例8: __draw_new_draft_window

    def __draw_new_draft_window(self, parent):

        self.parent.title("New Draft")

        style = StringVar()
        style.set("Snake")

        opponent_label = Label(parent, text="Opponents")
        opponent_entry = Entry(parent, width=5)
        
        position_label = Label(parent, text="Draft Position")
        position_entry = Entry(parent, width=5)
        
        rounds_label = Label(parent, text="Number of Rounds")
        rounds_entry = Entry(parent, width=5)
        
        style_label = Label(parent, text="Draft Style")
        style_menu = OptionMenu(parent, style, "Snake", "Linear")
        
        def begin_draft():
            """
            initializes variables to control the flow of the draft
            calls the first window of the draft.
            """
            self.game.number_of_opponents = int(opponent_entry.get())
            self.game.draft_position = int(position_entry.get())
            self.game.number_of_rounds = int(rounds_entry.get())
            self.game.draft_style = style.get()
            
            self.game.opponents = []
            self.game.current_position = 1
            self.game.current_round = 1
            
            for x in xrange(self.game.number_of_opponents):
                self.game.opponents.append(Opponent.Opponent(x))

            if self.game.draft_position <= self.game.number_of_opponents + 1:
                MainUI(self.parent, self.game)
            else:
                tkMessageBox.showinfo("Error",
                                      "Draft position too high!\nYou would never get to pick a player"
                                      )

        def begin_button(event):
            begin_draft()

        ok_button = Button(parent, text="OK", command=begin_draft)
        self.parent.bind("<Return>", begin_button)
        
        opponent_label.grid(row=0, pady=5)
        opponent_entry.grid(row=0, column=1, pady=5)
        position_label.grid(row=1)
        position_entry.grid(row=1, column=1)
        rounds_label.grid(row=2, pady=5)
        rounds_entry.grid(row=2, column=1, pady=5, padx=5)
        style_label.grid(row=3)
        style_menu.grid(row=3, column=1)
        ok_button.grid(row=4, column=1, sticky="se", pady=5, padx=5)
开发者ID:BarnettMichael,项目名称:FantasyFootballHelper,代码行数:58,代码来源:FFHGui.py

示例9: body

 def body(self, master):
     Label(master, text='Current Type: ').grid(row=0,column=0)
     Label(master, text=self.current_type).grid(row=0,column=1)
     Label(master, text='Change: ').grid(row=1,column=0)
     self.option_val = StringVar(master)    
     self.option_val.set(self.current_type)
     om = OptionMenu (master, self.option_val, 'master','slave','master+slave')
     om.grid(row=1,column=1,sticky=W)
     return om # initial focus on menu
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: __init__

 def __init__(self, master, variable, value, *values, **kwargs):
     #get a copy of kwargs before OptionMenu.__init__ munges them
     kwargsCopy=copy.copy(kwargs)
     if 'highlightthickness' in kwargs.keys():
         del(kwargs['highlightthickness'])
     OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
     self.config(highlightthickness = kwargsCopy.get('highlightthickness'))
     self.variable = variable
     self.command = kwargs.get('command')
开发者ID:Zinebl,项目名称:Pyro-Robotics-OSX,代码行数:9,代码来源:Picklist.py

示例11: initUIElements

 def initUIElements(self):
     filePaths = self.fileGroup.getResourcePaths()
     self.var = StringVar(self)
     if filePaths:
         self.var.set(filePaths[0])
         self.fileMenu = OptionMenu(self,self.var,*filePaths)
     else:
         self.fileMenu = OptionMenu(self,self.var,())
     if self.active:
         self.select = Button(self,text="Browse",command=self.onSelect)
开发者ID:crosslinks,项目名称:XlinkAnalyzer,代码行数:10,代码来源:item.py

示例12: __init__

 def __init__(self, master, variable, value, *values, **kwargs):
     # TODO copy value instead of whole dict
     kwargsCopy=copy.copy(kwargs)
     if 'highlightthickness' in 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:AtomicConductor,项目名称:conductor_client,代码行数:10,代码来源:dynOptionMenuWidget.py

示例13: init3Voices

    def init3Voices(self):
        # [(47, 67), (52, 76), (60, 81)])
        # (B,2) - 20
        # (E,3) - 24
        # (C,4) - 25
        self.note_name = ['C','Cs','D','Ds','E','F','Fs','G','Gs','A','As','B']
        self.pitchC1 = StringVar()
        self.pitchC2 = StringVar()
        self.pitchC3 = StringVar()
        self.octave1 = IntVar()
        self.octave2 = IntVar()
        self.octave3 = IntVar()
        self.range1 = IntVar()
        self.range2 = IntVar()
        self.range3 = IntVar()


        v1Label =Label(self, text="Voice 1 start:")
        v1Label.place(x = 30, y = 25)
        self.w1 = OptionMenu(self, self.pitchC1, *self.note_name)
        self.w1.place(x = 135, y = 25)
        self.pitchC1.set(self.note_name[11])
        self.oc1 = OptionMenu(self, self.octave1, *range(1, 9))
        self.oc1.place(x=200, y=25)
        self.octave1.set(2)
        v1_rangeLabel = Label(self, text="Range:")
        v1_rangeLabel.place(x=300, y=25)
        self.rangeoption1 = OptionMenu(self, self.range1, *range(18, 26))
        self.rangeoption1.place(x=360, y=25)
        self.range1.set(20)


        v2Label = Label(self, text="Voice 2 start:")
        v2Label.place(x=30, y=50)
        self.w2 = OptionMenu(self, self.pitchC2, *self.note_name)
        self.w2.place(x=135, y=50)
        self.pitchC2.set(self.note_name[4])
        self.oc2 = OptionMenu(self, self.octave2, *range(1, 9))
        self.oc2.place(x=200, y=25 * 2)
        self.octave2.set(3)
        v2_rangeLabel = Label(self, text="Range:")
        v2_rangeLabel.place(x=300, y=25 * 2)
        self.rangeoption2 = OptionMenu(self, self.range2, *range(18, 26))
        self.rangeoption2.place(x=360, y=25 * 2)
        self.range2.set(24)


        v3Label = Label(self, text="Voice 3 start:")
        v3Label.place(x=30, y=75)
        self.w3 = OptionMenu(self, self.pitchC3, *self.note_name)
        self.w3.place(x=135, y=75)
        self.pitchC3.set(self.note_name[0])
        self.oc3 = OptionMenu(self, self.octave3, *range(1, 9))
        self.oc3.place(x=200, y=25 * 3)
        self.octave3.set(4)
        v3_rangeLabel = Label(self, text="Range:")
        v3_rangeLabel.place(x=300, y=25 * 3)
        self.rangeoption3 = OptionMenu(self, self.range3, *range(18, 26))
        self.rangeoption3.place(x=360, y=25 * 3)
        self.range3.set(25)
开发者ID:donya,项目名称:PythonKulitta,代码行数:60,代码来源:ExampleGUI.py

示例14: __init__

 def __init__(self, parent):
     Frame.__init__(self, parent)
     self.parent = parent
     
     training_error_laber = Label(self, text = 'Training Error: ')
     training_error_laber.pack(side = 'left')
     
     error_options = [round(0.1 + i*0.1, 2) for i in range(25)]
     self.selected_error = DoubleVar(self, value = DEFAULT_TRAINING_ERROR)
     option_menu = OptionMenu(self, self.selected_error, *error_options, 
                              command = self._on_error_selection)
     option_menu.pack(side = 'right')
开发者ID:fmihaich,项目名称:annic,代码行数:12,代码来源:training_settings.py

示例15: _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 = 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:gijs,项目名称:nltk,代码行数:12,代码来源:collocations_app.py


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