Python tkinter.ttk 模块,Combobox() 实例源码

我们从Python开源项目中,提取了以下39个代码示例,用于说明如何使用tkinter.ttk.Combobox()

项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, combobox_position="top", *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self._combobox_position = combobox_position

        self._page_list = []
        self._label_list = []

        self._variable = tk.StringVar()

        self._combobox = ttk.Combobox(self, state="readonly", textvariable=self._variable)
        self._combobox.pack(side=combobox_position, fill="x")
        self._combobox.bind("<<ComboboxSelected>>", self._change_page, "+")

        self.frame = ttk.Frame(self)
        self.frame.pack(fill="both", expand=True)
项目:Colony    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, option, **kwargs):
        ttk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent
        self.option = option

        # TODO: Add more options.

        ttk.Checkbutton(self, text="Debugging Mode", variable=self.option.variable_debug).grid(row=0, column=0, sticky="we")
        ttk.Checkbutton(self, text="Scrollbars", variable=self.option.variable_scrollbars).grid(row=1, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid", variable=self.option.variable_grid).grid(row=2, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid Highlight", variable=self.option.variable_grid_highlight).grid(row=3, column=0, sticky="we")

        frame_colour = ttk.Frame(self)
        ttk.Label(frame_colour, text="Highlight Colour").grid(row=0, column=0)
        ttk.Combobox(frame_colour, textvariable=self.option.variable_highlight_colour, values=["white", "red", "blue", "yellow", "green", "purple", "orange", "pink"], state="readonly", width=7).grid(row=0, column=1)
        frame_colour.grid(row=4, column=0, sticky="we")

        ttk.Checkbutton(self, text="Extra Speed Arrows", variable=self.option.variable_extra_speed_arrows).grid(row=5, column=0, sticky="we")
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def add_combobox(self, key, choices, text, *, case_sensitive=True):
        """Add a ``ttk.Combobox`` that sets an option to a string.

        The combobox will contain each string in *choices*.

        A `validator callback <Validating>`_ that ensures the value is
        in *choices* is also added. If *case_sensitive* is False,
        :meth:`str.casefold` is used when comparing the strings.
        """
        def validator(value):
            if case_sensitive:
                ok = (value in choices)
            else:
                ok = (value.casefold() in map(str.casefold, choices))
            if not ok:
                raise InvalidValue("%r is not a valid %r value"
                                   % (value, key))

        self.connect(key, validator)

        frame = self.add_frame(key)
        ttk.Label(frame, text=text).pack(side='left')
        ttk.Combobox(frame, values=choices,
                     textvariable=self.get_var(key)).pack(side='right')
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
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
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Combobox(self.root, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Combobox(self.root, **kwargs)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def setUp(self):
        support.root_deiconify()
        self.combo = ttk.Combobox()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_values(self):
        def check_get_current(getval, currval):
            self.assertEqual(self.combo.get(), getval)
            self.assertEqual(self.combo.current(), currval)

        check_get_current('', -1)

        self.combo['values'] = ['a', 1, 'c']

        self.combo.set('c')
        check_get_current('c', 2)

        self.combo.current(0)
        check_get_current('a', 0)

        self.combo.set('d')
        check_get_current('d', -1)

        # testing values with empty string
        self.combo.set('')
        self.combo['values'] = (1, 2, '', 3)
        check_get_current('', 2)

        # testing values with empty string set through configure
        self.combo.configure(values=[1, '', 2])
        self.assertEqual(self.combo['values'], ('1', '', '2'))

        # out of range
        self.assertRaises(tkinter.TclError, self.combo.current,
            len(self.combo['values']))
        # it expects an integer (or something that can be converted to int)
        self.assertRaises(tkinter.TclError, self.combo.current, '')

        # testing creating combobox with empty string in values
        combo2 = ttk.Combobox(values=[1, 2, ''])
        self.assertEqual(combo2['values'], ('1', '2', ''))
        combo2.destroy()
项目:FunKii-UI    作者:dojafoja    | 项目源码 | 文件源码
def autocomplete(self, delta=0):
                """autocomplete the Combobox, delta may be 0/1/-1 to cycle through possible hits"""
                if delta: # need to delete selection otherwise we would fix the current position
                        self.delete(self.position, tkinter.END)
                else: # set position to end so selection starts where textentry ended
                        self.position = len(self.get())
                # collect hits
                _hits = []
                for element in self._completion_list:

                        box_value = self.get()
                        if element.lower().startswith(box_value.lower()): # Match case insensitively
                                _hits.append(element)
                # if we have a new hit list, keep this in mind
                if _hits != self._hits:
                        self._hit_index = 0
                        self._hits=_hits
                # only allow cycling if we are in a known hit list
                if _hits == self._hits and self._hits:
                        self._hit_index = (self._hit_index + delta) % len(self._hits)
                # now finally perform the auto completion
                if self._hits:
                        txt=self._hits[self._hit_index]
                        self.delete(0,tkinter.END)
                        self.insert(0,txt)
                        self.select_range(self.position,tkinter.END)
                        self.event_generate('<<ComboboxSelected>>')
                else:
                        self.event_generate('<<NoHits>>')
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def init_widgets(self):

        """Init all widgets"""

        # Source reference
        self.cb_source_ref = ttk.Combobox(self, textvariable=self.src_reference, state='normal')
        self.cb_source_ref['values'] = self.get_source_references()
        self.cb_source_ref.pack(side=LEFT, fill=X, expand=1)


        # Data type label
        self.l_data_type = ttk.Label(self, textvariable=self.src_datatype, width=8)
        self.src_datatype.set("Not set")

        self.l_data_type.pack(side=LEFT)

        # Dest reference
        self.cb_dest_ref = ttk.Combobox(self, textvariable=self.dest_reference, state='normal')
        self.cb_dest_ref['values'] = self.get_destination_references()
        self.cb_dest_ref.pack(side=RIGHT, fill=X, expand=1)

        # Is key field
        self.cb_is_key = ttk.Checkbutton(self, variable=self.is_key)
        self.cb_is_key.pack(side=RIGHT)

        # Current data
        self.l_data = ttk.Label(self, textvariable=self.curr_data)
        self.curr_data.set("No data")
        self.l_data.pack(side=RIGHT, fill=X, padx=5)
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def init_widgets(self):
        # file selector
        self.btn_file_select=Button(self, text="Select file",command=self.on_select)
        self.btn_file_select.grid(column=0, row=0, columnspan=2)

        # filename
        self.filename, self.e_filename, self.l_filename = make_entry(self, "File name: ", 1)

        # rows_xpath
        self.rows_xpath, self.e_rows_xpath, self.l_rows_xpath = make_entry(self, "Rows XPath: ", 2)

        # xpath_data_format
        self.xpath_data_format = StringVar()

        self.l_xpath_data_format = ttk.Label(self, text="Data format: :")
        self.l_xpath_data_format.grid(column=0, row=3)

        self.sel_xpath_data_format = ttk.Combobox(self, textvariable=self.xpath_data_format, state='readonly')
        self.sel_xpath_data_format['values'] = ["XML", "HTML"]
        self.sel_xpath_data_format.current(0)
        self.sel_xpath_data_format.grid(column=1, row=3)

        # xpath_text_qualifier
        self.xpath_text_qualifier, self.e_xpath_text_qualifier, self.l_xpath_text_qualifier = make_entry(self, "Text qualifier: ", 4)

        # encoding
        self.encoding, self.e_encoding, self.l_encoding = make_entry(self, "Encoding: ", 5)

        self.field_names = []
        self.field_xpaths = []
        self.field_types = []
项目:hunt_the_wumpus    作者:leonardoRampazzo    | 项目源码 | 文件源码
def add_posicoes(self):
        self.add_botoes_a_grid()
        self.buttonGO = Button(text="Start :>",command=self.start)
        self.buttonGO.grid(row=5,column=4)

        self.select = ttk.Combobox(width=10,value=['Facil', 'Médio', 'Dificil' , 'impossivel'])
        self.select.set("Facil")
        self.select.bind("<<ComboboxSelected>>", self.execute)
        self.select.state(['readonly'])
        self.select.grid(row=5,column=2)


        self.selectVel = ttk.Combobox(width=10,value=['Devagar', 'Normal', 'Rápido' , 'Flash'])
        self.selectVel.set("Devagar")
        self.selectVel.bind("<<ComboboxSelected>>", self.muda_velocidade)
        self.selectVel.state(['readonly'])
        self.selectVel.grid(row=6,column=2)

        self.label = Label(text="Pontos: 1000")
        self.label.grid(row=5,column=7)

        self.label1 = Label(text="Dificuldade:")
        self.label1.grid(row=5,column=1)

        self.label2 = Label(text="Velocidade:")
        self.label2.grid(row=6,column=1)

        self.text        = Text(height=30,width=50)
        self.text.grid(row=1,column=5,columnspan=3,rowspan=4,padx=5,pady=5)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Combobox(self.root, **kwargs)
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_combobox(self, exportselection: bool=False, justify: str="left", height: int=None, postcommand=None, state: str="normal", textvariable: tk.Variable=None, values: list=[], width: int=10, index: int or str="end", *args, **kwargs):
        """Insert a ttk.Combobox into the game."""
        widget = ttk.Combobox(self.text, exportselection=exportselection, justify=justify, height=height, postcommand=postcommand, state=state, textvariable=textvariable, values=values, width=width, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:serialplot    作者:crxguy52    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        ttk.Frame.__init__(self, parent)
        self.controller = controller
        self['padding'] = [0, 7, 0, 0]

        #Populate the serial configuration tab        
        self.baudlist = (4800, 9600, 19200, 38400, 57600, 115200, 230400, 921600)
        self.databitslist = (7, 8)
        self.stopbitslist = (1, 2)
        self.paritylist = ('None', 'Even', 'Odd', 'Mark', 'Space')

        baudlabel = ttk.Label(self, text='Baudrate')
        baudbox = ttk.Combobox(self, width=8, values=self.baudlist, 
                        textvariable=self.controller.TKvariables['baud'])
        datalabel = ttk.Label(self, text='Data bits')
        databox = ttk.Combobox(self, width=8, values = self.databitslist, \
                        textvariable=self.controller.TKvariables['databits'])            
        stopbitslabel = ttk.Label(self, text='Stop bits')
        stopbitsbox = ttk.Combobox(self, width=8, values=self.stopbitslist, \
                        textvariable=self.controller.TKvariables['stopbits'])          
        paritylabel = ttk.Label(self, text='Parity')
        paritybox = ttk.Combobox(self, width=8, values=self.paritylist, \
                        textvariable=self.controller.TKvariables['parity'])

        #ttk.Label(self, text='            ').grid(row=1, column=0)                
        baudlabel.grid(row=1, column = 1, padx=5)
        baudbox.grid(row=1, column=2, padx=5)
        datalabel.grid(row=2, column = 1, padx=5)
        databox.grid(row=2, column=2,  padx=5)
        stopbitslabel.grid(row=3, column = 1,  padx=5)
        stopbitsbox.grid(row=3, column=2,  padx=5)
        paritylabel.grid(row=4, column = 1,  padx=5)
        paritybox.grid(row=4, column=2,  padx=5)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Combobox(self.root, **kwargs)
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def set(self, val):
            if isinstance(self.entry, Combobox):
                self.entry.set(val)
            else:
                self.entry.delete(0, END)
                self.entry.insert(0, val)
项目:pyTrack    作者:clamytoe    | 项目源码 | 文件源码
def setup_tab3(tab):
    # remove frame
    remove_frame = ttk.LabelFrame(tab, text='Remove Project')
    remove_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')

    # Remove Project
    project_to_axe = tk.StringVar()

    walking_dead = ttk.Combobox(remove_frame, width=18, textvariable=project_to_axe, state='readonly')
    walking_dead['values'] = PROJECT_NAMES
    walking_dead.grid(columnspan=2, row=0, padx=5, pady=5)
    walking_dead.current(INDEX)
    walking_dead.configure(state='enabled') if PROJECTS else walking_dead.configure(state='disabled')

    # spacer
    spacer_label = ttk.Label(remove_frame, text='')
    spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)

    # add button and commands
    def remove_command():
        choice = PROJECTS[PROJECT_NAMES.index(walking_dead.get())].id
        remove_project(choice, safe=False)
        spacer_label.configure(text='Project was removed!', foreground='green')
        walking_dead.set('')
        init_globals()
        setup_tab1(TAB_1)
        if not PROJECTS:
            walking_dead.configure(state='disabled')
            remove_button.configure(state='disabled')

    remove_button = ttk.Button(tab, text='Remove Project', command=remove_command)
    remove_button.grid(columnspan=2, row=3, pady=5)
    remove_button.configure(state='enabled') if PROJECTS else remove_button.configure(state='disabled')
项目:tools4dou    作者:anddreiferreira    | 项目源码 | 文件源码
def __combobox(self):
    self.combobox_value = StringVar()
    self.combobox_gui = ttk.Combobox(self.parent, textvariable=self.combobox_value, state='readonly')
    self.combobox_gui['values'] = ('Selecione...', 'MongoDB', 'Elasticsearch')
    self.combobox_gui.current(0)
    self.combobox_gui.grid(column=1, row=8, sticky=(W, E))
项目:pyCSS    作者:eamontoyaa    | 项目源码 | 文件源码
def wantEvaluateOnlyOneSurfaceActivate():
    if wantEvaluateOnlyOneSurfaceVal.get() == True:
        Entry(slipCircleFrame, width=8, textvariable=\
            hztDistPointAtCrownFromCrownVal, state='normal').place(x=366, y=60)
        Entry(slipCircleFrame, width=8, \
            textvariable=hztDistPointAtToeFromCrownVal, state='normal').place(\
            x=366, y=80)
        Entry(slipCircleFrame, width=8, textvariable=slipRadiusVal, \
            state='normal').place(x=366, y=100) ###---
        Entry(slipCircleFrame, width=8, textvariable=numCirclesVal, \
            state='disabled').place(x=690, y=40)
        Entry(slipCircleFrame, width=8, textvariable=radiusIncrementVal, \
            state='disabled').place(x=690, y=60)
        Entry(slipCircleFrame, width=8, textvariable=numberIncrementsVal, \
            state='disabled').place(x=690, y=80)
        Entry(slipCircleFrame, width=8, textvariable=maxFsValueContVal, \
            state='disabled').place(x=690, y=100) ###---
        ttk.Combobox(values=['Fellenius', 'Bishop', 'Ambos'], state='normal',\
            textvariable=methodStringVal, width=7).place(x=420, y=300)  
    else:
        Entry(slipCircleFrame, width=8, textvariable=\
            hztDistPointAtCrownFromCrownVal, state='disabled').place(\
            x=366, y=60)
        Entry(slipCircleFrame, width=8, \
            textvariable=hztDistPointAtToeFromCrownVal, state='disabled').\
            place(x=366, y=80)
        Entry(slipCircleFrame, width=8, textvariable=slipRadiusVal, \
            state='disabled').place(x=366, y=100) ###---        
        Entry(slipCircleFrame, width=8, textvariable=numCirclesVal, \
            state='normal').place(x=690, y=40)
        Entry(slipCircleFrame, width=8, textvariable=radiusIncrementVal, \
            state='normal').place(x=690, y=60)
        Entry(slipCircleFrame, width=8, textvariable=numberIncrementsVal, \
            state='normal').place(x=690, y=80)
        Entry(slipCircleFrame, width=8, textvariable=maxFsValueContVal, \
            state='normal').place(x=690, y=100) ###---
        methodStringVal.set('Ambos')
        ttk.Combobox(values=['Fellenius', 'Bishop', 'Ambos'], state='disable',\
            textvariable=methodStringVal, width=7).place(x=420, y=300)
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def create_zip_button(self, gs):
        """Expand frame to reveal options when Create ZIP File is selected."""
        if self.zip_button_var.get() == 1:
            self.split_button_var = tk.IntVar()
            self.split_button = ttk.Checkbutton(self.zip_frame,
                                                text='Split ZIP File',
                                                variable=self.split_button_var)
            self.split_button.grid(row=2, column=0, sticky='w')
            self.split_button.grid_configure(padx=2, pady=5)
            self.split_entry_var = tk.IntVar()
            self.split_entry = ttk.Entry(self.zip_frame,
                                         width=3,
                                         justify='right',
                                         textvariable=self.split_entry_var)
            self.split_entry.grid(row=2, column=1, sticky='e')
            self.split_entry.grid_configure(pady=5)
            self.split_entry_var.set('2')
            self.split_combo = ttk.Combobox(self.zip_frame,
                                            width=4,
                                            justify='left',
                                            values='MB GB')
            self.split_combo.current(1)
            self.split_combo.grid(row=2, column=2, sticky='w')
            self.split_combo.grid_configure(pady=5)
        else:
            self.split_button.destroy()
            self.split_entry.destroy()
            self.split_combo.destroy()
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def create_zip_button(self, gs):
        """Expand frame to reveal options when Create ZIP File is selected."""
        if self.zip_button_var.get() == 1:
            self.split_button_var = tk.IntVar()
            self.split_button = ttk.Checkbutton(self.zip_frame,
                                                text='Split ZIP File',
                                                variable=self.split_button_var)
            self.split_button.grid(row=2, column=0, sticky='w')
            self.split_button.grid_configure(padx=2, pady=5)
            self.split_entry_var = tk.IntVar()
            self.split_entry = ttk.Entry(self.zip_frame,
                                         width=3,
                                         justify='right',
                                         textvariable=self.split_entry_var)
            self.split_entry.grid(row=2, column=1, sticky='e')
            self.split_entry.grid_configure(pady=5)
            self.split_entry_var.set('2')
            self.split_combo = ttk.Combobox(self.zip_frame,
                                            width=4,
                                            justify='left',
                                            values='MB GB')
            self.split_combo.current(1)
            self.split_combo.grid(row=2, column=2, sticky='w')
            self.split_combo.grid_configure(pady=5)
        else:
            self.split_button.destroy()
            self.split_entry.destroy()
            self.split_combo.destroy()
项目:qcri    作者:douville    | 项目源码 | 文件源码
def _create_local_pane(self, full_pane):
        local_pane = tk.LabelFrame(full_pane, text='Test Results')

        self.choose_results_button = tk.Button(
            local_pane,
            text='Results',
            width=15,
            command=self._load_run_results)
        self.choose_results_button.grid(
            row=0, column=0, sticky='ew', padx=10, pady=5)
        self.choose_results_entry = tk.Entry(
            local_pane, state='disabled', textvariable=self.runresultsvar)
        self.choose_results_entry.grid(
            row=0, column=1, sticky='nsew', padx=10, pady=5)
        self.choose_parser = ttk.Combobox(
            local_pane, show='', state='disabled')
        self.choose_parser.bind(
            '<<ComboboxSelected>>', self._on_parser_changed)
        self.choose_parser.grid(
            row=1, column=0, columnspan=2, sticky='nsew', padx=10, pady=7)
        self.runresultsview = TestResultsView(
            local_pane, on_selected=self._on_test_result_selected)
        self.runresultsview.grid(
            row=2, column=0, columnspan=2, sticky='nsew', padx=10, pady=5)
        self.runresultsview.rowconfigure(0, weight=1)
        self.runresultsview.columnconfigure(0, weight=1)

        local_pane.rowconfigure(2, weight=1)
        local_pane.columnconfigure(1, weight=1)
        local_pane.config(padx=10)
        return local_pane
项目:qcri    作者:douville    | 项目源码 | 文件源码
def _make_combo(self, frame, text):
        tk.Label(frame, text='{}:'.format(text)).pack(side=tk.TOP)
        cbo = ttk.Combobox(frame, width=16, show='')
        cbo.pack(side=tk.TOP, padx=10, fill=tk.BOTH)
        cbo.bind('<Return>', self.check_password)
        cbo['values'] = self.history.get(text.lower(), [])
        if cbo['values']:
            cbo.set(cbo['values'][-1])
        return cbo
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
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
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def createWidgets():    
    tabControl = ttk.Notebook(win)     
    tab1 = ttk.Frame(tabControl)            
    tabControl.add(tab1, text='Tab 1')    
    tabControl.pack(expand=1, fill="both")  
    monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)        

    ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
    name = tk.StringVar()
    nameEntered = ttk.Entry(monty, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1, sticky='W')

    action = ttk.Button(monty, text="Click Me!")   
    action.grid(column=2, row=1)

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

    scrolW = 30; scrolH = 3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)

    menuBar = Menu(tab1)
    win.config(menu=menuBar)
    fileMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="File", menu=fileMenu)
    helpMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="Help", menu=helpMenu)

    nameEntered.focus()     
