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


Python Frame.pack方法代码示例

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


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

示例1: show_source_tree

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
def show_source_tree(head):
    root = Tk()
    frame = Frame(root)
    frame.pack(fill = 'both')
    tree = tkinter.ttk.Treeview(frame)
    
    #insert root subroutine
    # @type head Node
    parent_id = tree.insert('', 'end', '', text = head.name)
    for child in head.children:
        child.insert_to_tree(tree, parent_id)



    
    #add scrollbar
    v_scrollbar = Scrollbar(frame, orient = VERTICAL, command = tree.yview)
    h_scrollbar = Scrollbar(frame, orient = HORIZONTAL, command = tree.xview)
    tree.configure(yscrollcommand = v_scrollbar.set, xscrollcommand = h_scrollbar.set)
    
    v_scrollbar.pack(side = 'right', fill = 'y')
    h_scrollbar.pack(side = 'bottom', fill = 'x')


    tree.pack(fill = 'both')
    root.geometry("600x600")
    root.mainloop()
开发者ID:guziy,项目名称:CallTreeGenerator,代码行数:29,代码来源:test_tkinter.py

示例2: initUI

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
    def initUI(self):
      
        self.lineCounter = 0
      
        # create a custom font
        self.customFontHeader = font.Font(family="Calibri", slant = "italic") #family="Helvetica", weight="bold", slant="italic")
        self.customFontMessage = font.Font(family="Calibri")
        
        self.parent.title("Python Chat") 
        
        frame = Frame(self.parent)
        frame.pack(fill=BOTH, expand=1, side=LEFT)
        
        self.box = ScrolledText(frame, wrap=WORD, relief = GROOVE, width=30, height=18, font=self.customFontMessage)
        self.box.insert(END, 'Welcome to Python Chat!')
        self.box.config(state=DISABLED)
        self.box.pack(expand="yes", fill=BOTH, side=TOP)
        
        self.textarea = Text(frame, width=30, height=5)
        #self.textarea.insert(END, "")
        self.textarea.bind("<KeyRelease-Return>", self.gettext) #Se metto on press, rimane una newline in piu
        self.textarea.pack(expand="yes", fill=BOTH, side=TOP)

        
        okButton = Button(frame, text="Panic Button", activebackground="red", command=self.sendFile) 
        okButton.pack(expand="no", fill=BOTH, side=TOP)
        
        self.usersFrame = Frame(self.parent)
        self.usersFrame.pack(fill=BOTH, expand=1, side=RIGHT)
        
        self.userListbox = Listbox(self.usersFrame, width=3)
        self.userListbox.pack(fill=BOTH, expand=1)
            
        self.updateUsersFrame()
开发者ID:skimdz86,项目名称:Utilities,代码行数:36,代码来源:BlinkingChatGUIClient.py

