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


Python tkinter.Label方法代码示例

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


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

示例1: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, text="IPSUM DOLOREM", pos="BR"):
        self.text = text
        self.pos = pos
        self.fg = "black"
        self.bg = "#f1f2f2"  # default transparent color
        self.width = 0
        self.height = 0

        tk = tkinter.Tk()
        self.label = tkinter.Label(tk, anchor="w")
        self.label.config(font=("Consolas", 8))
        self.label.master.overrideredirect(True)
        self.label.master.lift()
        self.label.master.wm_attributes("-topmost", True)
        self.label.master.wm_attributes("-disabled", True)
        self.label.master.wm_attributes("-transparentcolor", "#f1f2f3")

        hWindow = pywintypes.HANDLE(int(self.label.master.frame(), 16))
        exStyle = win32con.WS_EX_COMPOSITED | win32con.WS_EX_LAYERED | win32con.WS_EX_NOACTIVATE | \
                  win32con.WS_EX_TOPMOST | win32con.WS_EX_TRANSPARENT
        win32api.SetWindowLong(hWindow, win32con.GWL_EXSTYLE, exStyle)

        self.label.pack()
        self.update() 
开发者ID:CharlesDankoff,项目名称:ultra_secret_scripts,代码行数:26,代码来源:overlay_label.py

示例2: popup

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def popup(self, window, title, image, text, button_text, end_command=None):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)

        def run_end():
            popup.destroy()
            if end_command != None:
                end_command()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
        tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
开发者ID:nimaid,项目名称:LPHK,代码行数:27,代码来源:window.py

示例3: video_invite_window

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def video_invite_window(message, inviter_name):
    invite_window = tkinter.Toplevel()
    invite_window.geometry('300x100')
    invite_window.title('Invitation')
    label1 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text=inviter_name)
    label1.pack()
    label2 = tkinter.Label(invite_window, bg='#f0f0f0', width=20, text='invites you to video chat!')
    label2.pack()

    def accept_invite():
        invite_window.destroy()
        video_accept(message[message.index('INVITE') + 6:])

    def refuse_invite():
        invite_window.destroy()

    Refuse = tkinter.Button(invite_window, text="Refuse", command=refuse_invite)
    Refuse.place(x=60, y=60, width=60, height=25)
    Accept = tkinter.Button(invite_window, text="Accept", command=accept_invite)
    Accept.place(x=180, y=60, width=60, height=25) 
开发者ID:11ze,项目名称:The-chat-room,代码行数:22,代码来源:client-test2.py

示例4: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, master=None, store_name=None, **kwargs):
        super(FileBrowse, self).__init__(master=master, **kwargs)
        self.label_text = tk.StringVar()
        btn = tk.Button(self, text="下载到", command=self.choose_file)
        btn.pack(
            side=tk.LEFT,
        )

        tk.Label(self, textvariable=self.label_text).pack(
            side=tk.LEFT,
            fill=tk.X,
        )
        self.pack(fill=tk.X)

        self._store_name = store_name
        if store_name is not None:
            self._config = config_store
            save_path = self._config.op_read_path(store_name) or get_working_dir()
        else:
            self._config = None
            save_path = get_working_dir()

        self.label_text.set(
            save_path
        ) 
开发者ID:winkidney,项目名称:PickTrue,代码行数:27,代码来源:toolkit.py

示例5: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self):
        super().__init__()
        self.title("Hello Tkinter")
        self.label_text = tk.StringVar()
        self.label_text.set("My Name Is: ")

        self.name_text = tk.StringVar()

        self.label = tk.Label(self, textvar=self.label_text)
        self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=10)

        self.name_entry = tk.Entry(self, textvar=self.name_text)
        self.name_entry.pack(fill=tk.BOTH, expand=1, padx=20, pady=20)

        hello_button = tk.Button(self, text="Say Hello", command=self.say_hello)
        hello_button.pack(side=tk.LEFT, padx=(20, 0), pady=(0, 20))

        goodbye_button = tk.Button(self, text="Say Goodbye", command=self.say_goodbye)
        goodbye_button.pack(side=tk.RIGHT, padx=(0, 20), pady=(0, 20)) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Programming-by-Example,代码行数:21,代码来源:ch1-6.py

示例6: build

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def build(self, property_dict):
        for c in self.interior.winfo_children():
            c.destroy()


        # Filter property dict
        property_dict = {k: v for k, v in property_dict.items()
                         if self._key_filter_function(k)}

        # Prettify key/value pairs for display
        property_dict = {self._make_key_pretty(k): self._make_value_pretty(v)
                            for k, v in property_dict.items()}

        # Sort by key and filter
        dict_values = sorted(property_dict.items(), key=lambda x: x[0])

        for n,(k,v) in enumerate(dict_values):
            tk.Label(self.interior, text=k, borderwidth=1, relief=tk.SOLID,
                wraplength=75, anchor=tk.E, justify=tk.RIGHT).grid(
                row=n, column=0, sticky='nesw', padx=1, pady=1, ipadx=1)
            tk.Label(self.interior, text=v, borderwidth=1,
                wraplength=125, anchor=tk.W, justify=tk.LEFT).grid(
                row=n, column=1, sticky='nesw', padx=1, pady=1, ipadx=1) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:25,代码来源:viewer.py

