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


Python ttk.Combobox方法代码示例

本文整理汇总了Python中tkinter.ttk.Combobox方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Combobox方法的具体用法?Python ttk.Combobox怎么用?Python ttk.Combobox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.ttk的用法示例。


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

示例1: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, root, resource_dir):
        ttk.Frame.__init__(self, root)
        
        self.master_selector = None
        self.resource_dir = resource_dir
        self.items = os.listdir(os.path.join(self.resource_dir, "master"))
        
        self.cur_lang = tkinter.StringVar()
        self.select_lang_label = ttk.Label(root, text=u"select language:")
        self.langs = ttk.Combobox(root, textvariable=self.cur_lang)
        
        self.langs["values"] = self.items

        self.langs.current(0)
        for i, item in enumerate(self.items):
            if item == "fr":
                self.langs.current(i)
        
        self.langs.bind("<<ComboboxSelected>>", self.select_lang) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:21,代码来源:components.py

示例2: create_toolbar

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def create_toolbar(self):
        self.toolbar = ttk.Frame(self.master)
        newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
                image=self.images[NEW], command=self.board.new_game)
        TkUtil.Tooltip.Tooltip(newButton, text="New Game")
        zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
        self.zoomSpinbox = Spinbox(self.toolbar,
                textvariable=self.zoom, from_=Board.MIN_ZOOM,
                to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
                justify=tk.RIGHT, validate="all")
        self.zoomSpinbox.config(validatecommand=(
                self.zoomSpinbox.register(self.validate_int), "%P"))
        TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
        self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
                textvariable=self.shapeName, state="readonly",
                values=sorted(Shapes.ShapeForName.keys()))
        TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
        TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
                zoomLabel, self.zoomSpinbox, self.shapeCombobox))
        self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:22,代码来源:Main.py

示例3: inplace_combobox

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def inplace_combobox(self, col, item, values, readonly=True):
        self.clear_inplace_widgets()
        self._inplace_item = item
        state = 'readonly' if readonly else 'normal'
        self._inplace_var = tk.StringVar()
        svar = self._inplace_var
        svar.set(self.__get_value(col, item))
        self._inplace_widget = ttk.Combobox(self, textvariable=svar, state=state)
        self._inplace_widget.configure(values=values)
        cb = self._inplace_widget
        # cb.bind('<Return>', lambda e: self.__update_value(col, item))
        # cb.bind('<Unmap>', lambda e: self.__update_value(col, item))
        # cb.bind('<FocusOut>', lambda e: self.__update_value(col, item))
        cb.bind("<<ComboboxSelected>>", lambda e: self.__update_value(col, item), "+")

        self.__updateWnds(col, item, cb) 
开发者ID:ubuntunux,项目名称:PyEngine3D,代码行数:18,代码来源:EditableTreeview.py

示例4: create_widgets

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def create_widgets(self, names):
        ''' Creates appropriate widgets.

            Args:
                names (list of str): list of available sheet names.
        '''
        sheet_name_lbl = Label(self,
                               text='Choose sheet name where data is stored:')
        sheet_name_lbl.grid(sticky=N+W, padx=5, pady=5)
        sheet_names_box = Combobox(self, state="readonly", width=20,
                                   textvariable=self.sheet_name_str,
                                   values=names)
        sheet_names_box.current(0)
        sheet_names_box.grid(row=1, column=0, columnspan=2,
                             sticky=N+W, padx=5, pady=5)
        ok_btn = Button(self, text='OK', command=self.ok)
        ok_btn.grid(row=2, column=0, sticky=N+E, padx=5, pady=5)
        ok_btn.bind('<Return>', self.ok)
        ok_btn.focus()
        cancel_btn = Button(self, text='Cancel', command=self.cancel)
        cancel_btn.grid(row=2, column=1, sticky=N+E, padx=5, pady=5)
        cancel_btn.bind('<Return>', self.cancel) 
开发者ID:araith,项目名称:pyDEA,代码行数:24,代码来源:load_xls_gui.py

示例5: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, frame):
        self.frame = frame
        # Create a combobbox to select the logging level
        values = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
        self.level = tk.StringVar()
        ttk.Label(self.frame, text='Level:').grid(column=0, row=0, sticky=W)
        self.combobox = ttk.Combobox(
            self.frame,
            textvariable=self.level,
            width=25,
            state='readonly',
            values=values
        )
        self.combobox.current(0)
        self.combobox.grid(column=1, row=0, sticky=(W, E))
        # Create a text field to enter a message
        self.message = tk.StringVar()
        ttk.Label(self.frame, text='Message:').grid(column=0, row=1, sticky=W)
        ttk.Entry(self.frame, textvariable=self.message, width=25).grid(column=1, row=1, sticky=(W, E))
        # Add a button to log the message
        self.button = ttk.Button(self.frame, text='Submit', command=self.submit_message)
        self.button.grid(column=1, row=2, sticky=W) 
