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


Python OptionMenu.grid方法代码示例

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


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

示例1: WheelEntry

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
class WheelEntry(LabelFrame):
    DIA_UNITS = [dist.mm, dist.cm, dist.inch]

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

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

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

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

示例2: HiddenNeuronNumber

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [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

示例3: VelocitySelect

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
class VelocitySelect(Frame):
    VELOCITIES = [speeds.kmh, speeds.mih, speeds.ms]

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

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

示例4: __draw_new_draft_window

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
    def __draw_new_draft_window(self, parent):

        self.parent.title("New Draft")

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

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

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

        def begin_button(event):
            begin_draft()

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

示例5: body

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
 def body(self, master):
     Label(master, text='Current Type: ').grid(row=0,column=0)
     Label(master, text=self.current_type).grid(row=0,column=1)
     Label(master, text='Change: ').grid(row=1,column=0)
     self.option_val = StringVar(master)    
     self.option_val.set(self.current_type)
     om = OptionMenu (master, self.option_val, 'master','slave','master+slave')
     om.grid(row=1,column=1,sticky=W)
     return om # initial focus on menu
开发者ID:,项目名称:,代码行数:11,代码来源:

示例6: __init__

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        
        number_of_classes_label = Label(self, text = 'Number of classes: ')
        number_of_classes_label.grid(row = 0, column = 0)
        
        number_options = range(DEFAULT_NUMBER_OF_CLASS, MAX_NUMBER_OF_CLASSES+1)
        self.selected_number = IntVar(self, value = DEFAULT_NUMBER_OF_CLASS)
        option_menu = OptionMenu(self, self.selected_number, *number_options, 
                                 command = self._on_number_selection)
        option_menu.grid(row = 0, column = 1)

        self.observers = []
开发者ID:fmihaich,项目名称:annic,代码行数:16,代码来源:samples_collection.py

示例7: add_unit_frame

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
    def add_unit_frame(self, parent=None, id=1):
        """!
        Construct the frame which is contains the widgets relating to a single
        data logging unit.
        @param self The pointer for the object
        @param id An identifier for use with the frame.  This identifier can be
        an integer or string and is displayed within the label of the frame
        @param parent The parent frame/object to be used for the new frame.
        @return The data logging unit frame
        """
        #Dictionary to encapsulate information
        data_dict = {}
        data_dict['frame'] = StdLabelFrame(parent, text='Device %s' % id)
        #Create dynamic components
        data_dict['unit'] = StringVar()
        data_dict['unit'].set(UNIT_TYPES[0])
        data_dict['status'] = StringVar()
        data_dict['status'].set(CONNECTION_TYPES[0])
        data_dict['reading'] = StringVar()
        data_dict['reading'].set('%0.2f' % 0)
        #Display components
        #Unit selection
        drop_down = OptionMenu(data_dict['frame'],
                               data_dict['unit'],
                               *UNIT_TYPES)
        drop_down.configure(width=MAX_WIDGET_WIDTH,
                            bg='white',
                            borderwidth=0,
                            highlightbackground='white',
                            highlightcolor='white')
        drop_down.grid(row=0, columnspan=2)

        #Connection Status
        StdLabel(data_dict['frame'],
                 text='Connection Status: ').\
            grid(row=1, column=0)
        data_dict['status_widget'] = StdLabel(data_dict['frame'],
                                              textvariable=data_dict['status'],
                                              fg='red')
        data_dict['status_widget'].grid(row=1, column=1)

        #Measurement
        StdLabel(data_dict['frame'],
                 textvariable=data_dict['reading'],
                 font=tkFont.Font(family='Arial',
                                  size=36),
                 bg='gray').\
            grid(row=2, columnspan=2, pady=20)
        return data_dict
开发者ID:benjohnston24,项目名称:pyLogger,代码行数:51,代码来源:pyLoggerGui.py

示例8: FileFrame

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [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

示例9: __init__

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
    def __init__(self, parent):
        Frame.__init__(self, parent)
                
        number_of_layers_label = Label(self, text = 'Number of layers: ')
        number_of_layers_label.grid(row=0, column=0)
        
        number_options = range(DEFAULT_NUMBER_OF_HIDDEN_LAYERS, 
                               MAX_NUMBER_OF_HIDDEN_LAYERS + 1)
        
        selected_number = IntVar(self, value = DEFAULT_NUMBER_OF_HIDDEN_LAYERS)
        option_menu = OptionMenu(self, selected_number, *number_options, 
                            command = self._on_hidden_layers_number_selection)
        option_menu.grid(row=0, column=1)

        self.observers = []
开发者ID:fmihaich,项目名称:annic,代码行数:17,代码来源:perceptron_hidden_layers.py

示例10: __init__

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [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

示例11: SelectPage

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
class SelectPage(BasePage):
    def __init__(self, parent, controller):
        BasePage.__init__(self, parent, controller)

    def setupView(self, title="Test Select Page", item_list=[], default=0):
        self.desc = Label(self, text=title, font=TITLE_FONT)
        self.desc.grid(row=0, column=0, columnspan=2)
        self.optVar = StringVar()
        self.selection = OptionMenu(self, self.optVar, *item_list)
        self.selection.grid(row=1, column=0, columnspan=2, sticky="WE")
        self.optVar.set(item_list[default])
        self.ok = Button(self,
                         text='Next',
                         command=lambda: self.controller.transition(self))
        self.ok.grid(row=2, column=1, sticky="W")
        self.cancel = Button(self,
                             text='Cancel',
                             command=lambda: self.controller.quit())
        self.cancel.grid(row=2, column=0, sticky="E")
开发者ID:zapion,项目名称:working-scripts,代码行数:21,代码来源:testframe.py

示例12: MenuFrame

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
class MenuFrame(Frame):
    """
    Drop down menu in Mapping windows

    __str__ must be an unique identifier
    """
    def __init__(self,parent,items,callback=None,current=None,*args,**kwargs):
        Frame.__init__(self,parent,*args,**kwargs)
        self.var = StringVar(self)
        self.items = items
        if current in self.items:
            self.var.set(current)
        self.var.trace("w", lambda x,y,z,v=self.var: self.onChoice())
        self.delete = None
        self.choice = None
        self.callback = callback
        self.listeners = []
        self.menu = OptionMenu(self,self.var,*([i.name for i in self.items]+["None"]))
        self.menu.configure(width=10)
        
    def onChoice(self):
        if self.callback:
            candidates = [i for i in self.items if i.name == self.var.get()]
            item = None
            if candidates:
                item = candidates[0]
                self.choice = item
            else:
                self.delete = self.choice
            self.callback(item)
            
    def grid(self,*args,**kwargs):
        Frame.grid(self,*args,**kwargs)
        self.menu.grid()
    
    def get(self):
        return self.choice
    
    def set(self,item):
        if item in self.items:
            self.var.set(item)
开发者ID:crosslinks,项目名称:XlinkAnalyzer,代码行数:43,代码来源:item.py

示例13: Main

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
class Main():

	def __init__(self, master):

		#La intro se puede apagar al final, cumple solo una funcion vistosa

		#Iniciacion propia de la ventan y sus configuraciones
		self.master=master
		self.master.wm_title(R.AppTitle)
		self.widht=(self.master.winfo_screenwidth() - self.master.winfo_reqwidth()) / 2
		self.height=(self.master.winfo_screenheight() - self.master.winfo_reqheight()) / 2
		self.master.geometry("+{0:.0f}+{1:.0f}".format(self.widht, self.height))
		self.master.deiconify()
		self.master.resizable(False,False)
		self.icon=(R.IconPath)
		self.master.iconbitmap(self.icon)
		self.master.configure(background=R.Bgcolor)

		#Definicion de variables variables que estaran en uso.
		self.btnFlecha=Image.open(R.BtnFlechaImgPath)
		self.btnFlechaimg=ImageTk.PhotoImage(self.btnFlecha)
		self.selectMed = StringVar(self.master)
		self.selectMed.set(R.SelectMed)

		#Las variables que usaran para saber que hacer o que reemplazar
		self.fromLabel = StringVar()
		self.fromLabel.set(R.Select)
		self.toLabel=StringVar()
		self.toLabel.set(R.Select)

		#Los valores de las entradas
		self.fromNumber=StringVar()
		self.toNumber=StringVar()

		#La creacion de las partes del programita.
		self.menuChoices()
		self.convertChoice()
		self.convertButton()

	def menuChoices(self):

		#Menu de seleccion principal sobre los tipos que conversion que hara el programa
		self.MenuChoices = OptionMenu(self.master, self.selectMed, R.LongMain,R.AlmacMain, command=self.choice)
		self.MenuChoices.configure(bg="white",fg="black",activebackground="#eceefb",highlightbackground=R.Bgcolor,
									indicatoron=0,image=self.btnFlechaimg,compound='right')
		self.MenuChoices.grid(row=0,column=0)

	def convertChoice(self):

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

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

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

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

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

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

		self.entryTo=Entry(self.labelFrameTo,justify='center',textvariable=self.toNumber,state="readonly")
		self.entryTo.configure(bg="red", readonlybackground=R.Bgcolor)
		self.entryTo.grid(row=2,column=0,padx=3,pady=5)

	def convertButton(self):
		#El boton Convertir que activa las funcionalidades de los campos
		self.butonimgpath = Image.open(R.BtnConvertirImgPath)
		self.butonTkImage = ImageTk.PhotoImage(self.butonimgpath)
		self.button = Button(self.master,text='Convertir',command=self.choiceFromTo)
		self.button.configure(image=self.butonTkImage, bd=False, highlightthickness=0, activebackground="black")
		self.button.grid(row=3,column=1,sticky=E)

	def choice(self, choices):
		#Al tocar el boton [<- Selecione] se cambia la opcion de medida y se genera opciones acorde
		# error.set("")
		#Opciones acorde en el caso de elegir "Longitudes"
		if choices==R.LongMain:
				self.fromLabel.set(R.LongStart)
				self.toLabel.set(R.LongStart)
				self.clean()
				# medidas= ("kms", "milla","metro","legua","yarda","pie")
				for m in R.LongList:
						self.menuFrom['menu'].add_command(label=m,command=lambda v=self.fromLabel,l=m:v.set(l))
				for m in R.LongList:
						self.menuTo['menu'].add_command(label=m,command=lambda v=self.toLabel,l=m:v.set(l))

		#Genera las opciones si se elige "Almacenamientos"
		elif choices==R.AlmacMain:
				self.fromLabel.set(R.AlmacStart)
#.........这里部分代码省略.........
开发者ID:riojano0,项目名称:Python_Scripts,代码行数:103,代码来源:main.py

示例14: show

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [as 别名]
    def show(self):
        self.__root.title(CONST.APP_NAME)
        mainFrame = Frame(self.__root)
        # Make Dialog stretchable (to EAST and WEST)
        top = mainFrame.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        mainFrame.rowconfigure(0, weight=1)
        mainFrame.columnconfigure(0, weight=1)
        mainFrame.grid(sticky='ew')

        # Three Sections: Input-Settings, Output-Settings and Buttons
        inputFrame = LabelFrame(mainFrame, text='Input Settings')
        inputFrame.columnconfigure(1, weight=1)
        inputFrame.grid(column=0, row=0, padx=5, pady=5, sticky='ew')
        outputFrame = LabelFrame(mainFrame, text='Output Settings')
        outputFrame.columnconfigure(1, weight=1)
        outputFrame.grid(column=0, row=1, padx=5, pady=5, sticky='ew')
        buttonFrame = Frame(mainFrame)
        buttonFrame.grid(column=0, row=2, padx=5, pady=5, sticky='e')

        # Input-Settings
        scribusSourceFileLabel = Label(inputFrame, text='Scribus File:', width=15, anchor='w')
        scribusSourceFileLabel.grid(column=0, row=0, padx=5, pady=5, sticky='w')
        scribusSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getScribusSourceFileEntryVariable())
        scribusSourceFileEntry.grid(column=1, row=0, padx=5, pady=5, sticky='ew')
        scribusSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.scribusSourceFileEntryVariableHandler)
        scribusSourceFileButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')

        dataSourceFileLabel = Label(inputFrame, text='Data File:', width=15, anchor='w')
        dataSourceFileLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
        dataSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getDataSourceFileEntryVariable())
        dataSourceFileEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')
        dataSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.dataSourceFileEntryVariableHandler)
        dataSourceFileButton.grid(column=2, row=1, padx=5, pady=5, sticky='e')

        # Output-Settings
        outputDirectoryLabel = Label(outputFrame, text='Output Directory:', width=15, anchor='w')
        outputDirectoryLabel.grid(column=0, row=0, padx=5, pady=5, sticky='w')
        outputDirectoryEntry = Entry(outputFrame, width=70, textvariable=self.__ctrl.getOutputDirectoryEntryVariable())
        outputDirectoryEntry.grid(column=1, row=0, padx=5, pady=5, sticky='ew')
        outputDirectoryButton = Button(outputFrame, text='...', command=self.__ctrl.outputDirectoryEntryVariableHandler)
        outputDirectoryButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')

        outputFileNameLabel = Label(outputFrame, text='Output File Name:', width=15, anchor='w')
        outputFileNameLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
        outputFileNameEntry = Entry(outputFrame, width=70, textvariable=self.__ctrl.getOutputFileNameEntryVariable())
        outputFileNameEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')

        outputFormatLabel = Label(outputFrame, text='Output Format:', width=15, anchor='w')
        outputFormatLabel.grid(column=0, row=2, padx=5, pady=5, sticky='w')
        outputFormatListBox = OptionMenu(outputFrame, self.__ctrl.getSelectedOutputFormat(), self.__ctrl.getOutputFormatList())
        outputFormatListBox.grid(column=1, row=2, padx=5, pady=5, sticky='w')

        keepGeneratedScribusFilesLabel = Label(outputFrame, text='Keep Scribus Files:', width=15, anchor='w')
        keepGeneratedScribusFilesLabel.grid(column=0, row=3, padx=5, pady=5, sticky='w')
        keepGeneratedScribusFilesCheckbox = Checkbutton(outputFrame, variable=self.__ctrl.getKeepGeneratedScribusFilesCheckboxVariable())
        keepGeneratedScribusFilesCheckbox.grid(column=1, row=3, padx=5, pady=5, sticky='w')

        # Buttons to Cancel or to Run the Generator with the given Settings
        helpButton = Button(buttonFrame, text='Help', width=10, command=self.__ctrl.helpButtonHandler)
        helpButton.grid(column=0, row=0, padx=5, pady=5, sticky='e')
        cancelButton = Button(buttonFrame, text='Cancel', width=10, command=self.__ctrl.buttonCancelHandler)
        cancelButton.grid(column=1, row=0, padx=5, pady=5, sticky='e')
        generateButton = Button(buttonFrame, text='Generate', width=10, command=self.__ctrl.buttonOkHandler)
        generateButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')

        # Finally show the Generator Dialog
        mainFrame.grid()
        self.__root.grid()
        self.__root.mainloop()
开发者ID:rozzilla,项目名称:crea-tabella,代码行数:73,代码来源:ScribusGenerator.py

示例15: CreateView

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import grid [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


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