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


Python OptionMenu.config方法代码示例

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


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

示例1: HiddenNeuronNumber

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class HiddenNeuronNumber(Frame):
    def __init__(self, parent, layer_id):
        Frame.__init__(self, parent)
        self.parent = parent
        
        # Layer id is a number in range(MAX_NUMBER_OF_HIDDEN_LAYERS)
        self.layer_id = layer_id
        
        label_text = 'Neurons for layer {0}: '.format(layer_id + 1)
        self.label = Label(self, text = label_text)
        self.label.grid(row=0, column=0)
         
        
        number_options = range(1, MAX_NEURON_NUMBER_PER_HIDDEN_LAYER + 1)
        self.selected_number = \
                    IntVar(self, value = DEFAULT_NEURON_NUMBER_PER_HIDDEN_LAYER)
     
        self.option_menu = OptionMenu(self, self.selected_number, \
                                      *number_options)
        self.option_menu.grid(row=0, column=1)

        self.disable()
    
    def get(self):
        return self.selected_number.get()
        
    def enable(self):
        self.label.config(state = 'normal')
        self.option_menu.config(state = 'normal')
        
    def disable(self):
        self.label.config(state = 'disabled')
        self.option_menu.config(state = 'disabled')
开发者ID:fmihaich,项目名称:annic,代码行数:35,代码来源:perceptron_hidden_layers.py

示例2: FileFrame

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class FileFrame(Frame):
    """
    Gui frame that is tied to a FileGroup object.
    """
    def __init__(self,parent,active=False,fileGroup=FileGroup(),\
                 *args,**kwargs):
        Frame.__init__(self,parent,*args,**kwargs)
        self.parent = parent
        self.active = active
        self.fileGroup = fileGroup
        self.initUIElements()
        self.gridUIElements()

    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)

    def gridUIElements(self):
        self.fileMenu.config(width=10)
        self.fileMenu.grid(row=0,column=0)
        if self.active:
            self.select.grid(row=0,column=1)

    def onSelect(self):
        menu = self.fileMenu["menu"]
        menu.delete(0, "end")
        paths = tkFileDialog.askopenfilenames(parent=self)
        if len(paths) > 0:
            map(self.fileGroup.addFile,paths)
            self.resetFileMenu(paths,0)

    def resetFileMenu(self, options, index=None):
        menu = self.fileMenu["menu"]
        menu.delete(0, "end")
        for string in options:
            command=Tkinter._setit(self.var, string, None)
            menu.add_command(label=string,command=command)
        if index is not None:
            self.var.set(options[index])

    def getResourcePaths(self):
        return self.fileGroup.getResourcePaths()
开发者ID:crosslinks,项目名称:XlinkAnalyzer,代码行数:51,代码来源:item.py

示例3: __init__

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
    def __init__(self, controller):
        # initialize the GUI
        self.app = Tk()
        self.app.title('Tic Tac Toe')
        self.app.resizable(width=False, height=False)
        self.game_controller = controller   # interface to the game

        self.winner = None  # who has won the game

        # make the board
        self.buttons = [[None for i in range(SIZE)] for j in range(SIZE)]
        for x in range(SIZE):
            for y in range(SIZE):
                handler = lambda x=x, y=y: self.move(x,y)   # each button corresponds to making a move in that square
                self.buttons[x][y] = self.make_button(text='', command=handler, row=y, column=x+SIZE, width=1)
        
        # button to reset the board
        self.make_button(text='New Game', command=lambda:self.reset(), row=SIZE+1, column=SIZE)
        # button that makes the machine learn
        self.make_button(text='Learn', command=lambda:self.learn(), row=SIZE+1, column=SIZE+SIZE/2)
        # button that causes the machine to forget how to play
        self.make_button(text='Forget', command=lambda:self.forget(), row=SIZE+1, column=2*SIZE-1)

        self.update()

        # the score labels
        score = Label(self.app, text=' SCORE:', font=Font(family="Courier", weight='bold', size=32))
        score.grid(row=0, column=0, columnspan=SIZE)
        self.score = Label(self.app, text='0', font=Font(family="Courier", weight='bold', size=32))
        self.score.grid(row=1, column=1)

        # choose if you are X or O. X always goes first
        self.player_choice = StringVar()    # how to keep track of the option
        which_player = OptionMenu(self.app, self.player_choice, *(STRINGS[X], STRINGS[O])) # options are X and O
        which_player.grid(row=SIZE+2, column=SIZE+2)
        which_player.config(font=Font(family='Courier'))
        self.player_choice.set('X')
        self.player_choice.trace('w', self.choose_player)

        # choose between playing against a Perfect player or Learning player
        self.comp_type = StringVar()    # how to keep track of the option
        comp_type = OptionMenu(self.app, self.comp_type, *('Learning', 'Perfect'))
        comp_type.grid(row=SIZE+2, column=SIZE)
        comp_type.config(width=11, font=Font(family='Courier'))
        self.comp_type.set('Learning')
        self.comp_type.trace('w', self.choose_comp_type)