开发者ID:beenje,项目名称:tkinter-logging-text-widget,代码行数:24,代码来源:main.py

示例6: get_control

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def get_control(self):
        """ Set the correct control type based on the datatype or for this option """
        if self.choices and self.is_radio:
            control = "radio"
        elif self.choices and self.is_multi_option:
            control = "multi"
        elif self.choices and self.choices == "colorchooser":
            control = "colorchooser"
        elif self.choices:
            control = ttk.Combobox
        elif self.dtype == bool:
            control = ttk.Checkbutton
        elif self.dtype in (int, float):
            control = "scale"
        else:
            control = ttk.Entry
        logger.debug("Setting control '%s' to %s", self.title, control)
        return control 
开发者ID:deepfakes,项目名称:faceswap,代码行数:20,代码来源:control_helper.py

示例7: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, parent, component_name, list_combobox_data, tooltip_key):
        ttk.Frame.__init__(self, parent)
        self.columnconfigure(0, weight=1)

        logging.debug("\t\tBuilding \"%s\"" % component_name)
        label = widgets.TooltipLabel(self, tooltip_key, text=component_name)
        label.grid(row=0, column=0, sticky="w", padx=(5, 0))

        self.listComboboxData = list_combobox_data
        self.is_active = BooleanVar()
        self.option   = None

        self.button   = ttk.Checkbutton(self, onvalue=1, offvalue=0, variable=self.is_active)
        self.combo    = ttk.Combobox(self, state="disabled", values=self.listComboboxData, style='D.TCombobox')
        self.combo.bind("<<ComboboxSelected>>", self.option_selected)

        self.button.configure(command=partial(self._cb_value_changed, self.is_active, [self.combo]))
        self.button.grid(row=0, column=1, sticky="e")
        self.combo.grid(row=1, column=0, sticky="ew", padx=(20,0))
    #end init 
开发者ID:shitwolfymakes,项目名称:Endless-Sky-Mission-Builder,代码行数:22,代码来源:ComboComponentFrame.py

示例8: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, master, options, callback, **kwargs):
        self.callback = callback
        super().__init__(master, **kwargs)

        self.option_list = ttk.Combobox(self, values=options, state="readonly", width=25)
        self.option_list.current(0)
        self.option_list.pack()

        buttons = ttk.Frame(self)
        ok = ttk.Button(buttons, text="OK", command=self._cleanup)
        ok.pack(side=LEFT, fill="x")
        cxl = ttk.Button(buttons, text="Cancel", command=self._cancelled)
        cxl.pack(fill="x")
        buttons.pack()

        # these commands make the parent window inactive
        self.transient(master)
        self.grab_set()
        master.wait_window(self)
    #end init 
开发者ID:shitwolfymakes,项目名称:Endless-Sky-Mission-Builder,代码行数:22,代码来源:TypeSelectorWindow.py

示例9: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, parent):
        ttk.Frame.__init__(self, parent)
        logging.debug("\tInitializing OptionPane...")
        self.mfi = config.mission_file_items
        self.option_frame = self

        title = ttk.Label(self.option_frame, text="Mission File Items")
        title.pack()

        item_names = self.mfi.get_names()
        self.combo_box = ttk.Combobox(self.option_frame, state="readonly", values=item_names)
        self.combo_box.bind("<<ComboboxSelected>>", self.item_selected)
        self.combo_box.pack()
        if config.debugging:
            self.combo_box.current(0)

        self.add_buttons()
    #end init 
开发者ID:shitwolfymakes,项目名称:Endless-Sky-Mission-Builder,代码行数:20,代码来源:OptionPane.py

示例10: create_widgets

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def create_widgets(self):
        self.currencyFromCombobox = ttk.Combobox(self,
                textvariable=self.currencyFrom)
        self.currencyToCombobox = ttk.Combobox(self,
                textvariable=self.currencyTo)
        self.amountSpinbox = Spinbox(self, textvariable=self.amount,
                from_=1.0, to=10e6, validate="all", format="%0.2f",
                width=8)
        self.amountSpinbox.config(validatecommand=(
                self.amountSpinbox.register(self.validate), "%P"))
        self.resultLabel = ttk.Label(self) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:13,代码来源:Main.py

