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


Python Button.pack方法代码示例

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


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

示例1: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        self.parent.title("Buttons")
        self.style = Style()
        self.style.theme_use("default")

        frame = Frame(self, relief=GROOVE, borderwidth=5)
        frame.pack(fill=BOTH, expand=1)
        self.pack(fill = BOTH, expand = 1)

        self.imageLabel = Label(frame, image = "")
        self.imageLabel.pack(fill=BOTH, expand=1)

        closeButton = Button(self, text="Close")
        closeButton.pack(side=RIGHT)
        okButton = Button(self, text="OK")
        okButton.pack(side=RIGHT)

        options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")]
        option = OptionMenu(self, self.key, *options)
        self.key.set(options[0])
        option.pack(side="left")

        spin = Spinbox(self, from_=0, to=1, increment=0.05)
        self.val = spin.get()
        spin.pack(side="left")
开发者ID:fredericgo,项目名称:PyCV-Processing,代码行数:27,代码来源:frame.py

示例2: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
 def initUI(self):
   
     self.parent.title("Buttons")
     self.style = Style()
     self.style.theme_use("default")
     
     frame = Frame(self, relief=RAISED, borderwidth=1)
     frame.pack(fill=BOTH, expand=1)
     #We create another Frame widget. 
     #This widget takes the bulk of the area. 
     #We change the border of the frame so that the frame is visible. 
     #By default it is flat.
     
     self.pack(fill=BOTH, expand=1)
     
     closeButton = Button(self, text="Close")
     closeButton.pack(side=RIGHT, padx=5, pady=5)
     #A closeButton is created. 
     #It is put into a horizontal box. 
     #The side parameter will create a horizontal box layout, in which the button is placed to the right of the box. 
     #The padx and the pady parameters will put some space between the widgets. 
     #The padx puts some space between the button widgets and between the closeButton and the right border of the root window. 
     #The pady puts some space between the button widgets and the borders of the frame and the root window.
     okButton = Button(self, text="OK")
     okButton.pack(side=RIGHT)
开发者ID:griadooss,项目名称:HowTos,代码行数:27,代码来源:05_buttons.py

示例3: __init__

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
 def __init__(self, parent, controller):
     Frame.__init__(self, parent)
     self.controller = controller
     label = Label(self, text="About", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
     label.pack(side="top", fill="x", pady=10)
     label_2 = Label(self, text=
     """        Frogs vs Flies is a cool on-line multi-player game.
     It consists of hungry frogs, trying to catch some darn
     tasty flies to eat and not starve to death, and terrified,
     but playful flies that try to live as long as possible 
     to score points by not being eaten by nasty frogs.
     ----------------------------------------------------------------------------------------
     When the game has been selected or created, and your
     class selected, click in the game field to start feeling your
     limbs. To move, use your keyboard's arrows.
     By this point, you should know where they are located, 
     don't you? Great! Now you can start playing the game!
     ----------------------------------------------------------------------------------------
     Frogs, being cocky little things, have the ability to
     do a double jump, holding SHIFT while moving with cursors.
     And flies, being so fly, that the air can't catch up with
     them, have a greater field of view, so they can see frogs
     before they can see them.
     ----------------------------------------------------------------------------------------
     Have a wonderful time playing this awesome game!
     ----------------------------------------------------------------------------------------
     
     Created by Kristaps Dreija and Egils Avots in 2015 Fall
     """, font=ABOUT_FONT, anchor=CENTER, justify=CENTER)
     label_2.pack()
     button1 = Button(self, text="\nBack\n", command=lambda: controller.show_frame("StartPage"))
     button1.pack(ipadx=20,pady=10)
开发者ID:kristapsdreija,项目名称:Frogs-vs-Flies,代码行数:34,代码来源:tkinter_main.py

示例4: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        self.parent.title("Book downloader")
        self.style = Style()
        self.style.theme_use("default")
        
        framesearch = Frame(self)
        framesearch.pack(fill=BOTH)

        search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15)
        search_label.pack(side=LEFT)

        self.search_entry = Entry(framesearch)
        self.search_entry.pack(side=RIGHT, fill=X)
        self.search_entry.bind("<Return>", self.searchHandler)
        #self.search_entry.bind("<Key>", self.searchHandler)
        
        framelist = Frame(self, relief=RAISED, borderwidth=1)
        framelist.pack(fill=BOTH, expand=True)

        self.lb = Listbox(framelist, height=30)
        scrollbar = Scrollbar(framelist)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.lb.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.lb.yview)
        
        self.loadLibrary()
        for b in self.book_list:
            self.lb.insert(END, b[0])
        self.lb.pack(fill=BOTH)
        
        self.pack(fill=BOTH, expand=True)
        
        DownButton = Button(self, text="Download", command=self.downloadAction)
        DownButton.pack(side=RIGHT)