开发者ID:dnav6987,项目名称:TicTacToe,代码行数:48,代码来源:GUI.py

示例4: CreateView

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class CreateView(Frame):
    """A class describing the list creation page of the UI"""

    def __init__(self, parent, height, width, border_style, border_width,
                 background_colour):

        Frame.__init__(self, parent, height=height, width=width)

        #Connect to the word/list database 
        self.db = SpellingDatabase()
        self.parent = parent
		
        #Create a frame containing a menu for choosing word category
        categorymenu_frame = Frame(self, width=340, height=30, relief=SUNKEN, bd=1)
        categorymenu_frame.pack_propagate(0)
        categorymenu_label = Label(categorymenu_frame, text="Category:")
        wordlist_title = Label(categorymenu_frame, text="Select Words")
        #Menu options: one for each category of word
        optionList = ("Child", "ESOL", "Spelling Bee", "Custom")
        self.category_v = StringVar()
        self.category_v.set(optionList[0])
        #Command causes word browser to be populated with words from chosen category
        self.category_menu = OptionMenu(categorymenu_frame, self.category_v, *optionList, command=self.update_category)
        self.category_menu.config(width=10)
        self.category_menu.pack(side=RIGHT)
        categorymenu_label.pack(side=RIGHT)
        wordlist_title.pack(side=LEFT)
        
        #Create frame for the title of the user list panel
        userlist_title_frame = Frame(self, width=340, height=30)
        userlist_title_frame.pack_propagate(0)
        userlist_title = Label(userlist_title_frame, text="Your New List")
        userlist_title_frame.grid(column=2, row=0)
        userlist_title.pack(side=LEFT)

        #Create frame for middle bar containing transfer buttons
	middlebar_frame = Frame(self, width = 70, height=400)
        middlebar_frame.grid_propagate(0)
        #Buttons transfer words from one list to the other
        transfer_right_button = Button(middlebar_frame, text="->", command=self.transfer_right)
        transfer_left_button = Button(middlebar_frame, text="<-", command=self.transfer_left)
        #Press this button to generate a random list from the current category
        random_list_button = Button(middlebar_frame, text="Create", command=self.random_list)
        random_list_label = Label(middlebar_frame, text="Random\nList")
        self.random_list_entry = Entry(middlebar_frame, width=3, justify=RIGHT)
        self.random_list_entry.insert(0, 15) 
	transfer_left_button.grid(column=0, row=1, padx=15, pady=50)
        transfer_right_button.grid(column=0, row=0, padx=15, pady=50)
        random_list_label.grid(column=0, row=2, pady=3)
        self.random_list_entry.grid(column=0, row=3, pady=3)
        random_list_button.grid(column=0, row=4, pady=3)
        middlebar_frame.grid(column=1, row=1)
        #random_list_button.grid(column=0, row=2)

        #Create frame for "Add New Word" menu
        addword_frame = Frame(self, width=340, height=150, bd=2, relief=SUNKEN)
        addword_frame.grid_propagate(0)
        addword_label = Label(addword_frame, text = "Add a new word:")
        word_label = Label(addword_frame, text="Word:")
        def_label = Label(addword_frame, text="Definition:")
        use_label = Label(addword_frame, text="Example of Use:")
        difficulty_label = Label(addword_frame, text="Difficulty:")
        #Entry boxes and an option menu allowing the user to enter attributes of the new word
        self.addword_entry = Entry(addword_frame, width = 28)
        self.adddefinition_entry = Entry(addword_frame, width=28)
        self.adduse_entry = Entry(addword_frame, width=28)
        self.difficulty_v = StringVar()
        self.difficulty_v.set("1")
        difficulty_list = range(1,9)
        self.difficulty_menu = OptionMenu(addword_frame, self.difficulty_v, *difficulty_list)
        #Pressing this button adds the new word to the database
        addword_button = Button(addword_frame, text = "Add", command = self.add_word)
        addword_label.grid(row=0, column=0, sticky=W)
        addword_button.grid(row=0, column=1, pady=2, sticky=E)
        word_label.grid(row=1, column=0, sticky=W)
        def_label.grid(row=2, column=0, sticky=W)
        use_label.grid(row=3, column=0, sticky=W)
        difficulty_label.grid(row=4, column=0, sticky=W)
        self.addword_entry.grid(row=1, column=1, pady=2, sticky=E)
        self.adddefinition_entry.grid(row=2, column=1, pady=2, sticky=E)
        self.adduse_entry.grid(row=3, column=1, pady=2, sticky=E)
        self.difficulty_menu.grid(row=4, column=1, pady=2, sticky=E)
        addword_frame.grid(column=0, row=2)
        
        #Frame for menu allowing users to save their new lists
        savelist_frame = Frame(self, width=340, height=30, bd=2, relief=SUNKEN)
        savelist_frame.pack_propagate(0)
        savelist_label = Label(savelist_frame, text="List Name:")
        #User enters the name of the new list here
        self.savelist_entry = Entry(savelist_frame, width=25)
        #Pressing this button adds the new list to the database
        savelist_button = Button(savelist_frame, text="Save", command = self.save_list)
        savelist_label.pack(side=LEFT)
        savelist_button.pack(side=RIGHT)
        self.savelist_entry.pack(side=RIGHT, padx=5)
        savelist_frame.grid(column=2, row=2, sticky=N, pady=5)

        #Create list panel for browsing the words stored in database
        self.wordbrowse_frame = ListPane(self, height=25) 
        categorymenu_frame.grid(column=0, row=0)