示例11: create_widgets

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def create_widgets(self):
        self.sourceLabel = ttk.Label(self, text="Source Folder:",
                underline=-1 if TkUtil.mac() else 1)
        self.sourceEntry = ttk.Entry(self, width=30,
                textvariable=self.sourceText)
        self.sourceButton = TkUtil.Button(self, text="Source...",
                underline=0, command=lambda *args:
                    self.choose_folder(SOURCE))
        self.helpButton = TkUtil.Button(self, text="Help", underline=0,
                command=self.help)
        self.targetLabel = ttk.Label(self, text="Target Folder:",
                underline=-1 if TkUtil.mac() else 1)
        self.targetEntry = ttk.Entry(self, width=30,
                textvariable=self.targetText)
        self.targetButton = TkUtil.Button(self, text="Target...",
                underline=0, command=lambda *args:
                    self.choose_folder(TARGET))
        self.aboutButton = TkUtil.Button(self, text="About", underline=1,
                command=self.about)
        self.statusLabel = ttk.Label(self, textvariable=self.statusText)
        self.scaleButton = TkUtil.Button(self, text="Scale",
                underline=1, command=self.scale_or_cancel,
                default=tk.ACTIVE, state=tk.DISABLED)
        self.quitButton = TkUtil.Button(self, text="Quit", underline=0,
                command=self.close)
        self.dimensionLabel = ttk.Label(self, text="Max. Dimension:",
                underline=-1 if TkUtil.mac() else 6)
        self.dimensionCombobox = ttk.Combobox(self,
                textvariable=self.dimensionText, state="readonly",
                values=("50", "100", "150", "200", "250", "300", "350",
                        "400", "450", "500"))
        TkUtil.set_combobox_item(self.dimensionCombobox, "400") 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:34,代码来源:Main.py

示例12: create_widgets

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def create_widgets(self):
        self.wordWrapLabel = ttk.Label(self, text="Wrap:")
        self.wordWrapCombobox = ttk.Combobox(self, state="readonly",
                values=["None", "Character", "Word"],
                textvariable=self.__wordWrap, width=10)
        self.blockCursorCheckbutton = ttk.Checkbutton(self,
                text="Block Cursor", variable=self.__blockCursor)
        self.lineSpacingLabel = ttk.Label(self, text="Line Spacing:")
        self.lineSpacingSpinbox = tk.Spinbox(self, from_=0, to=32,
                width=3, validate="all", justify=tk.RIGHT,
                textvariable=self.__lineSpacing)
        self.lineSpacingSpinbox.config(validatecommand=(
                self.lineSpacingSpinbox.register(self.__validate_int),
                    "lineSpacingSpinbox", "%P")) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:16,代码来源:Display.py

示例13: add_combobox

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def add_combobox(self, **kwargs):
    """
    To add a combobox. Will automatically add an attribute.
    Args:
    - entries: a list that contains every selectable option.
    - variable: the name of the variable, that will become an attribute.
    - default_index: to define which default entry to show on the combobox.
    - var
    """
    widgets_dict = kwargs.pop("widgets_dict", None)
    frame = kwargs.pop("frame", None)
    entries = kwargs.pop("entries", None)
    name = kwargs.pop("name", "combobox")
    variable_name = kwargs.pop("variable", name + "_var")
    default_index = kwargs.pop("default", 0)

    var = tk.StringVar()
    var.set(entries[default_index])

    setattr(self, variable_name, var)

    combo_box = ttk.Combobox(frame,
                             textvariable=var,
                             values=entries,
                             state='readonly')

    widgets_dict[name] = combo_box 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:29,代码来源:frame_objects.py

示例14: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def __init__(self, parent, msg, title, options, default, text_variable):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.protocol("WM_DELETE_WINDOW", self.cancel_function)
        self.parent.bind('<Return>', self.ok_function)
        self.parent.title(title)
        self.input_text = text_variable
        self.input_text.set(default)
        if Settings.PopupLocation:
            self.parent.geometry("+{}+{}".format(
                Settings.PopupLocation.x,
                Settings.PopupLocation.y))
        self.msg = tk.Message(self.parent, text=msg)
        self.msg.grid(row=0, sticky="NSEW", padx=10, pady=10)
        self.input_list = ttk.Combobox(
            self.parent,
            textvariable=self.input_text,
            state="readonly",
            values=options)
        #self.input_list.activate(options.index(default))
        self.input_list.grid(row=1, sticky="EW", padx=10)
        self.button_frame = tk.Frame(self.parent)
        self.button_frame.grid(row=2, sticky="E")
        self.cancel = tk.Button(
            self.button_frame,
            text="Cancel",
            command=self.cancel_function,
            width=10)
        self.cancel.grid(row=0, column=0, padx=10, pady=10)
        self.ok_button = tk.Button(
            self.button_frame,
            text="Ok",
            command=self.ok_function,
            width=10)
        self.ok_button.grid(row=0, column=1, padx=10, pady=10)
        self.input_list.focus_set() 
开发者ID:glitchassassin,项目名称:lackey,代码行数:38,代码来源:SikuliGui.py

示例15: defaultFileEntries

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Combobox [as 别名]
def defaultFileEntries(self): 
        self.fileEntry.delete(0, tk.END)
        self.fileEntry.insert(0, 'Z:\\')        # bogus path
        self.fileEntry.config(state='readonly')         

        self.netwEntry.delete(0, tk.END)
        self.netwEntry.insert(0, 'Z:\\Backup')  # bogus path                      
    
    # Combobox callback 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:11,代码来源:GUI.py


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