#======================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def display_tab1():
    # Container frame to hold all other widgets
    monty = ttk.LabelFrame(display_area, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)

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

    # Adding a Textbox Entry widget
    name = tk.StringVar()
    nameEntered = ttk.Entry(monty, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1, sticky='W')

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

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

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

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

    # Adding another Button
    clear = ttk.Button(monty, text="Clear Text", command= lambda: clearScrol(scr))   
    clear.grid(column=2, row=2)

    # Adding more Feature Buttons
    startRow = 4
    for idx in range(12):
        if idx < 2:
            colIdx = idx
            col = colIdx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0

        b = ttk.Button(monty, text="Feature " + str(idx+1))   
        b.grid(column=col, row=startRow)   

#------------------------------------------
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        

        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')

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

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

        scrolW = 30; scrolH = 3
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        fileMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="File", menu=fileMenu)
        helpMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="Help", menu=helpMenu)

        nameEntered.focus()     
#==========================
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_values(self):
        def check_get_current(getval, currval):
            self.assertEqual(self.combo.get(), getval)
            self.assertEqual(self.combo.current(), currval)

        self.assertEqual(self.combo['values'],
                         () if tcl_version < (8, 5) else '')
        check_get_current('', -1)

        self.checkParam(self.combo, 'values', 'mon tue wed thur',
                        expected=('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string'))
        self.checkParam(self.combo, 'values', '',
                        expected='' if get_tk_patchlevel() < (8, 5, 10) else ())

        self.combo['values'] = ['a', 1, 'c']

        self.combo.set('c')
        check_get_current('c', 2)

        self.combo.current(0)
        check_get_current('a', 0)

        self.combo.set('d')
        check_get_current('d', -1)

        # testing values with empty string
        self.combo.set('')
        self.combo['values'] = (1, 2, '', 3)
        check_get_current('', 2)

        # testing values with empty string set through configure
        self.combo.configure(values=[1, '', 2])
        self.assertEqual(self.combo['values'],
                         ('1', '', '2') if self.wantobjects else
                         '1 {} 2')

        # testing values with spaces
        self.combo['values'] = ['a b', 'a\tb', 'a\nb']
        self.assertEqual(self.combo['values'],
                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
                         '{a b} {a\tb} {a\nb}')

        # testing values with special characters
        self.combo['values'] = [r'a\tb', '"a"', '} {']
        self.assertEqual(self.combo['values'],
                         (r'a\tb', '"a"', '} {') if self.wantobjects else
                         r'a\\tb {"a"} \}\ \{')

        # out of range
        self.assertRaises(tkinter.TclError, self.combo.current,
            len(self.combo['values']))
        # it expects an integer (or something that can be converted to int)
        self.assertRaises(tkinter.TclError, self.combo.current, '')

        # testing creating combobox with empty string in values
        combo2 = ttk.Combobox(self.root, values=[1, 2, ''])
        self.assertEqual(combo2['values'],
                         ('1', '2', '') if self.wantobjects else '1 2 {}')
        combo2.destroy()
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_values(self):
        def check_get_current(getval, currval):
            self.assertEqual(self.combo.get(), getval)
            self.assertEqual(self.combo.current(), currval)

        self.assertEqual(self.combo['values'],
                         () if tcl_version < (8, 5) else '')
        check_get_current('', -1)

        self.checkParam(self.combo, 'values', 'mon tue wed thur',
                        expected=('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string'))
        self.checkParam(self.combo, 'values', '',
                        expected='' if get_tk_patchlevel() < (8, 5, 10) else ())

        self.combo['values'] = ['a', 1, 'c']

        self.combo.set('c')
        check_get_current('c', 2)

        self.combo.current(0)
        check_get_current('a', 0)

        self.combo.set('d')
        check_get_current('d', -1)

        # testing values with empty string
        self.combo.set('')
        self.combo['values'] = (1, 2, '', 3)
        check_get_current('', 2)

        # testing values with empty string set through configure
        self.combo.configure(values=[1, '', 2])
        self.assertEqual(self.combo['values'],
                         ('1', '', '2') if self.wantobjects else
                         '1 {} 2')

        # testing values with spaces
        self.combo['values'] = ['a b', 'a\tb', 'a\nb']
        self.assertEqual(self.combo['values'],
                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
                         '{a b} {a\tb} {a\nb}')

        # testing values with special characters
        self.combo['values'] = [r'a\tb', '"a"', '} {']
        self.assertEqual(self.combo['values'],
                         (r'a\tb', '"a"', '} {') if self.wantobjects else
                         r'a\\tb {"a"} \}\ \{')

        # out of range
        self.assertRaises(tkinter.TclError, self.combo.current,
            len(self.combo['values']))
        # it expects an integer (or something that can be converted to int)
        self.assertRaises(tkinter.TclError, self.combo.current, '')

        # testing creating combobox with empty string in values
        combo2 = ttk.Combobox(self.root, values=[1, 2, ''])
        self.assertEqual(combo2['values'],
                         ('1', '2', '') if self.wantobjects else '1 2 {}')
        combo2.destroy()
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_gui(self):
        """Builds GUI."""
        self.root.title('Kindle to Anki')

        self.grid(column=0, row=0, sticky='nsew')

        # Load vocabulary file

        ttk.Label(self, text='Vocabulary file').grid(column=0, row=0)

        self.db_entry = ttk.Entry(self, width=30)
        self.db_entry.grid(column=1, row = 0)

        self.loaddb_button = ttk.Button(self, text='Load',
                                      command=self.load_words)
        self.loaddb_button.grid(column=2, row=0)

        # Choose language