#.........这里部分代码省略.........
开发者ID:Soulreaverm,项目名称:SE206Project,代码行数:103,代码来源:CreateView.py

示例5: init_troop

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]

#.........这里部分代码省略.........
                weapons = [random.choice(nation.ranged_weapon_list), random.choice(nation.sidearm_list)]
            else:
                weapons = [random.choice(nation.weapon_list), random.choice(nation.sidearm_list)]

            armor = random.choice(nation.armor_list)

            mount = nation.mount_none

            if random.randint(0, 100) < (self.elite * 2) + 5:
                mount = random.choice(nation.mount_list)

        self.weapons = weapons
        self.armor = armor
        self.mount = mount

        self.arms_history.append((self.weapons, self.armor, self.mount))
        self.stats_history.append(utility.base_soldier_stats())

        return self

    def rearm(self, name, new_weapons, new_armor, new_mount):
        if self.name == name:
            self.weapons = new_weapons
            self.armor = new_armor
            self.mount = new_mount
        else:
            for upgrade in self.upgrades:
                upgrade.rearm(name, new_weapons, new_armor, new_mount)

    def show_information_gui(self):
        self.gui_window = Tk()
        self.gui_window.title(self.name)
        self.gui_window.geometry("400x625+0+0")
        self.gui_window.config(background='white')

        self.ranged_label = gui.Label(self.gui_window, text='Is ranged: {}'.format(self.ranged))
        self.ranged_label.grid(row=0, sticky=W)

        self.mount_label = gui.Label(self.gui_window, text='Mount: {}'.format(self.mount.name))
        self.mount_label.grid(row=1, sticky=W)

        self.strength_label = gui.Label(self.gui_window, text='Strength: {}'.format(self.strength))
        self.strength_label.grid(row=2, sticky=W)

        self.health_label = gui.Label(self.gui_window, text='Health: {}'.format(self.health))
        self.health_label.grid(row=3, sticky=W)

        self.discipline_label = gui.Label(self.gui_window, text='Discipline: {}'.format(self.discipline))
        self.discipline_label.grid(row=4, sticky=W)


        self.discipline_label = gui.Label(self.gui_window, text='Cost: {}'.format(self.get_soldier_cost()))
        self.discipline_label.grid(row=5, sticky=W)

        self.arrangement = gui.Label(self.gui_window, text='Arrangement: {}x{}'.format(self.rank_size, self.ranks))
        self.arrangement.grid(row=6, sticky=W)

        self.arrangement_canvas = Canvas(self.gui_window, width = (self.rank_size + 1) * (TROOP_RADIUS + 1), height= (self.ranks + 1) * (TROOP_RADIUS + 1))
        self.arrangement_canvas.config(background='white')
        self.arrangement_canvas.grid(row=7, sticky=W)

        for x in xrange(1, self.rank_size + 1):
            for y in xrange(1, self.ranks + 1):
                base_x, base_y = x * (TROOP_RADIUS + 1), y * (TROOP_RADIUS + 1)
                self.arrangement_canvas.create_oval(base_x, base_y, base_x + TROOP_RADIUS, base_y + TROOP_RADIUS)
