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


Python Label.config方法代码示例

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


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

示例1: initUI

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

示例2: __makeWidgets

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

示例3: Remove_Machine_Modal

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class Remove_Machine_Modal(Modal):
	def __init__(self, parent=None, title="Remove Machine"):
		Modal.__init__(self, parent, title, geometry="500x85" if system() == "Windows" else "395x70")

	def initialize(self):
		self.label = Label(self, font=("TkTextFont", 13), width=36)
		self.label.grid(row=0, column=0, padx=10, columnspan=2)

		cancel_button = Button(self, text="Cancel", width=20, command=self.cancel)
		self.bind("<Escape>", self.cancel)
		cancel_button.grid(row=1, column=0, pady=10, padx=5, sticky="W")

		ok_button = Button(self, text="OK", width=20, command=self.ok)
		self.bind("<Return>", self.ok)
		ok_button.grid(row=1, column=1, pady=10, sticky="E")

	def ok(self, event=None):
		self.remove = True
		self.destroy()

	def cancel(self, event=None):
		self.remove = False
		self.destroy()

	def show(self, machine_name):
		self.label.config(text="Remove " + machine_name + "?")
		Modal.show(self)
		return self.remove
开发者ID:nalexander50,项目名称:MCRC-JSON-Creator,代码行数:30,代码来源:Remove_Machine_Modal.py

示例4: SlideShow

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

示例5: set_label

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
 def set_label(self, name, text='', side='left', width=0):
     if name not in self.labels:
         label = Label(self, borderwidth=0, anchor='w')
         label.pack(side=side, pady=0, padx=4)
         self.labels[name] = label
     else:
         label = self.labels[name]
     if width != 0:
         label.config(width=width)
     label.config(text=text)
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:12,代码来源:statusbar.py

示例6: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
    def __init__(self,parent,anchor,relief):
        """

        :param parent: fenetre root
        :param anchor: anchor
        :param relief: relief
        """
        for i in range(1,DIMENSION+1):
            label=Label(parent,text=i,anchor=anchor)
            label.config(borderwidth=0,width=2,height=2,relief=relief,bg="bisque")
            label.grid(row=i,column=3)
开发者ID:malikfassi,项目名称:draughts,代码行数:13,代码来源:draughtsGUI.py