示例7: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, main_window, msg='Please enter a node:'):
        tk.Toplevel.__init__(self)
        self.main_window = main_window
        self.title('Node Entry')
        self.geometry('170x160')
        self.rowconfigure(3, weight=1)

        tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2,
                                      sticky='NESW',padx=5,pady=5)
        self.posibilities = [d['dataG_id'] for n,d in
                    main_window.canvas.dispG.nodes_iter(data=True)]
        self.entry = AutocompleteEntry(self.posibilities, self)
        self.entry.bind('<Return>', lambda e: self.destroy(), add='+')
        self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5)

        tk.Button(self, text='Ok', command=self.destroy).grid(
            row=3, column=0, sticky='ESW',padx=5,pady=5)
        tk.Button(self, text='Cancel', command=self.cancel).grid(
            row=3, column=1, sticky='ESW',padx=5,pady=5)

        # Make modal
        self.winfo_toplevel().wait_window(self) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:24,代码来源:viewer.py

示例8: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, image, initialField, initialText):
        frm = tk.Frame(root)
        frm.config(background="white")
        self.image = tk.PhotoImage(format='gif',data=images[image.upper()])
        self.imageDimmed = tk.PhotoImage(format='gif',data=images[image])
        self.img = tk.Label(frm)
        self.img.config(borderwidth=0)
        self.img.pack(side = "left")
        self.fld = tk.Text(frm, **fieldParams)
        self.initScrollText(frm,self.fld,initialField)
        frm = tk.Frame(root)
        self.txt = tk.Text(frm, **textParams)
        self.initScrollText(frm,self.txt,initialText)
        for i in range(2):
            self.txt.tag_config(colors[i], background = colors[i])
            self.txt.tag_config("emph"+colors[i], foreground = emphColors[i]) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:18,代码来源:nemo_app.py

示例9: updateImageCount

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def updateImageCount(happyCount, sadCount):
    global HCount, SCount, imageCountString, countString   # Updating only when called by smileCallback/noSmileCallback
    if happyCount is True and HCount < 400:
        HCount += 1
    if sadCount is True and SCount < 400:
        SCount += 1
    if HCount == 400 or SCount == 400:
        HCount = 0
        SCount = 0
    # --- Updating Labels
    # -- Main Count
    imageCountPercentage = str(float((trainer.index + 1) * 0.25)) \
        if trainer.index+1 < len(faces.images) else "Classification DONE! 100"
    imageCountString = "Image Index: " + str(trainer.index+1) + "/400   " + "[" + imageCountPercentage + " %]"
    labelVar.set(imageCountString)           # Updating the Label (ImageCount)
    # -- Individual Counts
    countString = "(Happy: " + str(HCount) + "   " + "Sad: " + str(SCount) + ")\n"
    countVar.set(countString) 
开发者ID:its-izhar,项目名称:Emotion-Recognition-Using-SVMs,代码行数:20,代码来源:Emotion Recognition.py

示例10: ShowMol

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def ShowMol(mol, size=(300, 300), kekulize=True, wedgeBonds=True, title='RDKit Molecule', **kwargs):
    """ Generates a picture of a molecule and displays it in a Tkinter window
    """
    global tkRoot, tkLabel, tkPI
    try:
        import Tkinter
    except ImportError:
        import tkinter as Tkinter
    try:
        import ImageTk
    except ImportError:
        from PIL import ImageTk

    img = MolToImage(mol, size, kekulize, wedgeBonds, **kwargs)

    if not tkRoot:
        tkRoot = Tkinter.Tk()
        tkRoot.title(title)
        tkPI = ImageTk.PhotoImage(img)
        tkLabel = Tkinter.Label(tkRoot, image=tkPI)
        tkLabel.place(x=0, y=0, width=img.size[0], height=img.size[1])
    else:
        tkPI.paste(img)
    tkRoot.geometry('%dx%d' % (img.size)) 
开发者ID:blackmints,项目名称:3DGCN,代码行数:26,代码来源:__init__.py

