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


Python Label.pack方法代码示例

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


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

示例1: show_captcha

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
    def show_captcha(self,img_file):
        dialogRoot = Tk()
        dialogRoot.title("Input text.")
    
        img = PhotoImage(file=img_file)
    
        frame = Frame(dialogRoot)
    
        imal = Label(frame, image=img)
        imal.pack()
    
        label = Label(frame)
        label['text'] = "Your Input:"
        label.pack(side=LEFT)
    
        inputEntry = Entry(frame)
        inputEntry["width"] = 50
        inputEntry.pack(side=LEFT)
    
        def getInputText():
            '''callback of button'''
            # global inputEntry, dialogRoot
            if inputEntry.get().strip() == "":
                print("Please enter a message.")
            else:
                self.captcha_ans = inputEntry.get().strip()
                dialogRoot.destroy()

    
        button = Button(frame, text="Submit", command=getInputText)
        button.pack(side=LEFT)
    
        frame.pack()
        dialogRoot.mainloop()
开发者ID:fscnick,项目名称:RapidgatorDownloader,代码行数:36,代码来源:OtherUtility.py

示例2: GuiGenerateCount

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class GuiGenerateCount(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack()
        
        #step increment len
        self._stepLenFrm  = Frame(self); self._stepLenFrm.pack()
        self._stepLenLbl  = Label(self._stepLenFrm, text="Step Len: ");   self._stepLenLbl.pack(side=LEFT)
        self._stepLenSpin = Spinbox(self._stepLenFrm, from_=0, to=1000); self._stepLenSpin.pack(side=LEFT)
        
        #start value
        self._startFrm  = Frame(self); self._startFrm.pack()
        self._startLbl  = Label(self._startFrm, text="Start Value: ");   self._startLbl.pack(side=LEFT)
        self._startTxt  = Entry(self._startFrm);   self._startTxt.pack(side=LEFT)
        self._startTxt.insert(0, "0")
        
    def getSettings(self):
        return  {   "StepLen":      self._stepLenSpin.get(),
                    "StartValue":   self._startTxt.get()
                }
    
    def getName(self):
        return "Counter"
        
    def getGeneratorFunction(self):
        return generateCounter
开发者ID:awaken1988,项目名称:pyTools,代码行数:29,代码来源:tas_bytegenerator.py

示例3: main

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
def main(argv):
    ct.windll.shell32.SetCurrentProcessExplicitAppUserModelID(APPID+str(time.time()))
    root = Tk()
    label = Label(root)
    label.pack()
    tb_icon = tktools.TaskbarIcon(root)
    
    total = int(argv[1])
    current = [0]
    
    timer = TkTimer(widget=root, interval=1000)
    
    @timer.add_observer
    def show_left():
        current[0] += 1
        percent = int(current[0] / total * 100)
        tb_icon.progress = percent
        label['text'] = '{} seconds left.'.format(total-current[0])
        if 0 <= percent <= 50:
            state = TBPFLAG.TBPF_NORMAL
        elif 50 < percent <= 80:
            state = TBPFLAG.TBPF_PAUSED
        else:
            state = TBPFLAG.TBPF_ERROR
        tb_icon.state = state
        if current[0] >= total:
            timer.active = False
            tb_icon.state = TBPFLAG.TBPF_NOPROGRESS
        
    timer.active = True
    root.mainloop()
开发者ID:xialulee,项目名称:WaveSyn,代码行数:33,代码来源:sandglass.py

示例4: MainWindow

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class MainWindow(Frame):
    def createWidgets(self):
        self.nameLabel = Label(self, text="What's your name:")
        self.nameLabel.pack(side='top')
        
        self.nameInput = EntryTextHolder(self)
        self.nameInput.pack(side='top', fill='x', expand=True)
        
        self.helloLabel = LabelTextHolder(self)
        self.helloLabel.pack(side='top')
        
        self.sayHelloButton = Button(self, text="Say Hello")
        self.sayHelloButton.pack(side='right')
        self.sayHelloButton['command'] = self.model.say_hello
        
        self.randomNameButton = Button(self, text="Random Name")
        self.randomNameButton.pack(side='right')
        self.randomNameButton['command'] = self.model.select_random_name
    
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.model = MainWindowModel()        
        self.pack()
        self.createWidgets()
        self.model.set_children(self.nameInput.model, self.helloLabel.model)
开发者ID:daleathan,项目名称:guiskel,代码行数:27,代码来源:mainwindow.py

示例5: body

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
    def body(self, master):
        if self.icon:
            label = Label(master, image=self.icon)
            label.pack(pady=10)

        if self.app_name:
            self.title('About ' + self.app_name)
            label = Label(master, text=self.app_name)
            modify_font(label, size=12, weight=BOLD)
            label.pack()

        if self.description:
            label = Label(master, text=self.description)
            modify_font(label, size=10)
            label.pack(pady=10)

        if self.copyright:
            label = Label(master, text=self.copyright)
            modify_font(label, size=8)
            label.pack()

        if self.website:
            label = Hyperlink(master, destination=self.website)
            modify_font(label, size=8)
            label.pack()
开发者ID:lfairy,项目名称:treasure-chest,代码行数:27,代码来源:tk_aboutbox.py

示例6: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class FileChooser:
    def __init__(self):
        self.filechooser = Tk()
        self.filechooser.geometry('500x500+0+0')
        self.button  = Button(self.filechooser,text="Add Directory",command=self.addDir)
        self.listview = Listbox(self.filechooser)
        self.closebutton = Button(self.filechooser,text="Scan",command=self.Done)
        self.listview.pack(fill="both")
        self.button.pack(fill='x')
        helptext = """Select directories by pressing the "Add Directory" Button, then press Scan.
                        \n When the file tree appears, red text means the file or folder is a duplicate.
                        \n purple means the folder contains duplicates but itself is not a duplicate.
                        \n Double Click on red text entries to view matches"""
        self.instructions = Label(self.filechooser, text=helptext)
        self.instructions.pack(fill='both')
        self.closebutton.pack()


        self.filechooser.mainloop()
    def Done(self):
        self.filechooser.destroy()
    def addDir(self):
        dir = askdirectory()
        if os.path.isdir(dir):
            dirlist.append(dir)
            self.listview.insert('end',str(dir))
开发者ID:bretttjohnson1,项目名称:Duplicate_Discoverer,代码行数:28,代码来源:main.py

示例7: initUI

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

        self.parent.title("Text")        
        self.pack(fill=BOTH, side=LEFT)

        analysis = self.analysis

        avgSumStr = ("Average sum:      " + str(analysis.month.avg_sum))
        avgRevStr = ("Average revenue:  " + str(analysis.month.avg_rev))
        avgExpStr = ("Average expense:  " + str(analysis.month.avg_exp))

        medSumStr = ("Median sum:      " + str(analysis.month.med_sum))
        medRevStr = ("Median revenue:  " + str(analysis.month.med_rev))
        medExpStr = ("Median expense:  " + str(analysis.month.med_exp))

        curSumStr = ("Current sum:      " + str(analysis.current_month.sum))
        curRevStr = ("Current revenue:  " + str(analysis.current_month.rev))
        curExpStr = ("Current expense:  " + str(analysis.current_month.exp))

        superString = (avgSumStr
                +  "\n" + avgRevStr
                +  "\n" + avgExpStr

                +  "\n" + medSumStr
                +  "\n" + medRevStr
                +  "\n" + medExpStr

                +  "\n" + curSumStr
                +  "\n" + curRevStr
                +  "\n" + curExpStr
                )

        superLabel = Label(self, text=superString, anchor=W, justify=LEFT)
        superLabel.pack()
开发者ID:aJns,项目名称:tililoggeri,代码行数:36,代码来源:TextFrame.py

示例8: GuiGeneratorSelect

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class GuiGeneratorSelect(Frame):
    def __init__(self, parent, generators):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack()
        
        self._generators = generators
        self._generatorName = StringVar()
        self._generatorName.set(generators[0].getName())
        self._generatorName.trace("w", self._switchSettings)
        
        self._generatorLbl = Label(self, text="Generator");
        self._generatorLbl.pack(side=LEFT)
        
        param = (self, self._generatorName) + tuple(i.getName() for i in generators)
        self._generatorOpt = OptionMenu(*param)
        self._generatorOpt.pack(side=LEFT)
        
        
        self._switchSettings()
        
    def _switchSettings(self, *args):
       print("DBG: switch generator settings")
       for i in self._generators:
           if i.getName() == self._generatorName.get(): 
               i.pack()
               self._generatorGui = i
               print("pack " + str(i.getName()))
           else:
               i.pack_forget() 
               print("unpack " + str(i.getName()))
    
    def getCurrGeneratorGui(self):
        return self._generatorGui         
开发者ID:awaken1988,项目名称:pyTools,代码行数:36,代码来源:tas_bytegenerator.py

示例9: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class MyFirstGUI:
    LABEL_TEXT = [
        "This is our first GUI!",
        "Actually, this is our second GUI.",
        "We made it more interesting...",
        "...by making this label interactive.",
        "Go on, click on it again.",
    ]
    def __init__(self, master):
        self.master = master
        master.title("A simple GUI")

        self.label_index = 0
        self.label_text = StringVar()
        self.label_text.set(self.LABEL_TEXT[self.label_index])
        self.label = Label(master, textvariable=self.label_text)
        self.label.bind("<Button-1>", self.cycle_label_text)
        self.label.pack()

        self.greet_button = Button(master, text="Greet", command=self.greet)
        self.greet_button.pack()

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()

    def greet(self):
        print("Greetings!")

    def cycle_label_text(self, event):
        self.label_index += 1
        self.label_index %= len(self.LABEL_TEXT) # wrap around
        self.label_text.set(self.LABEL_TEXT[self.label_index])
开发者ID:gshkr123,项目名称:Python_Task,代码行数:34,代码来源:GUI-Lables.py

示例10: SlideShow

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class SlideShow(Tk):
    # inherit GUI framework extending tkinter
    def __init__(self, msShowTimeBetweenSlides=1500):
        # initialize tkinter super class
        Tk.__init__(self)
        
        # time each slide will be shown
        self.showTime = msShowTimeBetweenSlides
        
        # look for images in current working directory where this module lives
        listOfSlides = [slide for slide in listdir() if slide.endswith('gif')]

        # endlessly read in the slides so we can show them on the tkinter Label 
        self.iterableCycle = cycle((PhotoImage(file=slide), slide) for slide in listOfSlides)
        
        # create tkinter Label widget which can also display images
        self.slidesLabel = Label(self)
        
        # create the Frame widget
        self.slidesLabel.pack()
 
 
    def slidesCallback(self):
        # get next slide from iterable cycle
        currentInstance, nameOfSlide = next(self.iterableCycle)
        
        # assign next slide to Label widget
        self.slidesLabel.config(image=currentInstance)
        
        # update Window title with current slide
        self.title(nameOfSlide)
        
        # recursively repeat the Show
        self.after(self.showTime, self.slidesCallback)
开发者ID:xenron,项目名称:sandbox-dev-python,代码行数:36,代码来源:B04829_Ch10_SlideShow_PillowPrep.py

示例11: ua_win_tk

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
def ua_win_tk(url, pipe = None):
    from tkinter import Tk, Frame, Label, Entry, StringVar, BOTH, Button, RIGHT
    import sys
    sys.stdout.flush()
    instructions = "Visit the following URL to authorize the application:"
    response = {"x": False}
    root = Tk()
    root.title("oAuth2 Authorization Required")
    webbox = Frame(root)
    instructions = Label(webbox, text = instructions)
    instructions.pack(padx = 5, pady = 5)
    urlstr = StringVar(value = url)
    urlbox = Entry(webbox, textvariable = urlstr, state = "readonly")
    urlbox.pack(padx = 5, pady = 5)
    def open_browser():
        from subprocess import Popen
        p = Popen(["sensible-browser", url])
    browserbutton = Button(webbox, text = "Open in web browser", command = open_browser)
    browserbutton.pack(padx = 5, pady = 5)
    webbox.pack(fill = BOTH, expand = 1)
    if pipe:
        def poll():
            if pipe.poll():
                root.destroy()
                #Mutability ftw... wat
                response["x"] = True
            else:
                root.after(300, poll)
        root.after(300, poll)
    cancelbutton = Button(root, text = "Cancel", command = root.destroy)
    cancelbutton.pack(side = RIGHT, padx = 5, pady = 5)
    root.mainloop()
    return response["x"]
开发者ID:pyokagan,项目名称:pyoauth2client,代码行数:35,代码来源:ui.py

示例12: display_image

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
def display_image(title,image):
    win = Toplevel(root)
    photo = ImageTk.PhotoImage(image)
    win.title(title)
    label = Label(win,image=photo)
    label.image = photo #Kludge: keep a reference to avoid garbage collection!
    label.pack()
开发者ID:cmarch314,项目名称:PythonProjects,代码行数:9,代码来源:pildemo.py

示例13: initUI

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

示例14: Image_

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
class Image_(Widget_):

	def __init__(self, parent_frame, x, y):
		Widget_.__init__(self, parent_frame, x, y)
		self.label = Label(self.widget_frame)
		self.label.pack()
		self.label_bg, self.label_fg = None, None

	#def get_(self):
	#	return self.picture

	def get_info(self):
		return self.label.cget('text')

	def settings(self, **kwargs):
		''' all setting changes '''
		
		if 'label_bg' in kwargs:
			self.label.config(bg=kwargs['label_bg'])
		if 'label_fg' in kwargs:
			self.label.config(fg=kwargs['label_fg'])
		if 'image' in kwargs:
			self.img_path = kwargs['image']
			self.picture = Image.open(self.img_path)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)
		if 'resize' in kwargs:
			self.picture = self.picture.resize(kwargs['resize'], Image.ANTIALIAS)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)
		return
开发者ID:wasifzaman,项目名称:Project-RYB,代码行数:33,代码来源:image.py

示例15: __makeWidgets

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import pack [as 别名]
 def __makeWidgets(self):
     Label(self, text="Welcome to PyMath 0.3!\n", justify="center").pack()
     Label(self, text="Use the tabs to navigate between PyMath's different functions.", justify="center").pack()
     l = Label(self, text="About/Help", fg="blue", padx=10, pady=10)
     l.pack(side=BOTTOM, anchor=SE)
     l.config(cursor="hand2")
     l.bind("<Button-1>", self.showabout)
开发者ID:BookOwl,项目名称:pymath,代码行数:9,代码来源:welcomeWidget.py


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