#        ttk.Label(self, text='Language').grid(column=0, row=1)
#        self.lang_entry = ttk.Combobox(self, width=15)
#        self.lang_entry.grid(column=1, row = 1)
#        self.lang_entry['values'] = ('en')
#        self.lang_entry.state(['readonly'])

        # Load from OED         

        ttk.Label(self, text='App id').grid(column=0, row=2)
        self.appid_entry = ttk.Entry(self, width=30)
        self.appid_entry.grid(column=1, row = 2)

        ttk.Label(self, text='App key').grid(column=0, row=3)
        self.keyid_entry = ttk.Entry(self, width=30)
        self.keyid_entry.grid(column=1, row = 3)

        self.loadOED_button = ttk.Button(self, text='Load definitions from OED',
                                      command=self.load_OED)
        self.loadOED_button.grid(column=2, row=2, columnspan = 2, rowspan = 2)
        self.loadOED_button.state(['disabled'])

        # Create vocabulary file

        ttk.Label(self, text='Anki deck location:').grid(column=0, row=4)

        self.deck_entry = ttk.Entry(self, width=30)
        self.deck_entry.grid(column=1, row = 4)

        self.create_button = ttk.Button(self, text='Create Anki Deck',
                                      command=self.create_deck)
        self.create_button.grid(column=2, row=4)
        self.create_button.state(['disabled'])


        for child in self.winfo_children():
            child.grid_configure(padx=5, pady=5)
