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


Python Frame.grid方法代码示例

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


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

示例1: ProgramWidget

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
class ProgramWidget(Frame):

    def __init__(self, parent, client):
        super(ProgramWidget, self).__init__(parent)
        self.client = client
        self.client.onProgramChange = self.programChanged

        self.programLabel = Label(self, text = 'Program:')
        self.programLabel.grid(row = 0, column = 0)
        self.programEntry = Entry(self, text = 'Program name',
                                  state = 'readonly')
        self.programEntry.grid(row = 0, column = 1)
        self.buttonPanel = Frame(self)
        self.buttonPanel.grid(row = 1, column = 0, columnspan = 2, sticky = W)
        self.newButton = Button(self.buttonPanel, text='New',
                                command = self.newProgram)
        self.newButton.pack(side = LEFT)

    def programChanged(self):
        self.__setProgramText(str(self.client.state))

    def __setProgramText(self, text):
        self.programEntry.configure(state = NORMAL)
        self.programEntry.delete(0)
        self.programEntry.insert(0, text)
        self.programEntry.configure(state = 'readonly')

    def newProgram(self):
        self.client.makeNewProgram()
开发者ID:mindhog,项目名称:mawb,代码行数:31,代码来源:tkui.py

示例2: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def __init__(self):
        Toplevel.__init__(self)
        self.focus_set()
        self.grab_set()

        self.result = None
        self.module_data = None
        self.mod_applis = None
        self.title(ugettext("Instance editor"))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.ntbk = ttk.Notebook(self)
        self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))

        self.frm_general = Frame(self.ntbk, width=350, height=150)
        self.frm_general.grid_columnconfigure(0, weight=0)
        self.frm_general.grid_columnconfigure(1, weight=1)
        self._general_tabs()
        self.ntbk.add(self.frm_general, text=ugettext('General'))

        self.frm_database = Frame(self.ntbk, width=350, height=150)
        self.frm_database.grid_columnconfigure(0, weight=0)
        self.frm_database.grid_columnconfigure(1, weight=1)
        self._database_tabs()
        self.ntbk.add(self.frm_database, text=ugettext('Database'))

        btnframe = Frame(self, bd=1)
        btnframe.grid(row=1, column=0, columnspan=1)
        Button(btnframe, text=ugettext("OK"), width=10, command=self.apply).grid(
            row=0, column=0, sticky=(N, S, E))
        Button(btnframe, text=ugettext("Cancel"), width=10, command=self.destroy).grid(
            row=0, column=1, sticky=(N, S, W))
开发者ID:povtux,项目名称:core,代码行数:35,代码来源:lucterios_gui.py