示例3: Wall

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
class Wall(object):
    MIN_RED = MIN_GREEN = MIN_BLUE = 0x0
    MAX_RED = MAX_GREEN = MAX_BLUE = 0xFF

    PIXEL_WIDTH = 50

    def __init__(self, width, height):
        self.width = width
        self.height = height
        self._tk_init()
        self.pixels = [(0, 0, 0) for i in range(self.width * self.height)]

    def _tk_init(self):
        self.root = Tk()
        self.root.title("ColorWall %d x %d" % (self.width, self.height))
        self.root.resizable(0, 0)
        self.frame = Frame(self.root, bd=5, relief=SUNKEN)
        self.frame.pack()

        self.canvas = Canvas(self.frame,
                             width=self.PIXEL_WIDTH * self.width,
                             height=self.PIXEL_WIDTH * self.height,
                             bd=0, highlightthickness=0)
        self.canvas.pack()
        self.root.update()

    def set_pixel(self, x, y, hsv):
        self.pixels[self.width * y + x] = hsv

    def get_pixel(self, x, y):
        return self.pixels[self.width * y + x]

    def draw(self):
        self.canvas.delete(ALL)
        for x in range(len(self.pixels)):
            x_0 = (x % self.width) * self.PIXEL_WIDTH
            y_0 = (x / self.width) * self.PIXEL_WIDTH
            x_1 = x_0 + self.PIXEL_WIDTH
            y_1 = y_0 + self.PIXEL_WIDTH
            hue = "#%02x%02x%02x" % self._get_rgb(self.pixels[x])
            self.canvas.create_rectangle(x_0, y_0, x_1, y_1, fill=hue)
        self.canvas.update()

    def clear(self):
        for i in range(self.width * self.height):
            self.pixels[i] = (0, 0, 0)

    def _hsv_to_rgb(self, hsv):
        rgb = colorsys.hsv_to_rgb(*hsv)
        red = self.MAX_RED * rgb[0]
        green = self.MAX_GREEN * rgb[1]
        blue = self.MAX_BLUE * rgb[2]
        return (red, green, blue)

    def _get_rgb(self, hsv):
        red, green, blue = self._hsv_to_rgb(hsv)
        red = int(float(red) / (self.MAX_RED - self.MIN_RED) * 0xFF)
        green = int(float(green) / (self.MAX_GREEN - self.MIN_GREEN) * 0xFF)
        blue = int(float(blue) / (self.MAX_BLUE - self.MIN_BLUE) * 0xFF)
        return (red, green, blue)
开发者ID:rkedge,项目名称:ColorWall,代码行数:62,代码来源:wall.py

示例4: receivePrivateChat

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
 def receivePrivateChat(self, connectingUser):
     global conversationBoxList
     print("CHAT PRIVATA in arrivo con "+connectingUser)
         
     newWindow = Toplevel(self.parent)
     newWindow.title("Python Chat requested by "+connectingUser)
     newWindow.minsize(400, 475)
     newWindow.focus()
     
     def disconnectPM():
         del conversationBoxList[connectingUser]
         newWindow.destroy()
     newWindow.protocol('WM_DELETE_WINDOW', disconnectPM)
     
     #label = Label(newWindow, text="PROVA PROVA")
     #label.pack(side="top", fill="both", padx=10, pady=10)
     frame = Frame(newWindow)
     frame.pack(fill=BOTH, expand=1, side=LEFT)
     
     box = ScrolledText(frame, wrap=WORD, relief = GROOVE, width=30, height=18, font=self.customFontMessage)
     box.config(state=DISABLED)
     box.pack(expand="yes", fill=BOTH, side=TOP)
     
     textarea = Text(frame, width=30, height=5)
     textarea.bind("<KeyRelease-Return>", lambda event : self.getprivatetext(event, textarea, connectingUser)) 
     textarea.pack(expand="yes", fill=BOTH, side=TOP)
     
     #aggiungo alla mappa globale il box di conversazione
     conversationBoxList[connectingUser] = box
开发者ID:skimdz86,项目名称:Utilities,代码行数:31,代码来源:BlinkingChatGUIMultiClient.py

示例5: game_window

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
 def game_window(self):
     ##Window##
     self.root.grid()
     self.root.title("Equations")
     ##Canvas##
     #Frame
     frame=Frame(self.root)
     frame.pack()
     self.canvas=tk.Canvas(frame, bg="white", width=800, height=500)
     self.canvas.pack()
     #Background/label
     bg_image=tk.PhotoImage(file="EQUATIONSbackground.gif")
     self.canvas.create_image(0, 250, image=bg_image, anchor="w")
     
     ##Score Display##
     score_label=tk.Label(self.root, text=["Score:", self.score], font=("Courier", 20), fg="red", bg="white")
     score_label.pack()
     score_label.place(x=650, y=450)
     
     ##Popup Menu##
     popupmenu=tk.Label(self.canvas, text=("Answer all eight equations correctly!"), font=("Courier", 12), anchor="n", bg="white", fg="black", height=7)
     popupmenu.place(x=280, y=180)
     #Return to Menu Button
     returnmenu=tk.Button(self.canvas, text="Main Menu", bg="white", command=self.returntomenu)
     returnmenu.place(x=425, y=240)
     #Start Button
     start=tk.Button(self.canvas, text="Start", bg="white")
     start.config(command= lambda: self.gameplay(popupmenu, start, returnmenu, score_label, 8))
     start.place(x=325, y=240)
             
     ##Keep running##
     self.root.mainloop()
