Python tkinter.Label() Examples

The following are 30 code examples of tkinter.Label(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter , or try the search function .
Example #1
Source File: annotation_gui.py    From SEM with MIT License 9 votes vote down vote up
def preferences(self, event=None):
        preferenceTop = tkinter.Toplevel()
        preferenceTop.focus_set()
        
        notebook = ttk.Notebook(preferenceTop)
        
        frame1 = ttk.Frame(notebook)
        notebook.add(frame1, text='general')
        frame2 = ttk.Frame(notebook)
        notebook.add(frame2, text='shortcuts')

        c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word)
        c.pack()
        
        shortcuts_vars = []
        shortcuts_gui = []
        cur_row = 0
        j = -1
        frame_list = []
        frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts"))
        frame_list[-1].pack(fill="both", expand="yes")
        for i, shortcut in enumerate(self.shortcuts):
            j += 1
            key, cmd, bindings = shortcut
            name, command = cmd
            shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key))
            tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W)
            entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j])
            entry.grid(row=cur_row, column=1)
            cur_row += 1
        notebook.pack()
    
    #
    # ? menu methods
    # 
Example #2
Source File: window.py    From LPHK with GNU General Public License v3.0 8 votes vote down vote up
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() 
Example #3
Source File: components.py    From SEM with MIT License 8 votes vote down vote up
def __init__(self, root, resource_dir):
        ttk.Frame.__init__(self, root)
        
        self.master_selector = None
        self.resource_dir = resource_dir
        self.items = os.listdir(os.path.join(self.resource_dir, "master"))
        
        self.cur_lang = tkinter.StringVar()
        self.select_lang_label = ttk.Label(root, text=u"select language:")
        self.langs = ttk.Combobox(root, textvariable=self.cur_lang)
        
        self.langs["values"] = self.items

        self.langs.current(0)
        for i, item in enumerate(self.items):
            if item == "fr":
                self.langs.current(i)
        
        self.langs.bind("<<ComboboxSelected>>", self.select_lang) 
Example #4
Source File: overlay_label.py    From ultra_secret_scripts with GNU General Public License v3.0 7 votes vote down vote up
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() 
Example #5
Source File: viewer.py    From networkx_viewer with GNU General Public License v3.0 7 votes vote down vote up
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) 
Example #6
Source File: labelSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, parent=None, title="", decimalPlaces=0, inThousands=0, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        gridFrame = self._nametowidget(parent.winfo_parent())
        self.parent = self._nametowidget(gridFrame.winfo_parent())
        
        self.grid(row="0", column="0", sticky="ew")
        self.columnconfigure(0,weight=1)
        self.singleLabel = singleLabel = tk.Label(self, text=title)
        singleLabel.grid(row="0",column="0", sticky="ew")
        self.listbox = listbox = tk.Spinbox(self, from_=0, to=9, width=1, borderwidth=1, highlightthickness=0)
        listbox.delete(0,tk.END)
        listbox.insert(0,decimalPlaces)
        listbox.grid(row="0", column="1")
        checkboxValue = tk.IntVar()
        checkboxValue.set(inThousands)
        self.checkbox = checkbox = tk.Checkbutton(self, text="K", variable=checkboxValue, borderwidth=0, highlightthickness=0)
        checkbox.var = checkboxValue
        checkbox.grid(row="0", column="2")
        singleLabel.bind("<Button-1>", lambda e:self.dragStart(e, listbox, checkbox)) 
Example #7
Source File: fleetConnectionWindow.py    From PyEveLiveDPS with GNU General Public License v3.0 7 votes vote down vote up
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() 
Example #8
Source File: ch1-6.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
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)) 
Example #9
Source File: toolkit.py    From PickTrue with MIT License 6 votes vote down vote up
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
        ) 
Example #10
Source File: labelSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, mainWindow, **kwargs):
        tk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent
        self.mainWindow = mainWindow
        self.columnconfigure(2, weight=1)
        
        self.gridColumns = settings.getLabelColumns()
        self.labels = settings.getLabels()
        
        tk.Label(self, text="Labels on the left grid will be attached to the left side of the window.\n" +
                    "Labels on the right grid will be attached to the right side of the window.\n\n" + 
                    "You can drag and drop labels to move them to a different position in the grid."
                    ).grid(row="0", column="1", columnspan="5", pady=10)
        tk.Label(self, text="Use the arrows to move columns from one side of the window to another."
                    ).grid(row="3", column="1", columnspan="5")
        tk.Label(self, text="The number box represents how many decimal places the label will use. 0 is no decimal places.\n" +
                    "The checkbox is to represent the number in thousands.\n\n" +
                    "For instance, if you choose '3' decimals, and check the box, the number 1,234 will show as 1.234K"
                    ).grid(row="100", column="1", columnspan="5", pady=10)
        
        tk.Frame(self, height="1", width="10").grid(row="1",column="2")
        
        self.makeArrowButtons()
        
        self.makeGrids() 