开发者ID:joseche,项目名称:aws_scripts,代码行数:36,代码来源:download_books.py

示例5: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        
        #some aesthetic definitions 
        self.parent.title("Message Responder")
        self.style = Style()
        self.style.theme_use("classic")


        #building frame
        frame = Frame(self, relief=RAISED, borderwidth=1)
        frame.pack(fill=BOTH, expand=True)


        self.pack(fill=BOTH, expand=True)
        
        #adding some widgets
        label = Label(frame, text = self.text, wraplength = 495, justify = LEFT)
        label.pack()
        self.textBox = Text(frame, height = 2, width = 495)
        self.textBox.pack(side = BOTTOM)
        #self.textBox.insert(END, '#enter ye comments here')
        labelBox = Label(frame, text = "Actual Results:")
        labelBox.pack(anchor = W, side = BOTTOM)
        passButton = Button(self, text="PASS", command=self.btnClickedPass)
        passButton.pack(side=RIGHT, padx=5, pady=5)
        failButton = Button(self, text="FAIL", command=self.btnClickedFail)
        failButton.pack(side=RIGHT)
开发者ID:jnmcclai,项目名称:msg_responder,代码行数:29,代码来源:msg_responder.py

示例6: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        #<standard set up>
        self.parent.title("Buttons")
        self.style = Style()
        self.style.theme_use("default")
        #</standard set up>

        #if you put buttons here, it will initiate the buttons.
        #then it will initiate the frame. You would get two columns.
        #buttons appear in the second "lowered" area and not the raised frame.

        
        
        #<adding an additional frame>
        frame = Frame(self, relief=RAISED, borderwidth=1)
        
        frame.pack(fill=BOTH, expand =1)
        #</adding an additional frame>

        #<standard self.pack>
        self.pack(fill=BOTH, expand =1)
        #</standard self.pack>

        #<buttons are placed here>
        closeButton = Button (self, text = "Close")
        closeButton.pack(side=RIGHT, padx=5, pady =5)
        okButton = Button(self, text = "OK")
        okButton.pack(side=RIGHT)
开发者ID:91xie,项目名称:FYP,代码行数:30,代码来源:ButtonExample.py

示例7: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        

        information = Label(self,text = " \n Information on "+business_list[int(business_index)]['name']+"\n \n Located at: \n " + business_list[int(business_index)]['full_address'] )
        information.pack() 
        num_reviews  = Label(self, text = "Number of Reviews : " + str(business_list[int(business_index)]['review_count']) )    
        num_reviews.pack()
        
        type = Label(self, text = "Type of Restaurant : " + str(business_list[int(business_index)]['type']) )    
        type.pack()
        
        cat = business_list[int(business_index)]['categories']
        text_cat = ''
        for item in cat:
            text_cat = text_cat + ", " + item
        
        categories = Label(self, text = "Category of the resaurtant "+ text_cat )
        categories.pack()
        
        w = Label(self, text=" \n Write a Review for "+business_list[int(business_index)]['name'] )        
        w.pack() 
  
        e = Text(self, height=20, width=100)
        e.insert(END,"Insert Review Here")    
        e.pack()
        b = Button(self, text="Submit Review",command=lambda: self.tostars(e.get(1.0, END)))
        b.pack(side=BOTTOM, fill=BOTH)
        self.pack(fill=BOTH, expand=1)
开发者ID:PatrickVo,项目名称:CSCE470-Project-Final,代码行数:30,代码来源:yelpPD.py

示例8: __init__

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
class MyButton:
#Класс для улучшения читаемости кода однотипных элементов кнопок.
    def __init__(self, place_class, string_class, command_class):