项目:ted-editor    作者:tarnheld    | 项目源码 | 文件源码
def expand(self):
        self.expFrame = f = tk.Frame(self)
        f.columnconfigure(0, weight=1)
        f.grid(sticky='we')

        f1 = tk.Frame(f)
        f1.columnconfigure(1, weight=1)
        f1.grid(sticky='we')

        labels = ['Path-fitting', 'Auto-rejoin', 'Offset x', 'Offset z', 'Repeat']

        for row, text in enumerate(labels):
            l = tk.Label(f1, text=text, font=self.labelFont, anchor='w')
            l.grid(row=row, column = 0, sticky='we')

        PF = ttk.Combobox(f1, takefocus=False, width=6, font=self.labelFont,
                                  textvariable = self.pathfitting,
                                  values=('None', 'Stretch', 'Scale'), state="readonly")
        PF.grid(row=0, column = 1, sticky='we')
        PF.bind("<<ComboboxSelected>>", self.draw)

        JM = ttk.Combobox(f1, takefocus=False, width=6, font=self.labelFont,
                                  textvariable = self.joint_mode,
                                  values=('None', 'Lift', 'Bend'), state="readonly")
        JM.grid(row=1, column = 1, sticky='we')
        JM.bind("<<ComboboxSelected>>", self.draw)

        OS_x = FloatEntry(f1, textvariable = self.x_offset, font=self.labelFont, width=5)
        OS_x.grid(row=2, column = 1, sticky='we')
        OS_x.bind('<Return>', self.draw)
        OS_x.bind('<FocusOut>', self.draw)

        OS_z = FloatEntry(f1, textvariable = self.z_offset, font=self.labelFont, width=5)
        OS_z.grid(row=3, column = 1, sticky='we')
        OS_z.bind('<Return>', self.draw)
        OS_z.bind('<FocusOut>', self.draw)

        RP = tk.Checkbutton(f1, variable=self._repeat, command=self.draw)
        RP.grid(row=4, column = 1, sticky='w')

        sep = ttk.Separator(f, orient=tk.HORIZONTAL)
        sep.grid(padx=2, sticky='we')

        f2 = tk.Frame(f)
        for i in range(0, 3):
            f2.columnconfigure(i, weight=1)
        f2.grid(sticky='we')

        DS = tk.Checkbutton(f2, text='Display', width=5, font=self.labelFont,
                            indicatoron=False, bd=1, variable=self._display,
                            command=self.draw)
        DS.grid(row=0, column=0, sticky='wens', pady=2, padx=1)

        self.SET = tk.Button(f2, text='Set', width=5, font=self.labelFont, bd=1, command=self.applyCommand)
        self.SET.grid(row=0, column=1, sticky='we', pady=2, padx=1)

        self.ADD = tk.Button(f2, text='Add', width=5, font=self.labelFont, bd=1, command = lambda: self.applyCommand(mode='add'))
        self.ADD.grid(row=0, column=2, sticky='we', pady=2, padx=1)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_values(self):
        def check_get_current(getval, currval):
            self.assertEqual(self.combo.get(), getval)
            self.assertEqual(self.combo.current(), currval)

        self.assertEqual(self.combo['values'],
                         () if tcl_version < (8, 5) else '')
        check_get_current('', -1)

        self.checkParam(self.combo, 'values', 'mon tue wed thur',
                        expected=('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string'))
        self.checkParam(self.combo, 'values', '',
                        expected='' if get_tk_patchlevel() < (8, 5, 10) else ())

        self.combo['values'] = ['a', 1, 'c']

        self.combo.set('c')
        check_get_current('c', 2)

        self.combo.current(0)
        check_get_current('a', 0)

        self.combo.set('d')
        check_get_current('d', -1)

        # testing values with empty string
        self.combo.set('')
        self.combo['values'] = (1, 2, '', 3)
        check_get_current('', 2)

        # testing values with empty string set through configure
        self.combo.configure(values=[1, '', 2])
        self.assertEqual(self.combo['values'],
                         ('1', '', '2') if self.wantobjects else
                         '1 {} 2')

        # testing values with spaces
        self.combo['values'] = ['a b', 'a\tb', 'a\nb']
        self.assertEqual(self.combo['values'],
                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
                         '{a b} {a\tb} {a\nb}')

        # testing values with special characters
        self.combo['values'] = [r'a\tb', '"a"', '} {']
        self.assertEqual(self.combo['values'],
                         (r'a\tb', '"a"', '} {') if self.wantobjects else
                         r'a\\tb {"a"} \}\ \{')

        # out of range
        self.assertRaises(tkinter.TclError, self.combo.current,
            len(self.combo['values']))
        # it expects an integer (or something that can be converted to int)
        self.assertRaises(tkinter.TclError, self.combo.current, '')

        # testing creating combobox with empty string in values
        combo2 = ttk.Combobox(self.root, values=[1, 2, ''])
        self.assertEqual(combo2['values'],
                         ('1', '2', '') if self.wantobjects else '1 2 {}')
        combo2.destroy()
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def __init__(self, master=None, **kw):
        """
        GUI tab that handles interface and region selection and starting the server.
        :param master: root window
        :param kw: args
        """
        FrameTab.__init__(self, master, **kw)
        self.wii_u_interface = None
        self.normal_interface = None
        self.drc_sim_c = None
        self.wpa_supplicant = None
        LoggerGui.extra("Initializing FrameRunServer")
        # Create Widgets
        self.label_wpa = Label(self, text="Wii U Connection:")
        self.label_backend = Label(self, text="Server Status:")
        self.label_wpa_status = Label(self)
        self.label_backend_status = Label(self)
        self.button_start = Button(self, text="Start")
        self.button_stop = Button(self, text="Stop")
        self.label_wiiu_interface = Label(self, text="Wii U Interface")
        self.label_normal_interface = Label(self, text="Normal Interface")
        self.dropdown_wiiu_interface = Combobox(self, state="readonly")
        self.dropdown_normal_interface = Combobox(self, state="readonly")
        self.label_interface_info = Label(self)
        self.label_region = Label(self, text="Region")
        self.dropdown_region = Combobox(self, state="readonly")
        # Events
        self.button_start.bind("<Button-1>", self.start_server)
        self.button_stop.bind("<Button-1>", self.stop_server)
        # Position widgets
        self.label_wpa.grid(column=0, row=0, sticky="e")
        self.label_backend.grid(column=0, row=1, sticky="e")
        self.label_wpa_status.grid(column=1, row=0, sticky="w")
        self.label_backend_status.grid(column=1, row=1, sticky="w")
        self.label_wiiu_interface.grid(column=0, row=2)
        self.label_normal_interface.grid(column=0, row=3)
        self.dropdown_wiiu_interface.grid(column=1, row=2, columnspan=2)
        self.dropdown_normal_interface.grid(column=1, row=3, columnspan=2)
        self.label_region.grid(column=0, row=4)
        self.dropdown_region.grid(column=1, row=4, columnspan=2)
        self.button_start.grid(column=1, row=5)
        self.button_stop.grid(column=2, row=5)
        self.label_interface_info.grid(column=0, row=6, columnspan=3)
        LoggerGui.extra("Initialized FrameRunServer")
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def __init__(self, master=None, **kw):
        FrameTab.__init__(self, master, **kw)
        self.wpa_supplicant = None
        self.getting_psk = False
        # Widgets
        button_size = 50
        # Spade
        self.button_spade = Button(self, width=button_size, height=button_size)
        self.button_spade.image = self.get_image("image/spade.gif", button_size, button_size)
        self.button_spade.config(image=self.button_spade.image)
        self.button_spade.number = 0
        # Heart
        self.button_heart = Button(self, width=button_size, height=button_size)
        self.button_heart.image = self.get_image("image/heart.gif", button_size, button_size)
        self.button_heart.config(image=self.button_heart.image)
        self.button_heart.number = 1
        # Diamond
        self.button_diamond = Button(self, width=button_size, height=button_size)
        self.button_diamond.image = self.get_image("image/diamond.gif", button_size, button_size)
        self.button_diamond.config(image=self.button_diamond.image)
        self.button_diamond.number = 2
        # Clover
        self.button_clover = Button(self, width=button_size, height=button_size)
        self.button_clover.image = self.get_image("image/clover.gif", button_size, button_size)
        self.button_clover.config(image=self.button_clover.image)
        self.button_clover.number = 3
        # Delete
        self.button_delete = Button(self, text="Delete")
        # Code
        self.entry_pair_code = Entry(self, state="readonly")
        # Status Message
        self.status_message = Label(self, state="readonly")
        # interface dropdown
        self.dropdown_wii_u = Combobox(self, state="readonly")
        # Events
        self.button_spade.bind("<Button-1>", self.button_clicked)
        self.button_heart.bind("<Button-1>", self.button_clicked)
        self.button_diamond.bind("<Button-1>", self.button_clicked)
        self.button_clover.bind("<Button-1>", self.button_clicked)
        self.button_delete.bind("<Button-1>", self.button_delete_clicked)
        # Grid
        self.button_spade.grid(column=0, row=0)
        self.button_heart.grid(column=1, row=0)
        self.button_diamond.grid(column=2, row=0)
        self.button_clover.grid(column=3, row=0)
        self.button_delete.grid(column=4, row=0)
        self.entry_pair_code.grid(column=0, row=1, columnspan=5)
        self.status_message.grid(column=0, row=3, columnspan=5)
        self.dropdown_wii_u.grid(column=0, row=2, columnspan=5)

    # noinspection PyUnusedLocal