开发者ID:izelichenko,项目名称:math-game,代码行数:34,代码来源:equations.py

示例6: addPathFrame

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
    def addPathFrame(self):
        frame=Frame(self)
        frame.pack(fill=tk.X,expand=0,side=tk.TOP,padx=8,pady=5)

        frame.columnconfigure(1,weight=1)

        #------------------Database file------------------
        label=tk.Label(frame,text=dgbk('ting.sqlite文件:'),\
                bg='#bbb')
        label.grid(row=0,column=0,\
                sticky=tk.W,padx=8)

        self.db_entry=tk.Entry(frame)
        self.db_entry.grid(row=0,column=1,sticky=tk.W+tk.E,padx=8)

        self.db_button=tk.Button(frame,text=dgbk('打开'),command=self.openFile)
        self.db_button.grid(row=0,column=2,padx=8,sticky=tk.E)

        #--------------------Output dir--------------------
        label2=tk.Label(frame,text=dgbk('导出到文件夹:'),\
                bg='#bbb')
        label2.grid(row=2,column=0,\
                sticky=tk.W,padx=8)

        self.out_entry=tk.Entry(frame)
        self.out_entry.grid(row=2,column=1,sticky=tk.W+tk.E,padx=8)
        self.out_button=tk.Button(frame,text=dgbk('选择'),command=self.openDir)
        self.out_button.grid(row=2,column=2,padx=8,sticky=tk.E)
开发者ID:Xunius,项目名称:XimaExport,代码行数:30,代码来源:ximaexport-gui.py

示例7: create_widgets

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
    def create_widgets(self):
        """ Login form """

        frame_top = Frame(self, pady=15, padx=15)
        frame_top.pack()

        self.email = StringVar()
        self.email_label = Label(frame_top, text="Email")
        self.email_entry = Entry(frame_top, textvariable=self.email)

        self.password = StringVar()
        self.password_label = Label(frame_top, text="Password")
        self.password_entry = Entry(frame_top,
                                    textvariable=self.password, show='*')

        frame_bottom = Frame(self, pady=15, padx=15)
        frame_bottom.pack()

        self.submit = Button(frame_bottom)
        self.submit["text"] = "Login"
        self.submit["command"] = self.sign_in

        #layout widgets in grid
        self.email_label.grid(row=1, column=0)
        self.email_entry.grid(row=1, column=1)
        self.password_label.grid(row=2, column=0)
        self.password_entry.grid(row=2, column=1)
        self.submit.grid(row=2, column=0)
开发者ID:garthreckers,项目名称:p01-desktop,代码行数:30,代码来源:loginscreen.py

示例8: GUI

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
class GUI(object):
    """
    The base class for GUI builder
    """

    __metaclass__ = ABCMeta

    def __init__(self, root):
        self.colorPicker = ColorPicker(root)
        self.topToolbar = Frame(root, bd=1, relief=RAISED)
        self.topToolbar.pack(side=TOP, fill=X)
        self.canvas = DrawingCanvas(root, self.colorPicker)
        self.canvas.pack(expand=YES, fill=BOTH)

    # Initializes IO and Draw commands.
    @abstractmethod
    def initButtons(self, ios, commands):
        pass

    # Event handler when users click on an IO command.
    @abstractmethod
    def onIOCommandClick(self, button, command):
        pass

    # Event handler when users click on a draw command.
    @abstractmethod
    def onDrawCommandClick(self, button, command):
        pass

    # Event handler when users change the selected color.
    @abstractmethod
    def onChangeColor(self, command):
        pass
开发者ID:tu-tran,项目名称:DrawingProjectPython,代码行数:35,代码来源:gui.py