#При создании принимается место прикрепления виджета, строковое значение для надписи
#и строковое для установления команды при нажатии.
        self.button_class = Button(place_class, width = 30, text = string_class, command = command_class)
        self.button_class.pack(side = LEFT)
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        self.parent.title("Simple")

        self.style = Style()
        self.style.theme_use("default")



        self.textup = Text(self, width=340, height=34)
        self.textup.bind("<KeyPress>", lambda e: "break")
        self.textup.pack()

        self.frame = Frame(self, relief=RAISED, borderwidth=1)
        self.frame.pack(fill=BOTH, expand=1)
        self.pack(fill=BOTH, expand=1)

        Label(self.frame,text = '', width= "350", height="1").pack()
        Label(self.frame,text = '欢迎大家', width= "350", height="1").pack()
        Label(self.frame,text = '', width= "350", height="3").pack()

        self.text = Text(self, width=340, height=3)
        self.text.bind("<Return>", self.sendMes)
        self.text.pack()
        closeButton = Button(self, text="Close")
        closeButton.pack(side=RIGHT, padx=5, pady=5)
        okButton = Button(self, text="OK",
                          command=self.onClick)
        okButton.pack(side=RIGHT)
开发者ID:wwg377655460,项目名称:MyAi,代码行数:30,代码来源:GUI.py

示例10: showLoading

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
 def showLoading(self):
     self.attemptedMarkov = True
     popup = Toplevel()
     text = Message(popup, text="The Markov Generator is still loading!\n\nText will show up when loaded!")
     text.pack()
     closePop = Button(popup, text="Okay!", command=popup.destroy)
     closePop.pack()  
开发者ID:jahardin,项目名称:175Project,代码行数:9,代码来源:interface.py

示例11: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):

        Config.read("config.ini")
        Config.sections()
        derecha = ConfigSectionMap("Movimientos")['derecha']
        izquierda = ConfigSectionMap("Movimientos")['izquierda']
        disparo = ConfigSectionMap("Movimientos")['disparo']
        salto = ConfigSectionMap("Movimientos")['salto']

        derecha=int(derecha)
        izquierda=int(izquierda)
        disparo=int(disparo)
        salto=int(salto)

        self.parent.title("Place of dead - [Configuration]")
        self.style = Style()
        #self.style.theme_use("default")
        self.style.configure('My.TFrame', background='gray')
        #Layouts
        frame1 = Frame(self)
        frame1.pack(fill=Y)
        frame2 = Frame(self)
        frame2.pack(fill=Y)
        frame3 = Frame(self)
        frame3.pack(fill=Y)
        frame4 = Frame(self)
        frame4.pack(fill=Y)
        frame5 = Frame(self)
        frame5.pack(fill=Y)
        frame6 = Frame(self)
        frame6.pack(fill=Y)

        self.pack(fill=BOTH, expand=1)
        self.labela = Label(frame2, text="Movimiento a la derecha: ")#, textvariable=self.var)
        self.labela.pack(side=LEFT)
        derechae = Entry(frame2,width=9)
        derechae.insert(END, str(retornarletra(derecha)))
        derechae.pack(side=LEFT,padx=1, pady=1, expand=True)

        self.labelb = Label(frame3, text="Movimiento a la derecha: ")#, textvariable=self.var)
        self.labelb.pack(side=LEFT)
        izquierdae = Entry(frame3,width=9)
        izquierdae.insert(END, str(retornarletra(izquierda)))
        izquierdae.pack(side=LEFT,padx=1, pady=1, expand=True)

        self.labelc = Label(frame4, text="Salto: ")#, textvariable=self.var)
        self.labelc.pack(side=LEFT)
        saltoe = Entry(frame4,width=9)
        saltoe.insert(END, str(retornarletra(salto)))
        saltoe.pack(side=LEFT,padx=1, pady=1, expand=True)

        self.labeld = Label(frame5, text="Ataque: ")#, textvariable=self.var)
        self.labeld.pack(side=LEFT)
        disparoe = Entry(frame5,width=9)
        disparoe.insert(END, str(retornarletra(disparo)))
        disparoe.pack(side=LEFT,padx=1, pady=1, expand=True)

        okButton = Button(frame6, text="Save", command=lambda: self.save(derechae.get(),izquierdae.get(),saltoe.get(),disparoe.get()))
        okButton.pack(side=RIGHT)
开发者ID:carolinajimenez26,项目名称:gameproyect_pygame,代码行数:61,代码来源:imports.py