项目:serialplot    作者:crxguy52    | 项目源码 | 文件源码
def __init__(self, parent):
        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self['padding'] = '4'

        self.TKvariables = {}

        #Read in the defaults
        for key in defaults:

            if key[0:5] == 'graph' or key.find('ylims') >= 0:
                self.TKvariables.update({key:[]})

                for val in range(len(defaults[key])):
                    self.TKvariables[key].append(tk.StringVar(value=defaults[key][val]))

            else:
                self.TKvariables.update({key:tk.StringVar(value=defaults[key])})      

        num_vars = int(self.TKvariables['datalength'].get())
        self.datalist = list(range(1,num_vars+1))

        #Create a combobox containing the available COM ports        
        comlst = self.get_comlst()
        self.COMbox = ttk.Labelframe(self, text='COM port to source data from')
        self.COMcombo = ttk.Combobox(self.COMbox,  width=60, values=comlst, \
            state='readonly', textvariable=self.TKvariables['COMport'],\
            postcommand=self.updateCOMbox )
        self.COMbox.grid(row = 0, column = 0, columnspan = 5)
        self.COMcombo.grid()

        #Create an "about" text box
        ABOUTframe = ttk.LabelFrame(self, text = 'What it does')
        ABOUTlabel = ttk.Label(ABOUTframe, text= \
            'Graphs data coming in over the serial port in a comma '
            'seperated variable string. Hover over each option to get ' 
            'a description of what the setting does', wraplength = 140)
        ABOUTframe.grid(row=1, column = 0, rowspan = 2, columnspan = 2, \
            sticky = 'nw, se', padx= 3, pady = 5)
        CreateToolTip(ABOUTlabel,\
        "The default values can be changed by opening defaults.py with a text "
        "editor and changing the values")
        ABOUTlabel.pack()        

        #Create a Graph! and About buttons
        GObut = ttk.Button(self, text='Go!', command=self.goButton)
        GObut.grid(row=6, column = 0, sticky = 'we')
        ABOUTbut = ttk.Button(self, text='About', command=self.aboutButton) 
        ABOUTbut.grid(row = 6, column = 1, sticky = 'we')

        #Create an instance of the class for the config panel
        notebook = ConfigNotebook(self, self)

        #Update the state of the graphs based on the defaults and grid
        notebook.updateGraphs()     
        notebook.grid(row=1, column=3, columnspan=2, rowspan=6, sticky = 'nsew', \
                padx = 5, pady = 5)

        #Bind the enter key to start the program
        self.parent.bind("<Return>", lambda event:self.goButton())
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_values(self):
        def check_get_current(getval, currval):
            self.assertEqual(self.combo.get(), getval)
            self.assertEqual(self.combo.current(), currval)

        self.assertEqual(self.combo['values'],
                         () if tcl_version < (8, 5) else '')
        check_get_current('', -1)

        self.checkParam(self.combo, 'values', 'mon tue wed thur',
                        expected=('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur'))
        self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string'))
        self.checkParam(self.combo, 'values', '', expected=())

        self.combo['values'] = ['a', 1, 'c']

        self.combo.set('c')
        check_get_current('c', 2)

        self.combo.current(0)
        check_get_current('a', 0)

        self.combo.set('d')
        check_get_current('d', -1)

        # testing values with empty string
        self.combo.set('')
        self.combo['values'] = (1, 2, '', 3)
        check_get_current('', 2)

        # testing values with empty string set through configure
        self.combo.configure(values=[1, '', 2])
        self.assertEqual(self.combo['values'],
                         ('1', '', '2') if self.wantobjects else
                         '1 {} 2')

        # testing values with spaces
        self.combo['values'] = ['a b', 'a\tb', 'a\nb']
        self.assertEqual(self.combo['values'],
                         ('a b', 'a\tb', 'a\nb') if self.wantobjects else
                         '{a b} {a\tb} {a\nb}')

        # testing values with special characters
        self.combo['values'] = [r'a\tb', '"a"', '} {']
        self.assertEqual(self.combo['values'],
                         (r'a\tb', '"a"', '} {') if self.wantobjects else
                         r'a\\tb {"a"} \}\ \{')

        # out of range
        self.assertRaises(tkinter.TclError, self.combo.current,
            len(self.combo['values']))
        # it expects an integer (or something that can be converted to int)
        self.assertRaises(tkinter.TclError, self.combo.current, '')

        # testing creating combobox with empty string in values
        combo2 = ttk.Combobox(self.root, values=[1, 2, ''])
        self.assertEqual(combo2['values'],
                         ('1', '2', '') if self.wantobjects else '1 2 {}')
        combo2.destroy()