Example #11
Source File: client.py    From The-chat-room with MIT License 6 votes vote down vote up
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) 
Example #12
Source File: lineSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 6 votes vote down vote up
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") 
Example #13
Source File: client-test2.py    From The-chat-room with MIT License 6 votes vote down vote up
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) 
Example #14
Source File: client-test.py    From The-chat-room with MIT License 6 votes vote down vote up
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) 
Example #15
Source File: window.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def popup_choice(self, window, title, image, text, choices):
        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(func):
            popup.destroy()
            if func != None:
                func()

        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, columnspan=len(choices), padx=10, pady=10)
        for idx, choice in enumerate(choices):
            run_end_func = partial(run_end, choice[1])
            tk.Button(popup, text=choice[0], command=run_end_func).grid(column=1 + idx, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #16
Source File: simulationWindow.py    From PyEveLiveDPS with GNU General Public License v3.0 6 votes vote down vote up
def addRow(self, prefix, row):
        self.values[prefix] = {}
        self.values[prefix]["floor"] = tk.Entry(self.innerFrame, width=7)
        self.values[prefix]["floor"].grid(row=row, column="1")
        self.values[prefix]["floor"].insert(0, "0")
        tk.Label(self.innerFrame, text="-").grid(row=row, column="2")
        self.values[prefix]["ceiling"] = tk.Entry(self.innerFrame, width=7)
        self.values[prefix]["ceiling"].grid(row=row, column="3")
        self.values[prefix]["ceiling"].insert(0, "100")
        tk.Label(self.innerFrame, text="  every").grid(row=row, column="4")
        self.values[prefix]["cycle"] = tk.Entry(self.innerFrame, width=4)
        self.values[prefix]["cycle"].grid(row=row, column="5")
        self.values[prefix]["cycle"].insert(0, "3")
        tk.Label(self.innerFrame, text="s  ").grid(row=row, column="6")
        self.geometry("%sx%s" % (self.winfo_width(), self.winfo_height()+20))
        self.update_idletasks() 
Example #17
Source File: ChessView.py    From cchess-zero with MIT License 6 votes vote down vote up
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) 
Example #18
Source File: components.py    From SEM with MIT License 6 votes vote down vote up
def __init__(self, root, main_window, button_opt):
        ttk.Frame.__init__(self, root)
        
        self.root = root
        self.main_window = main_window
        self.current_files = None
        self.button_opt = button_opt
        
        # define options for opening or saving a file
        self.file_opt = options = {}
        options['defaultextension'] = '.txt'
        options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
        options['initialdir'] = os.path.expanduser("~")
        options['parent'] = root
        options['title'] = 'Select files to annotate.'
        
        self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames)
        self.label = ttk.Label(self.root, text=u"selected file(s):")
        self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif"))
        self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT)
        
        self.scrollbar = ttk.Scrollbar(self.root)
        self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.selected_files.yview) 