示例11: add_attr

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def add_attr(self, attr_name, right_label_text=None, *args):
        '''Add attr to the lower frame with a '-' button & title
        
        attr_name: title to be shown on the left side
        right_label_text: label string to be shown on the right side, which is
                          a word count or 'Calculating...'
        '''
        if len(self.attrs) == 0:
            self.lower_frame = Frame(self)
            self.lower_frame.pack(side="bottom", fill="both")
        attr = LabeledFrame(self.lower_frame, title=attr_name)
        btn_add_file = Tk.Button(attr, text=' - ')
        btn_add_file.pack(fill="both", side="left", padx=10, pady=5)
        btn_add_file.bind("<ButtonRelease-1>", partial(self.on_remove_attr, attr))
        lb_base_files = Tk.Label(attr, text=attr_name)
        lb_base_files.pack(fill="both", side="left", padx=10, pady=10)
        
        if right_label_text is not None:
            attr.right_label = Tk.Label(attr, text=right_label_text, font=('Helvetica', '10', 'italic'))
            attr.right_label.pack(fill="both", side="right", padx=10, pady=10)
        else:
            attr.right_label = None
        
        attr.pack(side="top", fill="both")
        self.attrs.append(attr) 
开发者ID:sc0tfree,项目名称:mentalist,代码行数:27,代码来源:base.py

示例12: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, root, resource_dir, lang="fr"):
        ttk.Frame.__init__(self, root)
        
        self.resource_dir = resource_dir
        self._lang = None
        langs = os.listdir(os.path.join(self.resource_dir, "master"))
        if langs:
            self._lang = (lang if lang in langs else langs[0])
        
        self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
        self.items.sort(key=lambda x: x.lower())
        max_length = max([len(item) for item in self.items])
        
        self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
        #strVar = tkinter.StringVar()
        self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)

        for item in self.items:
            self.masters.insert(tkinter.END, item) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:21,代码来源:components.py

示例13: draw_board

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def draw_board(self, board):
        self.piece_images.clear()
        self.move_images = []
        pieces = board.pieces
        for (x, y) in pieces.keys():
            self.piece_images[x, y] = tkinter.PhotoImage(file=pieces[x, y].get_image_file_name())
            self.can.create_image(board_coord(x), board_coord(y), image=self.piece_images[x, y])
        if board.selected_piece:
            for (x, y) in board.selected_piece.get_move_locs(board):
                self.move_images.append(tkinter.PhotoImage(file="images/OOS.gif"))
                self.can.create_image(board_coord(x), board_coord(y), image=self.move_images[-1])
                # self.can.create_text(board_coord(x), board_coord(y),text="Hello")

        # label = tkinter.Label(self.root, text='Hello world!')
        # label.place(x=30,y=30)
        # label.pack(fill='x', expand=1) 
开发者ID:chengstone,项目名称:cchess-zero,代码行数:18,代码来源:ChessView.py

示例14: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def __init__(self, loginQueue):
        tk.Toplevel.__init__(self)
        
        self.configure(pady=10, padx=20)
        
        self.wm_attributes("-topmost", True)
        self.wm_title("PyEveLiveDPS Awaiting Login")
        try:
            self.iconbitmap(sys._MEIPASS + '\\app.ico')
        except Exception:
            try:
                self.iconbitmap("app.ico")
            except Exception:
                pass
        self.geometry("200x50")
        self.update_idletasks()
            
        tk.Label(self, text='Waiting for you to login...').grid(row=1, column=1)

        self.loginStatus = loginQueue.get()

        self.destroy() 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:24,代码来源:fleetConnectionWindow.py

示例15: addLine

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Label [as 别名]
def addLine(self, settingsList, dpsFrame):
        lineNumber = len(settingsList)
        settingsList.append({"transitionValue": "", "color": "#FFFFFF"})
        settingsList[lineNumber]["transitionValue"] = tk.StringVar()
        settingsList[lineNumber]["transitionValue"].set(str(100*lineNumber))
              
        removeButton = tk.Button(dpsFrame, text="X", command=lambda:self.removeLine(lineNumber, settingsList, dpsFrame))
        font = tkFont.Font(font=removeButton['font'])
        font.config(weight='bold')
        removeButton['font'] = font
        removeButton.grid(row=lineNumber, column="0")
        lineLabel = tk.Label(dpsFrame, text="Threshold when the line changes color:")
        lineLabel.grid(row=lineNumber, column="1")
        initialThreshold = tk.Entry(dpsFrame, textvariable=settingsList[lineNumber]["transitionValue"], width=10)
        initialThreshold.grid(row=lineNumber, column="2")
        initialLabel = tk.Label(dpsFrame, text="Color:")
        initialLabel.grid(row=lineNumber, column="3")
        colorButton = tk.Button(dpsFrame, text="    ", 
                                command=lambda:self.colorWindow(settingsList[lineNumber], colorButton), 
                                bg=settingsList[lineNumber]["color"])
        colorButton.grid(row=lineNumber, column="4") 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:23,代码来源:lineSettingsFrame.py


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