项目:pyGISS    作者:afourmy    | 项目源码 | 文件源码
def __init__(self, controller):            
        super().__init__(controller)
        self.configure(background='#A1DBCD')   

        lf_creation = ttk.Labelframe(
                                     self, 
                                     text = 'Object management', 
                                     padding = (6, 6, 12, 12)
                                     )
        lf_creation.grid(row=0, column=0, padx=5, pady=5)

        psf_object_label = tk.Label(
                               self, 
                               image = controller.psf_button_image, 
                               relief = 'flat', 
                               bg = '#A1DBCD'
                               )
        psf_object_label.bind('<Button-1>', controller.start_drag_and_drop)
        psf_object_label.grid(row=0, column=0, pady=10, padx=55, in_=lf_creation)

        import_nodes_button = ttk.Button(self, text='Import nodes',
                            command=controller.map.import_nodes, width=20)
        import_nodes_button.grid(row=2, column=0, pady=5, in_=lf_creation)

        lf_projection = ttk.Labelframe(
                                       self, 
                                       text = 'Projection management', 
                                       padding = (6, 6, 12, 12)
                                       )
        lf_projection.grid(row=1, column=0, padx=5, pady=5)

        self.projection_list = ttk.Combobox(self, width=18)
        self.projection_list['values'] = tuple(controller.map.projections)
        self.projection_list.current(0)
        self.projection_list.grid(row=0, column=0, in_=lf_projection)

        change_projection_button = ttk.Button(self, text='Change projection',
                            command=controller.map.change_projection, width=20)
        change_projection_button.grid(row=1, column=0, pady=5, in_=lf_projection)

        lf_map_management = ttk.Labelframe(
                                        self, 
                                        text = 'Map management', 
                                        padding = (6, 6, 12, 12)
                                        )
        lf_map_management.grid(row=2, column=0, padx=5, pady=5)

        delete_map = ttk.Button(self, text='Delete map',
                            command=controller.map.delete_map, width=20)
        delete_map.grid(row=0, column=0, pady=5, in_=lf_map_management)

        delete_selection = ttk.Button(self, text='Delete selected nodes',
                            command=controller.map.delete_selected_nodes, width=20)
        delete_selection.grid(row=1, column=0, pady=5, in_=lf_map_management)