示例3: showPlotTools

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def showPlotTools(self):        
        
        f2= Frame(self.frame, relief=FLAT,bg='#FADC46')
        f2.grid(row=1,column=0,rowspan=2,columnspan=3,sticky=N+S+E+W,padx=10,pady =10)
        
        b1 = Button(f2,text='3D K',relief=RAISED,command= lambda:self.plotButtonPressed(1))
        b1.grid(row=0, column=0,sticky=N+S+E+W,padx=5,pady =5)
        
        b2 = Button(f2,text='3D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(2))
        b2.grid(row=0, column=1,sticky=N+S+E+W,padx=5,pady =5)
        
        b3 = Button(f2,text='3D DP',relief=RAISED,command=lambda:self.plotButtonPressed(3))
        b3.grid(row=0, column=2,sticky=N+S+E+W,padx=5,pady =5)
        
        b4 = Button(f2,text='2D K',relief=RAISED,command=lambda:self.plotButtonPressed(4))
        b4.grid(row=1, column=0,sticky=N+S+E+W,padx=5,pady =5)

        b5 = Button(f2,text='2D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(5))
        b5.grid(row=1, column=1,sticky=N+S+E+W,padx=5,pady =5)

        b6 = Button(f2,text='2D DP',relief=RAISED,command=lambda:self.plotButtonPressed(6))
        b6.grid(row=1, column=2,sticky=N+S+E+W,padx=5,pady =5)
        
        f2.columnconfigure(0, weight=1)
        f2.columnconfigure(1, weight=1)
        f2.columnconfigure(2, weight=1)

        f2.rowconfigure(0, weight=1)
        f2.rowconfigure(1, weight=1)
开发者ID:VrishtiDutta,项目名称:EGUANA_Python,代码行数:31,代码来源:EGUANA.py

示例4: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
class Widget_:

	def __init__(self, parent_frame, row, column, width=50, height=50):
		self.widget_frame = Frame(parent_frame, width=width, height=height)
		self.widget_frame.grid(row=row, column=column)
		self.width, self.height = width, height
		return

	def add_tag(self, tag_library, string):
		tag_library[string] = self

	def delete_widget(self):
		for child in self.widget_frame.winfo_children():
			child.destroy()
		self.widget_frame.destroy()

	def hide_widget(self):
		self.widget_frame.grid_forget()

	def get_info(self):
		return

	def set_field(self):
		return

	pass
开发者ID:wasifzaman,项目名称:Project-RYB,代码行数:28,代码来源:widget_.py

示例5: draw_automata

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
def draw_automata(turing_machine=None):

    w = len(turing_machine.states)
    h = len(turing_machine.rules)

    root = Tk()
    frame = Frame(root, width=800, height=600)
    frame.grid(row=0, column=0)
    canvas = Canvas(frame, bg='#FFFFFF', width=800, height=600,
                    scrollregion=(0, -h * 15, w * 100, h * 15*3))
    hbar = Scrollbar(frame, orient=HORIZONTAL)
    hbar.pack(side=BOTTOM, fill=X)
    hbar.config(command=canvas.xview)
    vbar = Scrollbar(frame, orient=VERTICAL)
    vbar.pack(side=RIGHT, fill=Y)
    vbar.config(command=canvas.yview)
    canvas.config(width=800, height=600)
    canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
    canvas.pack(side=LEFT, expand=True, fill=BOTH)

    for position, state in enumerate(turing_machine.states):
        state_position[state] = position
        loop_occurrences[position] = 0
        canvas_id = canvas.create_text(10 + 80 * position, 400, anchor="nw")
        canvas.itemconfig(canvas_id, text="state-")
        canvas.insert(canvas_id, 12, "%d" % state)

    counter = 1
    for rule in turing_machine.rules:
        counter = draw_arrow(state_position[rule.current_state],
                             state_position[rule.next_state],
                             canvas, counter, rule)

    root.mainloop()
开发者ID:ytsvetkov,项目名称:TuringMachine,代码行数:36,代码来源:automata_graph.py

示例6: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def __init__(self, root, title):
        self.root = root
        self.root.title(title)

        # Variable that stores file handle (may be unnecessary)
        self.file_handle = ""

        master_frame = Frame(root)
        master_frame.pack(expand="yes", fill="both")

        # Create left button frame and buttons
        button_frame = Frame(master_frame)
        self.open_button = Button(button_frame, text="Choose File", command=self.load_file)
        self.open_button.pack(expand="yes", fill="both")
        self.apply_button = Button(button_frame, text="Apply", command=self.apply_consistent, state="disabled")
        self.apply_button.pack(expand="yes", fill="both")
        self.save_button = Button(button_frame, text="Save File", command=self.save_file, state="disabled")
        self.save_button.pack(expand="yes", fill="both")

        # Create text frame and initialize text widget
        text_frame = Frame(master_frame)
        self.text_box = Text(text_frame, height=10, width=50, state="disabled")
        self.text_box.pack(side="top", expand="yes", fill="both")

        # Configure weights for grid elements
        master_frame.columnconfigure(0, weight=1)
        master_frame.columnconfigure(1, weight=5)
        for i in range(3):
            master_frame.rowconfigure(i, weight=1)

        # Position button and text frames
        button_frame.grid(row=0, column=0, rowspan=3, sticky="nsew")
        text_frame.grid(row=0, column=1, rowspan=3, sticky="nsew")
        
        self.root.minsize(500, 200)
开发者ID:Petetete,项目名称:Consistent-CSS,代码行数:37,代码来源:consistent-css.py

示例7: _initjoincondpanel

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
 def _initjoincondpanel(self):
     frame = Frame(self)
     frame.grid(row=0, column=2, sticky=E + W + S + N, padx=5)
     
     label = Label(frame, text="Join Condition: ")
     label.grid(sticky=N + W)
     
     self.joincondlist = Listbox(frame)
     self.joincondlist.grid(row=1, rowspan=1, columnspan=3, sticky=E + W + S + N)
     
     vsl = Scrollbar(frame, orient=VERTICAL)
     vsl.grid(row=1, column=3, rowspan=1, sticky=N + S + W)
     
     hsl = Scrollbar(frame, orient=HORIZONTAL)
     hsl.grid(row=2, column=0, columnspan=3, sticky=W + E + N)
     
     self.joincondlist.config(yscrollcommand=vsl.set, xscrollcommand=hsl.set)
     
     hsl.config(command=self.joincondlist.xview)
     vsl.config(command=self.joincondlist.yview)
     
     newbtn = Button(frame, text="New", width=7, command=self._addjoincondition)
     newbtn.grid(row=3, column=0, padx=5, pady=5, sticky=E)
     
     delbtn = Button(frame, text="Delete", width=7, command=self._deletejoincondition)
     delbtn.grid(row=3, column=1, sticky=E)
     
     modbtn = Button(frame, text="Update", width=7, command=self._modifyjoincondition)
     modbtn.grid(row=3, column=2, padx=5, pady=5, sticky=W)
开发者ID:shawncx,项目名称:LogParser,代码行数:31,代码来源:logui.py

示例8: _initfilepanel

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
 def _initfilepanel(self):
     frame = Frame(self)
     frame.grid(row=0, column=0, sticky=E + W + S + N)
     
     label = Label(frame, text="File List: ")
     label.grid(sticky=N + W)
     
     self.filelist = Listbox(frame, width=40)
     self.filelist.grid(row=1, column=0, rowspan=2, columnspan=3)
     
     vsl = Scrollbar(frame, orient=VERTICAL)
     vsl.grid(row=1, column=3, rowspan=2, sticky=N + S + W)
     
     hsl = Scrollbar(frame, orient=HORIZONTAL)
     hsl.grid(row=3, column=0, columnspan=3, sticky=W + E + N)
     
     self.filelist.config(yscrollcommand=vsl.set, xscrollcommand=hsl.set)
     self.filelist.bind('<<ListboxSelect>>', self._onfilelistselection)
     
     hsl.config(command=self.filelist.xview)
     vsl.config(command=self.filelist.yview)
     
     upbtn = Button(frame, text="Up", width=7, command=self._upfile)
     upbtn.grid(row=1, column=4, padx=5, pady=5)
     
     downbtn = Button(frame, text="Down", width=7, command=self._downfile)
     downbtn.grid(row=2, column=4, padx=5, pady=5)
     
     newbtn = Button(frame, text="New", width=7, command=self._addfile)
     newbtn.grid(row=4, column=1, pady=5, sticky=E + S)
     
     delbtn = Button(frame, text="Delete", width=7, command=self._deletefile)
     delbtn.grid(row=4, column=2, padx=5, pady=5, sticky=W + S)
开发者ID:shawncx,项目名称:LogParser,代码行数:35,代码来源:logui.py

示例9: home_page

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def home_page(self, master):
        frame = Frame(master)
        frame.grid(row=0, column=0)

        image = PhotoImage(file="img/guido.gif")
        bg = Label(frame, image=image)
        bg.image = image
        bg.grid(row=0, column=0, rowspan=4, columnspan=2)

        index = 0
        while index < 3:
            frame.grid_columnconfigure(index, minsize=200)
            frame.grid_rowconfigure(index, minsize=80)
            index += 1

        summary_button = HomeButton(frame, self.to_summary, 'img/summary.png')
        summary_button.grid(row=0, column=0, sticky='w')

        edit_button = HomeButton(frame, self.to_edit, 'img/edit.png')
        edit_button.grid(row=0, column=1, sticky='e')

        momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png')
        momentary_button.grid(row=1, column=0, sticky='w')

        preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png')
        preferences_button.grid(row=1, column=1, sticky='e')

        music = HomeButton(frame, self.to_summary, 'img/music.png')
        music.grid(row=2, column=0, sticky='w')

        info = HomeButton(frame, self.to_summary, 'img/info.png')
        info.grid(row=2, column=1, sticky='e')

        return frame
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:36,代码来源:Gui.py

示例10: create_region_frame

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
 def create_region_frame(self, tid):
     """ Initiliases a frame on the map for region with id tid. """
     x = int(tid.split("_")[1])
     N = int(sqrt(len(self.board)))
     my_frame = Frame(self.frame_map, height=3 * self.size - 1,
                      width=3 * self.size - 1, bd=2, relief="flat")
     my_frame.grid(row=int((x - 1) / N), column=(x - 1) % N)
     self.board_regions[tid] = my_frame
开发者ID:mkerin,项目名称:SmallWorlds,代码行数:10,代码来源:class_GameGUI.py

示例11: make_frame

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
 def make_frame(self,labeltext=None):
     "Return gridded labeled Frame for option or other buttons."
     if labeltext:
         l = Label(self.top, text=labeltext)
         l.grid(row=self.row, column=0, sticky="nw")
     f = Frame(self.top)
     f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
     self.row = self.row + 1
     return f
开发者ID:vemulasravan6,项目名称:cpython,代码行数:11,代码来源:SearchDialogBase.py

示例12: __create_app_frame

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
 def __create_app_frame(self):
     """
     This function creates and pack (using grid) the main app frame
     (The left toolbar (users list) and the canvas
     """
     app_frame = Frame(self.__master_splinter)
     self.create_game_canvas(app_frame)
     self.create_left_toolbar(app_frame)
     app_frame.grid(row=1)
开发者ID:Omertorren,项目名称:ex12,代码行数:11,代码来源:client.py

示例13: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def __init__(self, master):
        column0_padx = 24
        row_pady = 36

        #Label 1
        lbl_testcase_exec = Label(master, text="Test case execution",
                                  wraplength=100, anchor='w', justify='left')
        lbl_results_cmp = Label(master, text="Results comparison",
                                wraplength=100, justify='left')
        lbl_tolerance = Label(master, text="Tolerance (5%)", wraplength=100)
        testcase_exec = Checkbutton(master)
        results_cmp = Checkbutton(master)
        tolerance = Entry(master, width=4)
        lbl_analysis = Label(master, text="Analysis Library")
        analysis_lib = Entry(master, width=30)

        lbl_testcase_exec.grid(row=0, column=2, padx=20, pady=12, sticky='w')
        lbl_results_cmp.grid(row=0, column=3, pady=12, sticky='w')
        lbl_tolerance.grid(row=0, column=4, padx=20, pady=12, sticky='wn')
        lbl_analysis.grid(row=1, column=0, sticky='w', padx=column0_padx)
        analysis_lib.grid(row=1, column=1, sticky='w')
        testcase_exec.grid(row=1, column=2, padx=20, sticky='w')
        results_cmp.grid(row=1, column=3, sticky='w')
        tolerance.grid(row=1, column=4, padx=20, sticky='w')

        #Label 2
        lbl_ref_analysis = Label(
            master, text="Reference Analysis Libary Version",
            wraplength=150, justify='left', pady=row_pady)
        ref_analysis_lib = Entry(master, width=30)
        lbl_ref_analysis.grid(row=2, column=0, sticky='w', padx=column0_padx)
        ref_analysis_lib.grid(row=2, column=1, sticky='w')

        # version
        lbl_version = Label(master, text="Version under Test")
        version = Label(master, text="vA.B.C.D")
        lbl_version.grid(row=3, column=0, sticky='w', padx=column0_padx)
        version.grid(row=3, column=1, sticky='w')

        # test all
        lbl_testall = Label(master, text="Test All")
        testall = Checkbutton(master)
        lbl_testall.grid(row=4, column=0, pady=row_pady, padx=column0_padx,
                         sticky='w')
        testall.grid(row=4, column=1, sticky='w')

        # buttons
        bottom_frame = Frame(master)
        bottom_frame.grid(row=5, column=1, columnspan=3, sticky='w')

        btn_start = Button(bottom_frame, text = "Go", width=7)
        btn_start.pack(side='left')
        btn_commit = Button(bottom_frame, text="Commit", width=7)
        btn_commit.pack(side='left', padx=80)
        btn_exit = Button(bottom_frame, text="Exit", width=7)
        btn_exit.pack(side='left')
开发者ID:ShrikanthRamanathan,项目名称:python-exercises,代码行数:58,代码来源:grid-layout.py

示例14: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
    def __init__(self):
        """
            À completer !.
        """
        super().__init__()

        # Nom de la fenêtre.
        self.title("Ultimate Tic-Tac-Toe")

        # La partie de ultimate Tic-Tac-Toe
        self.partie = Partie()

        # Un ditionnaire contenant les 9 canvas des 9 plateaux du jeu
        self.canvas_uplateau = {}

        Button(self.canvas_uplateau, text ='Débuter la partie', command =self.demande_confirmation).\
            grid(row =0, column =4)

        self.var = IntVar()
        Checkbutton(self, text= 'VS ordinateur', variable=self.var, onvalue =1, offvalue =0).grid(row =0, column =2)


        # L'entrée du joueur1 est automatiquement demandé
        Label(self.canvas_uplateau, text ="Nom du Joueur 1:").\
            grid(row =0, column =0, sticky=E)
        self.joueur1 = Entry(self.canvas_uplateau, width =14)
        self.joueur1.grid(row =0, column =1, padx=5, pady=5, sticky=E+W)

#        Label (self.canvas_uplateau, text="Le tour: {}".format(self.partie.joueur_courant.nom)).grid(row=3, column=3)

        # L'entrée du joueur2 est selon la checkbox (peut etre l'ordinateur
        Label(self.canvas_uplateau, text ="Nom du Joueur 2:").\
            grid(row =1, column =0, sticky=E)
        self.joueur2 = Entry(self.canvas_uplateau, width =14)
        self.joueur2.grid(row =1, column =1, padx=5, pady=5, sticky=E+W)

        Button(self.canvas_uplateau, text = 'Quitter', command = self.quit).\
            grid (row = 5, column = 4, sticky = E)

        # Création des frames et des canvas du jeu
        for i in range(0, 3):
            for j in range(0, 3):
                cadre = Frame(self, borderwidth=5, relief=GROOVE, background = '#e1e1e1')
                cadre.grid(row=i+3, column=j, padx=5, pady=5)
                cadre.bind('<Enter>', self.entrer_frame)
                cadre.bind('<Leave>', self.sortir_frame)
                self.canvas_uplateau[i,j] = CanvasPlateau(cadre, self.partie.uplateau[i,j])
                self.canvas_uplateau[i,j].grid()
                # On lie un clic sur le Canvas à une méthode.
                self.canvas_uplateau[i,j].bind('<Button-1>', self.selectionner)

        # Ajout d'une étiquette d'information.
        self.messages = Label(self)
        self.messages.grid(columnspan=3)
开发者ID:EL4321,项目名称:TP3,代码行数:56,代码来源:jeu_utictactoe.py

示例15: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid [as 别名]
class AddRestrictionDialog:
    def __init__(self, parent):
        self.parent = parent
        self.gui = Toplevel(parent.guiRoot)
        self.gui.grab_set()
        self.gui.focus()

        self.gui.columnconfigure(0, weight=1)
        self.gui.columnconfigure(1, weight=1)

        Label(self.gui, text="Enzyme:").grid(row=0, column=0, sticky="e", padx=5)
        self.entryEnzyme = Entry(self.gui)
        self.entryEnzyme.grid(row=0, column=1, sticky="w", padx=5, pady=10)
        self.frameButtonGroup = Frame(self.gui)
        self.frameButtonGroup.grid(row=1, column=0, columnspan=2, pady=10)
        self.buttonOK = Button(self.frameButtonGroup, text=" OK ")
        self.buttonCancel = Button(self.frameButtonGroup, text=" Cancel ")
        self.buttonOK.grid(row=0, column=1, sticky="w", padx=5)
        self.buttonCancel.grid(row=0, column=0, sticky="e", padx=5)

        # Set (minimum + max) Window size
        self.gui.update()
        self.gui.minsize(self.gui.winfo_width(), self.gui.winfo_height())
        self.gui.maxsize(self.gui.winfo_width(), self.gui.winfo_height())

        self.entryEnzyme.focus()

        self.buttonOK.bind("<ButtonRelease>", self.actionOK)
        self.buttonCancel.bind("<ButtonRelease>", self.actionCancel)
        self.entryEnzyme.bind("<Return>", self.actionOK)

        self.gui.mainloop()

    #         self.gui.grab_release()
    #         self.gui.destroy()

    def actionOK(self, event):
        enzymeString = self.entryEnzyme.get()
        if enzymeString in rest_dict.keys():

            if enzymeString in self.parent.optimizer.restrictionEnzymeList:
                showinfo("", (enzymeString + " was already added to the list"))
                return

            self.parent.optimizer.restrictionEnzymeList.append(enzymeString)
            self.parent.guiRoot.event_generate("<<Update>>", when="tail")
            self.gui.destroy()
        else:
            showinfo("", (enzymeString + " is not a valid restriction enzyme"))

    def actionCancel(self, event):
        self.gui.destroy()
开发者ID:hoerldavid,项目名称:codonoptimizer,代码行数:54,代码来源:OptimizerMainWindow.py


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