示例9: initUI

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
    def initUI(self):
        self.parent.title('PyZilla')
        self.padding = 5

        self.pack(fill=BOTH, expand=1)

        # Create a menubar
        mnuMenu = Menu(self.parent)
        self.parent.config(menu=mnuMenu)

        # Create menubar
        mnuFileMenu = Menu(mnuMenu)

        # Add File menu items
        mnuFileMenu.add_command(label='Open', command=self.onBtnOpenFile)
        mnuFileMenu.add_command(label='Exit', command=self.quit)

        # Add File menu items to File menu
        mnuMenu.add_cascade(label='File', menu=mnuFileMenu)

        # Create frame for all the widgets
        frame = Frame(self)
        frame.pack(anchor=N, fill=BOTH)

        # Create file open dialog
        btnOpenFile = Button(frame, text="Load file", command=self.onBtnOpenFile)
        btnOpenFile.pack(side=RIGHT, pady=self.padding)

        # Create filename label
        self.lblFilename = Label(frame, text='No filename chosen...')
        self.lblFilename.pack(side=LEFT, pady=self.padding, padx=self.padding)

        # Create the text widget for the results
        self.txtResults = Text(self)
        self.txtResults.pack(fill=BOTH, expand=1, pady=self.padding, padx=self.padding)
开发者ID:claudemuller,项目名称:pyzilla,代码行数:37,代码来源:pyzilla.py

示例10: __init__

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

        if title:
            self.title(title)

        self.parent = parent
        self.result = None

        body = Frame(self)
        self.initial_focus = self.body(body)
        body.pack(padx=5, pady=5)
        self.buttonbox()
        self.grab_set()

        if not self.initial_focus:
            self.initial_focus = self

        self.protocol("WM_DELETE_WINDOW", self.cancel)
        self.geometry("+%d+%d" % (parent.winfo_rootx() + 50,
                                  parent.winfo_rooty() + 50))
        self.initial_focus.focus_set()

        self.wait_window(self)
开发者ID:SpeedProg,项目名称:PveLauncher,代码行数:27,代码来源:tksimpledialog.py

示例11: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
 def __init__(self, *args, **kwargs):
     self._app = Scripting.root_node
     self.__topwin = kwargs.pop('topwin')
     super().__init__(*args, **kwargs)
     
     frm = Frame(self)
     self.__gui_images = []
     imageMatFileBtn = ImageTk.PhotoImage(
         file=Scripting.root_node.get_gui_image_path('Pattern_SaveMat_Button.png'))
     self.__gui_images.append(imageMatFileBtn)
     Button(
         frm, 
         image=imageMatFileBtn, 
         command=self._on_save_mat_file).pack(side='top')
     Button(
         frm, 
         text='mat', 
         width=6).pack(side='top')
     frm.pack(side='left')
     
     frm = Frame(self)
     imageExcelFileBtn = ImageTk.PhotoImage(
         file=Scripting.root_node.get_gui_image_path('Pattern_SaveExcel_Button.png'))
     self.__gui_images.append(imageExcelFileBtn)
     Button(frm, image=imageExcelFileBtn).pack(side='top')
     Button(frm, text='xlsx', width=6).pack(side='top')
     frm.pack(side='left')
     
     self.name = 'Corr Matrix'
开发者ID:xialulee,项目名称:WaveSyn,代码行数:31,代码来源:patternsyn.py