示例12: Login

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
class Login(Frame):
    """******** Funcion: __init__ **************
    Descripcion: Constructor de Login
    Parametros:
    self Login
    parent Tk
    Retorno: void
    *****************************************************"""
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()


    """******** Funcion: initUI **************
    Descripcion: Inicia la interfaz grafica de un Login,
                para ello hace uso de Frames y Widgets.
    Parametros:
    self Login
    Retorno: void
    *****************************************************"""
    def initUI(self):
        self.parent.title("Pythagram: Login")
        self.style = Style()
        self.style.theme_use("default")

        self.frame = Frame(self, relief=RAISED)
        self.frame.pack(fill=BOTH, expand=1)
        self.instructions = Label(self.frame,text="A new Web Browser window will open, you must log-in and accept the permissions to use this app.\nThen you have to copy the code that appears and paste it on the next text box.")
        self.instructions.pack(fill=BOTH, padx=5,pady=5)
        self.codeLabel = Label(self.frame,text="Code:")
        self.codeLabel.pack(fill=BOTH, padx=5,pady=5)
        self.codeEntry = Entry(self.frame)
        self.codeEntry.pack(fill=BOTH, padx=5,pady=5)
        self.pack(fill=BOTH, expand=1)

        self.closeButton = Button(self, text="Cancel", command=self.quit)
        self.closeButton.pack(side=RIGHT, padx=5, pady=5)
        self.okButton = Button(self, text="OK", command=self.login)
        self.okButton.pack(side=RIGHT)

    """******** Funcion: login **************
    Descripcion: Luego que el usuario ingresa su codigo de acceso, hace
                la solicitud al servidor para cargar su cuenta en una
                ventana de tipo Profile
    Parametros:
    self
    Retorno: Retorna...
    *****************************************************"""
    def login(self):
        code = self.codeEntry.get()
        api = InstagramAPI(code)
        raw = api.call_resource('users', 'info', user_id='self')
        data = raw['data']
        self.newWindow = Toplevel(self.parent)
        global GlobalID
        GlobalID = data['id']
        p = Profile(self.newWindow,api,data['id'])
开发者ID:ncyrcus,项目名称:tareas-lp,代码行数:60,代码来源:gui.py

示例13: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
	def initUI(self):
		self.parent.title("Kinect Controlled Quadcopter")
		self.style = Style()
		self.style.theme_use("default")
		frame = Frame(self, relief=RAISED, borderwidth=1)
		frame.pack(fill=BOTH, expand=True)
		self.pack(fill=BOTH, expand=True)
		run_button = Button(self, text="Run", command = self.openFile)
		run_button.pack(side=RIGHT)
开发者ID:ZakiChammaa,项目名称:KinectControlledQuadcpter,代码行数:11,代码来源:gui.py

示例14: initUI

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def initUI(self):
        
        self.parent.title("Team 604 Scouting App - ver. 0.2")
        
        self.style = Style()
        self.style.theme_use("default")
        
        
        
        frame1 = Frame(self, 
                       relief=RAISED, 
                       borderwidth=1)
        frame1.pack(fill=NONE,
                    expand=1)
        
        #Key Functions
        
        dataPopulationButton = Button(self, 
                                      te1xt="Data Population",
                                      command=Data_Population, 
                                      width=12)   
        dataPopulationButton.pack()
        
        teamLookupButton = Button(self,
                                  text="Export",    # Export module needs to be made 
                                  width=12)           
        teamLookupButton.pack()
        
        teamRankingButton = Button(self, 
                                   text="Team Ranking",
                                   command=Team_Ranking,  
                                   width=12)         
        teamRankingButton.pack()
        
        teamEntryDeletionButton = Button(self,
                                         text="Match Deletion",
                                         width=12)    #TODO: Make TeamEntryDeletion GUI
        teamEntryDeletionButton.pack()
        #Formatting to look pretty

        frame2 = Frame(self, 
                       relief=RAISED, 
                       borderwidth=1)
        frame2.pack(fill=NONE, 
                    expand =1)
        
        
        quitButton = Button(self,
                            text="Quit", 
                            command=self.quit)
        quitButton.pack(side=RIGHT, 
                        padx=15, 
                        pady=5)             #TODO: Fix Button placement  

        self.pack(fill=BOTH, 
                  expand=1)
开发者ID:frc604,项目名称:scouting-2014-deprecated,代码行数:58,代码来源:ScoutingWrapper_GUI.py

示例15: ventanaImprimir

# 需要导入模块: from ttk import Button [as 别名]
# 或者: from ttk.Button import pack [as 别名]
    def ventanaImprimir(self):
        t = Toplevel(self)
        t.wm_title("Imprimir")

        Label(t, text="Numero de Copias por etiqueta").pack()
        w = Spinbox(t, from_=1, to=10)
        w.pack()

        buttonImprimir = Button(t, text="Imprimir",  command=lambda:self.imprimir(int(w.get()),t))
        buttonImprimir.pack()
开发者ID:rached193,项目名称:Caritas,代码行数:12,代码来源:caritas.py


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