Example #19
Source File: nemo_app.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
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]) 
Example #20
Source File: Emotion Recognition.py    From Emotion-Recognition-Using-SVMs with MIT License 6 votes vote down vote up
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) 
Example #21
Source File: __init__.py    From 3DGCN with MIT License 6 votes vote down vote up
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)) 
Example #22
Source File: base.py    From mentalist with MIT License 6 votes vote down vote up
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) 
Example #23
Source File: fc_clean.py    From fastclass with Apache License 2.0 5 votes vote down vote up
def setup(self):
        self.Canvas = tk.Label(self)
        self.Canvas.grid(row=0, column=0, columnspan=6, rowspan=6)
        ttk.Button(self, text="Prev", command=self.display_prev).grid(row=4, column=6)
        ttk.Button(self, text="Next", command=self.display_next).grid(row=4, column=7)
        ttk.Button(self, text="Save & Exit", command=self.save_and_exit).grid(
            row=5, column=6, columnspan=2
        )

        self.lfdata = ttk.Labelframe(self, padding=(2, 2, 4, 4), text="Selection")
        self.lfdata.grid(row=0, column=6, columnspan=2, sticky="ne")
        for i, item in enumerate(digits + "d"):
            ttk.Button(
                self.lfdata, text=item, command=partial(self.button_callback, item)
            ).grid(in_=self.lfdata, column=6 + i % 2, row=i // 2, sticky="w") 
Example #24
Source File: adder.py    From mentalist with MIT License 5 votes vote down vote up
def open_special_dlg(self):
        '''Open a popup for selecting special characters
        '''
        self.special_dlg = Tk.Toplevel()
        self.special_dlg.withdraw()
        self.special_dlg.title('Select Special Characters')
        self.special_dlg.resizable(width=False, height=False)
        frame = Tk.Frame(self.special_dlg)
        lb = Tk.Label(frame, text='Select Special Characters'.format(self.title))
        lb.pack(fill='both', side='top')

        box = Tk.Frame(frame)
        self.chk_special = []
        max_column_checks = 15
        for v, val in enumerate(SPECIAL_CHARACTERS):
            var = Tk.IntVar()
            tmp = Tk.Checkbutton(box, text=val, relief=Tk.FLAT, variable=var)
            self.chk_special.append(var)
            tmp.grid(row=v % max_column_checks, column=v // max_column_checks,
                     sticky='W', padx=10)
        box.pack(fill='both', side='top', padx=30, pady=20)

        # Ok and Cancel buttons
        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_special)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=self.on_ok_special_dlg)
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        frame.pack(fill='both', padx=60, pady=10)
        
        center_window(self.special_dlg, self.main.master)
        self.special_dlg.focus_set() 
Example #25
Source File: base.py    From mentalist with MIT License 5 votes vote down vote up
def __init__(self, controller, master=None, main=None, title='Title', right_label_text=None, allow_remove=True, number=1, **kwargs):
        '''
        controller: a mentalist.controller.Controller instance
        master: the tkinter master of this view
        main: a mentalist.view.Main instance
        title: the title string to be displayed for this node
        right_label_text: an optional string to be displayed on the right-hand
                          side (word count)
        allow_remove: False if attempting to remove this node gives an error message
        number: an integer starting with 1 identifying this node's position in the chain
        '''
        Frame.__init__(self, master=master, **kwargs)
        self.controller = controller
        self.title = title
        self.main = main
        self.attrs = []
        self.number = number
        self.allow_remove = allow_remove
        self.configure(borderwidth=1, relief=Tk.RAISED)
        self.upper_frame = Frame(self)
        self.upper_frame.configure(borderwidth=1, relief=Tk.RIDGE)
        self.lb_title = Tk.Label(self.upper_frame, text='{}. {}'.format(number, title))
        self.lb_title.pack(fill="both", side="left", padx=10, pady=10)
        
        if right_label_text is not None: # this is the right-justified word count label
            self.right_label = Tk.Label(self.upper_frame, text=right_label_text, font=('Helvetica', '10', 'italic'))
            self.right_label.pack(fill="both", side="right", padx=10, pady=10)
        else:
            self.right_label = None
        
        self.upper_frame.pack(side="top", fill="x", expand=1)
        self.lower_frame = Frame(self)
        self.lower_frame.pack(side="bottom", fill="both")
        self.add_upper_button()
        if self.allow_remove:
            self.add_remove_button()
        self.pack(side="top", fill="both", padx=2, pady=2) 
Example #26
Source File: base_words.py    From mentalist with MIT License 5 votes vote down vote up
def open_string_popup(self, type_):
        '''Custom string input popup window
        type_: the name to appear in labels ('Base Words')
        '''
        self.string_popup = Tk.Toplevel()
        self.string_popup.withdraw()
        self.string_popup.title('Input Custom String ({})'.format(type_))
        self.string_popup.resizable(width=False, height=False)
        frame = Tk.Frame(self.string_popup)
        lb = Tk.Label(frame, text='Input Custom String - {}'.format(self.title))
        lb.pack(fill='both', side='top')

        box = Tk.Frame(frame)
        lb1 = Tk.Label(box, text='String: ')
        lb1.pack(side='left', padx=5)
        self.entry_string = Tk.Entry(box, width=25)
        self.entry_string.pack(side='left')
        box.pack(fill='both', side='top', padx=30, pady=20)

        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_string_popup)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=partial(self.on_ok_string_popup, type_))
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        frame.pack(fill='both', padx=10, pady=10)
        
        center_window(self.string_popup, self.main.master)
        self.string_popup.focus_set() 