示例12: initUI

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
 def initUI(self):
     #top frame using all the remaining space
     innerTopFrame = Frame(self, background="black")
     innerTopFrame.pack(fill=BOTH, expand=1)
     #CLOSE Label
     innerBottomLeftFrame = Frame(self, background="black")
     innerBottomLeftFrame.place(x=0, width=self.wRoot/2, 
         y=self.hRoot-200, height=200)
     closeLabel = Label(innerBottomLeftFrame, bg="black", fg="black",
         text="CLOSE", font=("Comic Sans MS", 48, "bold"))
     innerBottomLeftFrame.bind("<Enter>", lambda f: closeLabel.config(fg="white"))
     innerBottomLeftFrame.bind("<Leave>", lambda f: closeLabel.config(fg="black"))
     innerBottomLeftFrame.bind("<Button-1>", lambda f: self.root.quit())
     closeLabel.bind("<Button-1>", lambda f: self.root.quit())
     closeLabel.pack(fill=BOTH)
     #SHUT DOWN Label
     innerBottomRightFrame = Frame(self, background="black")
     innerBottomRightFrame.place(x=self.wRoot/2, width=self.wRoot/2, 
         y=self.hRoot-200, height=200)
     shutdownLabel = Label(innerBottomRightFrame, bg="black", fg="black",
         text="SHUT DOWN", font=("Comic Sans MS", 48, "bold"))
     innerBottomRightFrame.bind("<Enter>", lambda f: shutdownLabel.config(fg="white"))
     innerBottomRightFrame.bind("<Leave>", lambda f: shutdownLabel.config(fg="black"))
     innerBottomRightFrame.bind("<Button-1>", self.shutdown)
     shutdownLabel.bind("<Button-1>", self.shutdown)
     shutdownLabel.pack(fill=BOTH)
     #design the FullScreenApp
     self.pack(fill=BOTH, expand=1)
开发者ID:ilmeo,项目名称:python-homeTheater,代码行数:30,代码来源:homeTheater.py

示例13: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
    def __init__(self, parent, handler):

        '''Initialization method.'''

        Frame.__init__(self, parent)

        button_frame = Frame(self)
        button_frame.pack(side=TOP)

        self.deal_button = Button(button_frame, text="Deal",
                                  command=lambda: handler("deal"))
        self.deal_button.pack(side=LEFT, padx=5, pady=5)

        self.quit_button = Button(button_frame, text="Quit",
                                  command=lambda: handler("quit"))
        self.quit_button.pack(side=RIGHT, padx=5, pady=5)

        self.exchange_button = Button(button_frame, text="Exchange",
                                      command=lambda: handler("exchange"))
        self.exchange_button.pack(side=RIGHT, padx=5, pady=5)

        self.show_button = Button(button_frame, text="Show",
                                  command=lambda: handler("show"))
        self.show_button.pack(side=RIGHT, padx=5, pady=5)

        label_frame = Frame(self)
        label_frame.pack(side=BOTTOM)

        self.status_label = Label(label_frame, relief=SUNKEN)
        self.set_status_text("No text to show")
        self.status_label.pack(side=TOP, padx=5, pady=5)
开发者ID:paulgriffiths,项目名称:videopoker,代码行数:33,代码来源:chw.py

示例14: __init__

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

示例15: ChoosePlayerDialog

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import pack [as 别名]
class ChoosePlayerDialog(Toplevel):
    """Dialog used to prompt the user to choose a player."""
    def __init__(self, program: GUIProgram):
        super(ChoosePlayerDialog, self).__init__(program.app)
        self.title('Choose Player')
        self.program = program
        self.body = Frame(self)
        self.initial_focus = self.body
        self.body.pack()
        self.create_widgets()
        self.initial_focus.focus_set()
        # If this window is closed, terminate the application.
        self.wm_protocol('WM_DELETE_WINDOW', self.on_close)

    def create_widgets(self):
        """Generate the label and buttons to prompt the user for a player."""
        Label(self.body, text='Choose your player:').pack()
        for player in Player:
            Button(self.body, text=player,
                   command=partial(self.click_handler, player),
                   **GUIProgram.standard_button_dimensions).pack()

    def click_handler(self, player: Player):
        """Callback used to call back into the main program to handle the
        player choice.  Once complete, the dialog is closed.
        """
        self.program.handle_player_choice(player)
        self.body.destroy()
        self.destroy()

    def on_close(self):
        """Callback used to terminate the application if closed."""
        self.program.window.quit()
开发者ID:carymrobbins,项目名称:Tic-Tac-Toe,代码行数:35,代码来源:gui.py


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