开发者ID:Kytuzian,项目名称:History-Generator,代码行数:69,代码来源:troop.py

示例6: Example

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):

        self.parent.title("IAF CALC 0.01")
        self.pack(fill=BOTH, expand=1)

        self.configure(background="white")

        frameTOP = Frame(self)
        frameTOP.config(bg="white")
        frameTOP.pack(side=TOP)

        frameFILES = Frame(frameTOP)
        frameFILES.pack(side=LEFT, padx=10)

        # --- BUTTON FOR FILE 1 --- #
        frameF1 = LabelFrame(frameFILES, text="Eyes open file:", relief=FLAT, borderwidth=1, background="white")
        frameF1.pack(fill=X, expand=1)
        self.nameF1 = Entry(frameF1, width=50)
        self.nameF1.config(bg="lightgray")
        self.nameF1.pack(side=LEFT)
        self.nameF1.delete(0, END)
        self.nameF1.insert(0, "")
        self.buttonLoadFile1 = Button(frameF1, text="...", command=self.askOpenFile1)
        self.buttonLoadFile1.pack(side=LEFT, padx=5, pady=5)
        # ----------------------- #

        # --- BUTTON FOR FILE 2 --- #
        frameF2 = LabelFrame(frameFILES, text="Eyes closed file:", relief=FLAT, borderwidth=1, background="white")
        frameF2.pack(fill=X, expand=1)
        self.nameF2 = Entry(frameF2, width=50)
        self.nameF2.config(bg="lightgray")
        self.nameF2.pack(side=LEFT)
        self.nameF2.delete(0, END)
        self.nameF2.insert(0, "")
        self.buttonLoadFile2 = Button(frameF2, text="...", command=self.askOpenFile2)
        self.buttonLoadFile2.pack(side=LEFT, padx=5, pady=5)
        # ----------------------- #

        # --- BUTTON FOR FILE OUTPUT --- #
        frameO = LabelFrame(frameFILES, text="Output directory:", relief=FLAT, borderwidth=1, background="white")
        frameO.pack(fill=X, expand=1)
        self.nameO = Entry(frameO, width=50)
        self.nameO.config(bg="lightgray")
        self.nameO.pack(side=LEFT)
        self.nameO.delete(0, END)
        self.nameO.insert(0, "")
        self.buttonSelectOutput = Button(frameO, text="...", command=self.askOutputDirectory)
        self.buttonSelectOutput.pack(side=LEFT, padx=5, pady=5)
        # -------------------------------#
        # self.pack()
        # self.pack(fill=Y, expand=1)

        # ---------- PSD PARAMETER SELECTION ---------- #
        framePARAM = Frame(frameTOP)
        framePARAM.config(bg="white")
        framePARAM.pack(side=LEFT, fill=X)

        frame = LabelFrame(framePARAM, text="PSD Parameters", relief=RIDGE, borderwidth=1, background="white")
        frame.pack(fill=BOTH, expand=1, side=TOP)

        wFs = Label(frame, text="Fs:", bg="white")
        wFs.pack(side=LEFT)
        self.inputFs = Entry(frame, width=5)
        self.inputFs.pack(side=LEFT, padx=5)
        self.inputFs.delete(0, END)
        self.inputFs.insert(0, "500")

        wWS = Label(frame, text="Window size:", bg="white")
        wWS.pack(side=LEFT)
        self.inputWinSize = Entry(frame, width=5)
        self.inputWinSize.pack(side=LEFT, padx=5)
        self.inputWinSize.delete(0, END)
        self.inputWinSize.insert(0, "1024")

        wOL = Label(frame, text="Overlap:", bg="white")
        wOL.pack(side=LEFT)
        self.inputOverlap = Entry(frame, width=5)
        self.inputOverlap.pack(side=LEFT, padx=5)
        self.inputOverlap.delete(0, END)
        self.inputOverlap.insert(0, "512")

        wWT = Label(frame, text="Window function:", bg="white")
        wWT.pack(side=LEFT)

        variable = StringVar(frame)
        variable.set("Hamming")  # default value
        self.inputWinType = OptionMenu(frame, variable, "Hamming", "Bartlett", "Blackman", "Hanning", "None")
        self.inputWinType.config(bg="white", width=10)
        self.inputWinType.pack(side=LEFT)

        buttonRun = Button(frame, text="GO!", command=self.goTime)
        buttonRun.pack(side=RIGHT)

        # Channel selector