Example #27
Source File: map-creator.py    From rpg-text with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.variables = defaultdict(tk.StringVar)
        self.exits_var = [tk.IntVar() for i in range(4)]
        for var in self.exits_var:
            var.set(1)

        self.exits_frame = tk.Frame(self)
        self.form_entries = OrderedDict()
        self.form_labels = OrderedDict()
        self.form_exits = OrderedDict()
        self.form_entries_names = ('Location Name', 'Description', 'NPCs', 'Icon', "Submaps")
        self.exits_names = ('N', 'S', 'E', 'W')
        self.position_variable = tk.StringVar()
        self.position_variable.set('(0, 0)')
        self.position_label_lbl = tk.Label(self, text='Position : ')
        self.position_label = tk.Label(self, textvariable=self.position_variable)
        for entry in self.form_entries_names:
            self.form_labels[entry] = tk.Label(self, text=entry + ' :')
            if not entry == 'Description':
                self.form_entries[entry] = tk.Entry(self, textvariable=self.variables[entry], width=20)
            else:
                self.form_entries[entry] = tk.Text(self, width=20)
        for i, ext in enumerate(self.exits_names):
            self.form_exits[ext + '_label'] = tk.Label(self.exits_frame, text=ext + " :")
            self.form_exits[ext + '_checkbox'] = tk.Checkbutton(self.exits_frame, variable=self.exits_var[i])
        self.exits_label = tk.Label(self, text='Exits :')
        self.save_button = tk.Button(self, text='Save', command=self.save_btn)
        self.setup_ui() 
Example #28
Source File: tooltip.py    From brownie with MIT License 5 votes vote down vote up
def __init__(self, widget, text=None, textvariable=None):
        super().__init__(widget._root())
        label = tk.Label(self, text=text, textvariable=textvariable, font=(None, 10))
        label.pack()
        self.wm_overrideredirect(True)
        self.withdraw()
        self.kill = False
        self.widget = widget
        widget.bind("<Enter>", self.enter) 
Example #29
Source File: annotation_gui.py    From SEM with MIT License 5 votes vote down vote up
def about_sem(self, event=None):
        options = {"background":"white"}
        aboutTop = tkinter.Toplevel(**options)
        aboutTop.title("About SEM")
        aboutTop.focus_set()
        
        two_cols = []
        two_cols.append(("author:", "Yoann Dupont"))
        two_cols.append(("mail:", "yoa.dupont@gmail.com"))
        two_cols.append(("website:", "http://www.lattice.cnrs.fr/sites/itellier/SEM.html"))
        two_cols.append(("github:", "https://github.com/YoannDupont/SEM"))
        two_cols.append(("online app:", "apps.lattice.cnrs.fr/sem"))
        
        x = 0
        label = ttk.Label(aboutTop, text=sem.full_name(), **options)
        label.grid(row=x, column=0)
        x += 1
        ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
        x += 1
        ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
        x += 1
        for key, val in two_cols:
            label = ttk.Label(aboutTop, text=key, **options)
            label.grid(row=x, column=0, sticky="w")
            label = ttk.Label(aboutTop, text=val, **options)
            label.grid(row=x, column=1, sticky="w")
            x += 1
            ttk.Label(aboutTop, text="", **options).grid(row=x, column=0)
            x += 1
    
    #
    # global methods
    # 
Example #30
Source File: example.py    From Traffic-Signs-and-Object-Detection with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):

        tk.Tk.__init__(self)

        self.geometry('%dx%d+500+500' % (WIDTH,HEIGHT))
        self.title('GooMPy')

        self.canvas = tk.Canvas(self, width=WIDTH, height=HEIGHT)

        self.canvas.pack()

        self.bind("<Key>", self.check_quit)
        self.bind('<B1-Motion>', self.drag)
        self.bind('<Button-1>', self.click)

        self.label = tk.Label(self.canvas)

        self.radiogroup = tk.Frame(self.canvas)
        self.radiovar = tk.IntVar()
        self.maptypes = ['roadmap', 'terrain', 'satellite', 'hybrid']
        self.add_radio_button('Road Map',  0)
        self.add_radio_button('Terrain',   1)
        self.add_radio_button('Satellite', 2)
        self.add_radio_button('Hybrid',    3)

        self.zoom_in_button  = self.add_zoom_button('+', +1)
        self.zoom_out_button = self.add_zoom_button('-', -1)

        self.zoomlevel = ZOOM

        maptype_index = 0
        self.radiovar.set(maptype_index)

        self.goompy = GooMPy(WIDTH, HEIGHT, LATITUDE, LONGITUDE, ZOOM, MAPTYPE)

        self.restart()