项目:BrickUsingMultipleModules    作者:hackffm    | 项目源码 | 文件源码
def add_module_line(self, row, module_id, module_desc, expected_revisions):
        self.module_controls[module_id] = {}
        controls = self.module_controls[module_id]
        module_id_widget = ttk.Label(self.table, text=module_id, **table_default_style)
        module_id_widget.grid(row=row, column=COL_ID, sticky=tk.N+tk.S+tk.E+tk.W)

        # revision
        revision = module_desc["revision"]
        if expected_revisions is None:
            rev_text = "{}*".format(revision)
            color = None
        else:
            try:
                if revision == int(expected_revisions[module_id]):
                    rev_text = revision
                    color = None
                else:
                    rev_text = "{} / {}".format(revision, expected_revisions[module_id])
                    color = "red"
            except KeyError:
                rev_text = "{} / ?".format(revision)
                color = "red"

        module_revision = ttk.Label(self.table, text=rev_text, background=color, **table_default_style)
        module_revision.grid(row=row, column=COL_REVISION, sticky=tk.N+tk.S+tk.E+tk.W)

        # nextstate
        module_nextstate = ttk.Combobox(self.table, values=["on", "random", "off"], state="readonly")
        module_nextstate.grid(row=row, column=COL_NEXTSTATE, sticky=tk.N+tk.S+tk.E+tk.W)
        module_nextstate.current(1)
        controls["nextstate"] = module_nextstate

        # random value
        random_value = tk.StringVar()
        module_random = tk.Entry(self.table, textvariable=random_value, disabledforeground="black")
        module_random.grid(row=row, column=COL_RANDOMNUMBER, sticky=tk.N+tk.S+tk.E+tk.W)
        controls["random"] = module_random
        controls["random_value"] = random_value
        self.make_red_on_invalid_change(random_value, module_random, lambda module_id=module_id: self.parse_randomness_string(module_id))
        random_value.trace("w", lambda *args: self.disable_widgets_if_necessary())
        self.disable_while_running.append(module_random)

        # state
        module_state = ttk.Label(self.table, text="?", **table_default_style)
        module_state.grid(row=row, column=COL_STATE, sticky=tk.N+tk.S+tk.E+tk.W)
        controls["state"] = module_state

        # failure counter
        module_fail = ttk.Label(self.table, text="?", **table_default_style)
        module_fail.grid(row=row, column=COL_FAILURES, sticky=tk.N+tk.S+tk.E+tk.W)
        controls["fail"] = module_fail

        # ui description
        module_description = ttk.Label(self.table, text="?", relief=tk.RIDGE)
        module_description.grid(row=row, column=COL_DESCRIPTION, sticky=tk.N+tk.S+tk.E+tk.W)
        controls["desc"] = module_description

        # solve button
        module_solve = ttk.Button(self.table, text="solve", command=lambda module_id=module_id: self.solve(module_id), width=WIDTH_SHORT)
        module_solve.grid(row=row, column=COL_SOLVE)