示例7: StatusBar

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class StatusBar(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.label = Label(self, borderwidth=1, relief=SUNKEN, anchor=E)
        self.label.pack(fill=X)

    def set(self, format, *args):
        self.label.config(text=format % args)
        self.label.update_idletasks()

    def clear(self):
        self.label.config(text="")
        self.label.update_idletasks()
开发者ID:tarekauel,项目名称:umundo-java,代码行数:15,代码来源:statusbar.py

示例8: Image_

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

示例9: DatePicker

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class DatePicker(Frame):
    def __init__(self, root, output_list):
        super().__init__(root)
        self.root = root
        self.output_list = output_list
        self.month = datetime.date.today().month
        self.year = datetime.date.today().year
        self.buttons = {}
        for row in range(6):
            for col in range(7):
                b = Button(self)
                self.buttons[(row, col)] = b
                b.grid(row=row+1, column=col, sticky="EW")
        Button(self, text="<",
               command=lambda: self.change_month(-1)).grid(row=0, column=0)
        Button(self, text=">",
               command=lambda: self.change_month(1)).grid(row=0, column=6)
        self.label = Label(self)
        self.label.grid(row=0, column=1, columnspan=5)
        self.change_month(0)

    def change_month(self, delta):
        m = self.month + delta - 1
        self.month, self.year = m % 12 + 1, self.year + m // 12
        self.label.config(text="{} {}".format(calendar.month_name[self.month],
                                              self.year))
        self.update_buttons()

    def choose(self, day):
        self.output_list[:] = [self.year, self.month, day]
        self.root.destroy()

    def set_day(self, button, day):
        if day:
            button.config(text=str(day), command=lambda: self.choose(day),
                          state=NORMAL)
        else:
            button.config(text="", command=None, state=DISABLED)

    def update_buttons(self):
        c = calendar.Calendar(firstweekday=6)
        days = c.monthdayscalendar(self.year, self.month)
        for row in range(6):
            for col in range(7):
                try:
                    day = days[row][col]
                except IndexError:
                    day = 0
                self.set_day(self.buttons[(row, col)], day)
开发者ID:kalgynirae,项目名称:random,代码行数:51,代码来源:date_picker.py

示例10: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class App:
    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.new_madlib_button = Button(frame, text="New Madlib", command=self.new_madlib)
        self.new_madlib_button.pack(side=tkinter.LEFT)
        self.quit_button = Button(frame, text="QUIT", fg="red", command=frame.quit)
        self.quit_button.pack(side=tkinter.RIGHT)
        self.label = Label(root, text=Madlib().get_madlib())
        self.label.pack()

    def new_madlib(self):
        self.label.config(text=Madlib().get_madlib())
开发者ID:appletonmakerspace,项目名称:madlib,代码行数:17,代码来源:madlib_gui_client.py

示例11: TkTimerCore

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class TkTimerCore(TimerCore):
    def __init__(self, *args, title, font_size, **kwargs):
        def close_handler(event):
            self.close()
        def clicked_handler(event):
            self.interact()

        self.master = Tk()
        self.master.wm_title(title)
        self.master.bind('<Destroy>', close_handler)
        self.label = Label(self.master, font='Sans {}'.format(int(font_size)))
        self.label.pack(expand=True)

        self.control = Toplevel()
        self.control.wm_title(title + ' (control)')
        self.control.minsize(150, 150)
        self.control.bind('<Destroy>', close_handler)
        self.button = Button(self.control, text='Start/Pause')
        self.button.bind('<ButtonRelease>', clicked_handler)
        self.button.pack(expand=True)

        self.timeout_running = False

        super().__init__(*args, **kwargs)

    def start_timeout(self):
        assert self.timeout_running is False
        def timeout_call():
            if self.timeout_running:
                self.update()
                self.master.after(25, timeout_call)
        self.timeout_running = True
        timeout_call()

    def stop_timeout(self):
        assert self.timeout_running is True
        self.timeout_running = False

    def mainloop(self):
        return self.master.mainloop()

    def shutdown(self):
        self.master.quit()

    def set_label_text(self, text, finished=False):
        self.label.config(text=text)
        if finished:
            self.label.config(fg='red')
开发者ID:tifv,项目名称:jtimer,代码行数:50,代码来源:tk.py

示例12: Menu

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class Menu(Tk):
    def __init__(self):
        global FMagasin
        Tk.__init__(self)
        self.title('Donjon & Python')
        self.magasin = Magasin.Magasin(self)
        self.magasin.grid(row=0, column=0)
        Button(self, text='Jouer', command=self.play, height=2, width=20).grid(row=1, column=1)
        Button(self,text='Options', command=__main__.ouvrirOption, height=2, width=9).grid(row=1, column=2)
        self.framePerso = LabelFrame(self, text='Selection du personnage', width=30)
        self.framePerso.grid(row=0, column=1, columnspan=2)
        self.OR = Label(self, background='Yellow', height=2, width=70)
        self.OR.grid(row=1, column=0)
        self.majOR()
        self.remplirFramePerso()
    def run(self):
        Audio.playMusic('Rogue Legacy - Castle', -1)
        self.majPerso()
        self.mainloop()
        Sauvegarde.sauvegarder(__main__.savePath)
    def majPerso(self):
        for i in range(3):
            self.listeBox[i].maj()
    def majOR(self):
        self.OR.config(text="Pièce d'or : " + str(Magasin.OR))
    def remplirFramePerso(self):
        listePerso = GenerationPersonnage.genererPerso()
        self.listeBox = []
        for i in range(len(listePerso)):
            self.listeBox.append(BoxPerso(self.framePerso, listePerso[i], i))
            self.listeBox[i].pack()
    def play(self):
        if __main__.perso:
            Sauvegarde.sauvegarder(__main__.savePath)
            self.destroy()
            __main__.motGraph = MoteurGraphique()
            # try:    #Les thread entrainent parfois des problèmes d'inconsistance dans pygame
            __main__.motGraph.run()
            __main__.motGraph = None
开发者ID:Hugal31,项目名称:Donjon-Python,代码行数:41,代码来源:Menu.py

示例13: Amel

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class Amel(LabelFrame):
    def __init__(self, boss, nom, amelioration, maximum, prix, up, logo):
        """
        amelioration (str) : Nom de l'amélioration du bouton
        maximum (int) : Maximum de fois que l'on peut augmenter l'amélioration
        prix (int) : Prix de l'amélioration par niveau
        up (int) : Montant de point apporté par l'amélioration
        """
        global imagesMag
        self.amel = amelioration
        self.max = maximum
        self.prix = prix
        self.up = up
        LabelFrame.__init__(self,  boss)
        Label(self, image=imagesMag[logo]).pack(side=LEFT)
        Label(self, text=nom, width=18).pack(side=LEFT)
        self.button = Button(self, command=self.acheter, width = 6)
        self.level = Label(self, width=5)
        self.total = Label(self, width=11)
        self.total.pack(side=RIGHT)
        self.level.pack(side=RIGHT)
        self.button.pack(side=RIGHT)
        self.maj()
    def maj(self):
        global amel, stat
        self.button.config(text=(str((amel[self.amel]+1)*self.prix) + ' PO'))
        self.level.config(text=str(amel[self.amel]) + '/' + str(self.max))
        self.total.config(text='Total : ' + str(stat[self.amel]))
    def acheter(self):
        global stat, OR, amel
        if ((OR >= (amel[self.amel]+1)*self.prix) and (amel[self.amel] < self.max)):
            OR -= (amel[self.amel]+1)*self.prix   #A changer
            stat[self.amel] += self.up
            amel[self.amel] += 1
            self.maj()
            __main__.menu.majPerso()
            __main__.menu.majOR()
开发者ID:Hugal31,项目名称:Donjon-Python,代码行数:39,代码来源:Magasin.py

示例14: BoxPerso

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import config [as 别名]
class BoxPerso(LabelFrame):
    def __init__(self, boss, personnage, numero):
        LabelFrame.__init__(self, boss, text=personnage.type)
        self.pv = Label(self)
        self.pv.pack()
        self.atk = Label(self)
        self.atk.pack()
        self.deff = Label(self)
        self.deff.pack()
        self.critChc = Label(self)
        self.critChc.pack()
        Button(self, text='Choisir', command=self.choisir).pack()
        self.personnage = personnage
        self.maj()
    def maj(self):
        statObjet = {}
        statObjet['pv'] = 0
        statObjet['dmg'] = 0
        statObjet['deff'] = 0
        statObjet['critDmg'] = 0
        statObjet['critChc'] = 0
        statObjet['multOr'] = 0
        statObjet['mana'] = 0
        if __main__.menu :
            for typ in __main__.menu.magasin.listComboBox:
                if typ.get() != '':
                    for stat in typ.listObjets[typ.get()].stat: #On récupère les stats des objets sélectionnés
                        statObjet[stat] += typ.listObjets[typ.get()].stat[stat]
        self.personnage.majCarac(Magasin.stat['pv'] + statObjet['pv'],
                                 Magasin.stat['atk'] + statObjet['dmg'],
                                 Magasin.stat['deff'] + statObjet['deff'],
                                 Magasin.stat['critDmg'] + statObjet['critDmg'],
                                 Magasin.stat['critChc'] + statObjet['critChc'],
                                 Magasin.stat['multOR'] + statObjet['multOr'],
                                 Magasin.stat['mana'] + statObjet['mana'])
        self.pv.config(text='Pv : ' + str(self.personnage.pv), width=30)
        self.atk.config(text='Attaque : ' + str(self.personnage.atk))
        self.deff.config(text='Armure : ' + str(self.personnage.deff))
        self.critChc.config(text='Chance de critique : ' + str(self.personnage.critChc))
    def choisir(self):
        __main__.perso = self.personnage
开发者ID:Hugal31,项目名称:Donjon-Python,代码行数:43,代码来源:Menu.py

示例15: Optionmenu

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

	def __init__(self, parent_frame, x, y):
		Widget_.__init__(self, parent_frame, x, y)
		self.label_width = 15
		self.entry_width = 20
		self.options = []
		self.stringvar = StringVar()
		self.label = Label(self.widget_frame, width=self.label_width, anchor=E)
		self.combobox = ttk.Combobox(self.widget_frame,
			textvariable=self.stringvar,
			state='readonly'
			)
		self.label.pack(side=LEFT, padx=3)
		self.combobox.pack(side=LEFT)
		self.label_bg, self.label_fg, self.label_hover_bg, self.label_hover_fg = None, None, None, None
		self.entry_bg, self.entry_fg, self.entry_hover_bg, self.entry_hover_fg = None, None, None, None
		self.combobox_style = ttk.Style()
		self.combobox_style.configure(
			'TCombobox',
			background='white',
			selectbackground='white',
			selectforeground='black',
			borderwidth=0
			)
		self.combobox_style.map('TCombobox', fieldbackground=[])

	def settings(self, **kwargs):
		if 'label' in kwargs:
			self.label.config(text=kwargs['label'])
		if 'set_option' in kwargs:
			self.stringvar.set(kwargs['set_option'])
		if 'add_option' in kwargs:
			if type(kwargs['add_option']) == list:
				self.options.extend(kwargs['add_option'])
			elif type(kwargs['add_option']) == str:
				self.options.append(kwargs['add_option'])
			self.combobox['values'] = tuple(self.options)
		if 'font' in kwargs:
			self.combobox.config(font=kwargs['font'])
		if 'label_bg' in kwargs:
			self.label_bg = kwargs['label_bg']
			self.label.config(bg=self.label_bg)
		if 'label_fg' in kwargs:
			self.label_fg = kwargs['label_fg']
			self.label.config(fg=self.label_fg)


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


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