#.........这里部分代码省略.........
开发者ID:silmis,项目名称:CENTplatform,代码行数:103,代码来源:iafcalc.py

示例7: observation

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class observation():
    # Set up all the data fields and frames
    def __init__(self, contentframe, console, params):
        self.frame = contentframe
        self.iniparams = {
            "totbest": "-",
            "x": [],
            "y": [],
            "mu": [],
            "var": [],
            "time": []
        }
        self.lockgraph = False
        self.console = console
        self.params = params
        self.experimentdata()
        self.startgraph()

    # Destroy the Frame
    def destroy(self):
        self.frame.destroy()

    # Create the widgets
    def experimentdata(self):
        f = Frame(self.frame)
        self.experimentframe = f
        f.config(padx=20, pady=20, bg=Styles.colours["grey"])
        modeldetails = header(f, "Model:")
        fm = Frame(f)
        fm.config(padx=20, pady=20, bg=Styles.colours["grey"])
        infoh(fm, "Command:", self.params["command"].get(), 0, 0)
        infoh(fm, "Model Input:", self.params["modelinput"].get(), 1, 0)
        infoh(fm, "Model Output:", self.params["modeloutput"].get(), 2, 0)

        self.numexperitments = header(f, "Current Experiment: 0/0")
        _, self.iterinfo = infov(f, "Iteration:", "-", 5, 0)
        _, self.kernelinfo = infov(f, "Kernel:", "-", 5, 1)
        _, self.policyinfo = infov(f, "Policy:", "-", 5, 2)

        resultsframe = Frame(f)
        resultsframe.config(bg=Styles.colours["grey"])
        headersmall(resultsframe, "Best Result:       ").grid(row=0, column=0, sticky=W + E + N + S)

        Label(resultsframe, text="Current:", font=Styles.fonts["entry"], bg=Styles.colours["grey"], width=9).grid(row=0,
                                                                                                                  column=1,
                                                                                                                  sticky=E)
        self.curbestlabel = Label(resultsframe, bg=Styles.colours["grey"], text="-", width=20, font=Styles.fonts["h2"])
        self.curbestlabel.grid(row=0, column=2, sticky=W)

        Label(resultsframe, text="Overall:", font=Styles.fonts["entry"], bg=Styles.colours["grey"], width=9).grid(row=1,
                                                                                                                  column=1,
                                                                                                                  sticky=E)
        self.totbestlabel = Label(resultsframe, text=self.iniparams["totbest"], bg=Styles.colours["grey"], width=20,
                                  font=Styles.fonts["h2"])
        self.totbestlabel.grid(row=1, column=2, sticky=W)

        curresultsframe = Frame(f)
        curresultsframe.config(bg=Styles.colours["grey"])

        headersmall(curresultsframe, "Latest Iteration: ").grid(row=0, column=0, sticky=W + E + N + S)

        Label(curresultsframe, text="y:", font=Styles.fonts["entry"], bg=Styles.colours["grey"], width=9).grid(row=0,
                                                                                                               column=1,
                                                                                                               sticky=E)
        self.cury = Label(curresultsframe, text="-", width=20, font=Styles.fonts["h2"], bg=Styles.colours["grey"])
        self.cury.grid(row=0, column=2, sticky=W)

        Label(curresultsframe, text="mu:", font=Styles.fonts["entry"], bg=Styles.colours["grey"], width=9).grid(row=1,
                                                                                                                column=1,
                                                                                                                sticky=E)
        self.curmu = Label(curresultsframe, text=self.iniparams["totbest"], bg=Styles.colours["grey"], width=20,
                           font=Styles.fonts["h2"])
        self.curmu.grid(row=1, column=2, sticky=W)

        Label(curresultsframe, text="var:", font=Styles.fonts["entry"], bg=Styles.colours["grey"], width=9).grid(row=2,
                                                                                                                 column=1,
                                                                                                                 sticky=E)
        self.curvar = Label(curresultsframe, text=self.iniparams["totbest"], bg=Styles.colours["grey"], width=20,
                            font=Styles.fonts["h2"])
        self.curvar.grid(row=2, column=2, sticky=W)

        modeldetails.grid(row=0, column=0, columnspan=3, sticky=W + E + N + S)

        fm.grid(row=1, column=0, columnspan=3, sticky=W + E + N + S, padx=20)

        self.numexperitments.grid(row=4, column=0, columnspan=3, sticky=W + E + N + S)

        resultsframe.grid(row=7, column=0, columnspan=3, sticky=W + E + N + S)
        curresultsframe.grid(row=8, column=0, columnspan=3, sticky=W + E + N + S)
        f.grid(row=0, column=1, sticky=W + E + N + S)

    # Create the graph base
    def startgraph(self):
        #Older versions of matplot do not support style command
        try:
            pl.style.use('ggplot')
        except:
            pass
        root = Frame(self.frame)
        self.graphframem = root
#.........这里部分代码省略.........
开发者ID:jakedm,项目名称:projectb,代码行数:103,代码来源:observation.py

示例8: Cockpit

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]

#.........这里部分代码省略.........

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

        self._shiftCanvas.grid(row=0,column=1, padx=2, pady=2)
        self._shiftCanvas.create_oval(1, 1, 400, 400, outline="#ff0000")
        self._shiftCanvas.create_line(200, 2, 200, 400, fill="#ff0000")
        self._shiftCanvas.create_line(2, 200, 400, 200, fill="#ff0000")
        self._shiftMarker = self._shiftCanvas.create_oval(196, 196, 204, 204, outline="#0000ff", fill="#0000ff")
        
        self._yaw = DoubleVar()
        self._yawScale = Scale(controlFrame, orient=HORIZONTAL, from_=-100.0, to=100.0, \
                            tickinterval=0, variable=self._yaw, \
                            length=200, showvalue=1, \
                            command=self._onYawScaleChanged)
        self._yawScale.bind("<Double-Button-1>", self._onYawScaleDoubleButton1, "+")
        self._yawScale.grid(row=1, column=1)
        
        self._controlKeyActive = False
        

        #PID calibration

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

        self._pidSelected = StringVar()
        self._pidSelected.set("--")
        self._pidListBox = OptionMenu(pidCalibrationFrame, self._pidSelected, "--", \
                                      Cockpit.KEY_ANG_SPEED, Cockpit.KEY_ANGLES, Cockpit.KEY_ACCEL, \
                                       command=self._onPidListBoxChanged)
        self._pidListBox.pack(side=LEFT, padx=2)
        self._pidListBox.config(width=10)
        
        self._axisSelected = StringVar()
        self._axisSelected.set("--")
        self._axisListBox = OptionMenu(pidCalibrationFrame, self._axisSelected, "--", "X", "Y", "Z", \
                                       command=self._onAxisListBoxChanged)
        self._axisListBox.pack(side=LEFT, padx=2)
        self._axisListBox.config(state=DISABLED)

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

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

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

        self._pidIString = StringVar()
        self._pidIString.set("0.00")
        self._pidISpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidIString, command=self._onPidSpinboxChanged)
        self._pidISpinbox.pack(side=LEFT, padx=2)
        
        Label(pidCalibrationFrame, text="D").pack(side=LEFT, padx=(14, 2))
        
        self._pidDString = StringVar()
        self._pidDString.set("0.00")
        self._pidDSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=10000.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidDString, command=self._onPidSpinboxChanged)
        self._pidDSpinbox.pack(side=LEFT, padx=2)
        
开发者ID:dpm76,项目名称:eaglebone,代码行数:69,代码来源:cockpit.py

示例9: Cockpit

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]

#.........这里部分代码省略.........

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

        self._shiftCanvas.grid(row=0,column=1, padx=2, pady=2)
        self._shiftCanvas.create_oval(2, 2, 400, 400, outline="#ff0000")
        self._shiftCanvas.create_line(201, 2, 201, 400, fill="#ff0000")
        self._shiftCanvas.create_line(2, 201, 400, 201, fill="#ff0000")
        self._shiftMarker = self._shiftCanvas.create_oval(197, 197, 205, 205, outline="#0000ff", fill="#0000ff")
        
        self._yaw = DoubleVar()
        self._yawScale = Scale(controlFrame, orient=HORIZONTAL, from_=-100.0, to=100.0, \
                            tickinterval=0, variable=self._yaw, \
                            length=200, showvalue=1, \
                            command=self._onYawScaleChanged)
        self._yawScale.bind("<Double-Button-1>", self._onYawScaleDoubleButton1, "+")
        self._yawScale.grid(row=1, column=1)
        
        self._controlKeyActive = False
        

        #PID calibration

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

        self._pidSelected = StringVar()
        self._pidSelected.set("--")
        self._pidListBox = OptionMenu(pidCalibrationFrame, self._pidSelected, "--", \
                                      Cockpit.KEY_ANG_SPEED, Cockpit.KEY_ANGLES, Cockpit.KEY_ACCEL, \
                                       command=self._onPidListBoxChanged)
        self._pidListBox.pack(side=LEFT, padx=2)
        self._pidListBox.config(width=10)
        
        self._axisSelected = StringVar()
        self._axisSelected.set("--")
        self._axisListBox = OptionMenu(pidCalibrationFrame, self._axisSelected, "--", "X", "Y", "Z", \
                                       command=self._onAxisListBoxChanged)
        self._axisListBox.pack(side=LEFT, padx=2)
        self._axisListBox.config(state=DISABLED)

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

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

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

        self._pidIString = StringVar()
        self._pidIString.set("0.00")
        self._pidISpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=100.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidIString, command=self._onPidSpinboxChanged)
        self._pidISpinbox.pack(side=LEFT, padx=2)
        
        Label(pidCalibrationFrame, text="D").pack(side=LEFT, padx=(14, 2))
        
        self._pidDString = StringVar()
        self._pidDString.set("0.00")
        self._pidDSpinbox = Spinbox(pidCalibrationFrame, width=5, from_=0.0, to=100.0, increment=0.01, state=DISABLED, \
                                         textvariable=self._pidDString, command=self._onPidSpinboxChanged)
        self._pidDSpinbox.pack(side=LEFT, padx=2)
        
开发者ID:hisie,项目名称:eaglebone,代码行数:69,代码来源:cockpit.py

示例10: SampleApp

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import config [as 别名]
class SampleApp(Tk):
    def enable_frame(self, frame):
        for child in frame.winfo_children():
            child.configure(state='normal')
            child.update()

    def disable_frame(self, frame):
        for child in frame.winfo_children():
            child.configure(state='disable')
            child.update()

    def onselect(self, evt):

        w = evt.widget
        index = int(w.curselection()[0])
        value = w.get(index)
        template_vals = next(v for i, v in enumerate(templates.items()) if i == index)
        print('You selected item %d: "%s"' % (index, value))

        for key, value in self.entries.items():
            self.disable_frame(value["row"])

        for v in template_vals[1]:
            self.enable_frame(self.entries[int(v)]["row"])
        self.set_index(self.list_view.selection_get())

    def build_fill_form(self):

        row_1 = Frame(self.fillForm, width=121)
        row_1.pack(side=TOP)

        label_1 = Label(row_1, text="1. Податоци за основач (мкд)", width=row_width_entry)
        label_1.pack(side=LEFT)

        entry_1 = Entry(row_1, width=row_width_entry)
        entry_1.pack(side=LEFT)

        self.entries[1] = {"row": row_1, "entry": entry_1}

        row_2 = Frame(self.fillForm, width=row_width)
        row_2.pack(side=TOP)

        label_2 = Label(row_2, text="2. Data for Founder (eng)", width=row_width_text)
        label_2.pack(side=LEFT)

        entry_2 = Entry(row_2, width=row_width_entry)
        entry_2.pack(side=LEFT)

        self.entries[2] = {"row": row_2, "entry": entry_2}

        row_3 = Frame(self.fillForm, width=row_width_entry)
        row_3.pack(side=TOP)

        label_3 = Label(row_3, text="3. Назив на Друштвото (мкд)", width=row_width_text)
        label_3.pack(side=LEFT)

        entry_3 = Entry(row_3, width=row_width_entry)
        entry_3.pack(side=LEFT)

        self.entries[3] = {"row": row_3, "entry": entry_3}

        row_4 = Frame(self.fillForm, width=row_width)
        row_4.pack(side=TOP)

        label_4 = Label(row_4, text="4. Name of the Company (eng)", width=row_width_text)
        label_4.pack(side=LEFT)

        entry_4 = Entry(row_4, width=row_width_entry)
        entry_4.pack(side=LEFT)

        self.entries[4] = {"row": row_4, "entry": entry_4}

        row_5 = Frame(self.fillForm, width=row_width)
        row_5.pack(side=TOP)

        label_5 = Label(row_5, text="5. Датум на документ (мкд)", width=row_width_text)
        label_5.pack(side=LEFT)

        entry_5 = Entry(row_5, width=row_width_entry)
        entry_5.pack(side=LEFT)

        self.entries[5] = {"row": row_5, "entry": entry_5}

        row_6 = Frame(self.fillForm, width=row_width)
        row_6.pack(side=TOP)

        label_6 = Label(row_6, text="6. Date of document (eng)", width=row_width_text)
        label_6.pack(side=LEFT)

        entry_6 = Entry(row_6, width=row_width_entry)
        entry_6.pack(side=LEFT)

        self.entries[6] = {"row": row_6, "entry": entry_6}

        row_7 = Frame(self.fillForm, width=row_width)
        row_7.pack(side=TOP)

        label_7 = Label(row_7, text="7. Скратен назив на Друштвото (мкд)", width=row_width_text)
        label_7.pack(side=LEFT)

#.........这里部分代码省略.........
开发者ID:viktorijat,项目名称:etw,代码行数:103,代码来源:interface.py


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