Python Tkinter.Message() Examples

The following are 9 code examples of Tkinter.Message(). 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: SikuliGui.py    From lackey with MIT License 5 votes vote down vote up
def __init__(self, parent, msg, title, hidden, text_variable):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.protocol("WM_DELETE_WINDOW", self.cancel_function)
        self.parent.bind('<Return>', self.ok_function)
        self.parent.title(title)
        self.input_text = text_variable
        if Settings.PopupLocation:
            self.parent.geometry("+{}+{}".format(
                Settings.PopupLocation.x,
                Settings.PopupLocation.y))
        self.msg = tk.Message(self.parent, text=msg)
        self.msg.grid(row=0, sticky="NSEW", padx=10, pady=10)
        self.input_entry = tk.Entry(self.parent, width=50, textvariable=self.input_text)
        if hidden:
            self.input_entry.config(show="*")
        self.input_entry.grid(row=1, sticky="EW", padx=10)
        self.button_frame = tk.Frame(self.parent)
        self.button_frame.grid(row=2, sticky="E")
        self.cancel = tk.Button(
            self.button_frame,
            text="Cancel",
            command=self.cancel_function,
            width=10)
        self.cancel.grid(row=0, column=0, padx=10, pady=10)
        self.ok_button = tk.Button(
            self.button_frame,
            text="Ok",
            command=self.ok_function,
            width=10)
        self.ok_button.grid(row=0, column=1, padx=10, pady=10)
        self.input_entry.focus_set() 
Example #2
Source File: SikuliGui.py    From lackey with MIT License 5 votes vote down vote up
def __init__(self, parent, msg, title, options, default, text_variable):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.protocol("WM_DELETE_WINDOW", self.cancel_function)
        self.parent.bind('<Return>', self.ok_function)
        self.parent.title(title)
        self.input_text = text_variable
        self.input_text.set(default)
        if Settings.PopupLocation:
            self.parent.geometry("+{}+{}".format(
                Settings.PopupLocation.x,
                Settings.PopupLocation.y))
        self.msg = tk.Message(self.parent, text=msg)
        self.msg.grid(row=0, sticky="NSEW", padx=10, pady=10)
        self.input_list = ttk.Combobox(
            self.parent,
            textvariable=self.input_text,
            state="readonly",
            values=options)
        #self.input_list.activate(options.index(default))
        self.input_list.grid(row=1, sticky="EW", padx=10)
        self.button_frame = tk.Frame(self.parent)
        self.button_frame.grid(row=2, sticky="E")
        self.cancel = tk.Button(
            self.button_frame,
            text="Cancel",
            command=self.cancel_function,
            width=10)
        self.cancel.grid(row=0, column=0, padx=10, pady=10)
        self.ok_button = tk.Button(
            self.button_frame,
            text="Ok",
            command=self.ok_function,
            width=10)
        self.ok_button.grid(row=0, column=1, padx=10, pady=10)
        self.input_list.focus_set() 
Example #3
Source File: SikuliGui.py    From lackey with MIT License 5 votes vote down vote up
def __init__(self, parent, message, title, lines, width, input_text):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.protocol("WM_DELETE_WINDOW", self.cancel_function)
        #self.parent.bind('<Return>', self.ok_function)
        self.parent.title(title)
        self.input_text = input_text
        if Settings.PopupLocation:
            self.parent.geometry("+{}+{}".format(
                Settings.PopupLocation.x,
                Settings.PopupLocation.y))

        self.input_entry = TextExtension(
            self.parent,
            textvariable=self.input_text,
            width=width,
            height=lines)
        self.input_entry.grid(row=1, sticky="EW", padx=10, pady=10)

        self.msg = tk.Message(self.parent, text=message)
        self.msg.grid(row=0, sticky="NSEW", padx=10)

        self.button_frame = tk.Frame(self.parent)
        self.button_frame.grid(row=2, sticky="E")
        self.cancel = tk.Button(
            self.button_frame,
            text="Cancel",
            command=self.cancel_function,
            width=10)
        self.cancel.grid(row=0, column=0, padx=10, pady=10)
        self.ok_button = tk.Button(
            self.button_frame,
            text="Ok",
            command=self.ok_function,
            width=10)
        self.ok_button.grid(row=0, column=1, padx=10, pady=10)
        self.input_entry.focus() 
Example #4
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return tkinter.Message(self.root, **kwargs) 
Example #5
Source File: pyspantask.py    From py-span-task with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, master, *scripts, **opts):

    # build gui:
    Tkinter.Frame.__init__(self, master, **opts)
    master.title("Py-Span-Task")

    self.scripts = list(scripts)
    self.opts = {}

    self.display_var = Tkinter.StringVar("")
    width = master.winfo_screenwidth()
    self.display = Tkinter.Message(self, justify=LEFT, textvar=self.display_var,
                     font=(fontname, fontsize),
                     width=width-(width/10), bg="white")
    self.display.pack(fill=BOTH, expand=1)

    self.entry_var = Tkinter.StringVar("")
    self.entry = Tkinter.Entry(self, font=(fontname, fontsize),
                               state="disabled",
                               textvar=self.entry_var)
    self.entry.pack(fill=X)
    self.entry.bind('<Return>', lambda e:self.key_pressed('<Return>'))

    self.bind('<space>', lambda e:self.key_pressed('<space>'))

    # Sometimes lexical closures suck:
    def event_handler_creator(frame, key):
      return lambda e:frame.key_pressed(key)

    for v in responses.values():
      self.bind(v, event_handler_creator(self, v))

    self.focus_set()

    self.key_pressed(None) 
Example #6
Source File: 05_Password_Prompt.py    From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License 5 votes vote down vote up
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.pack()
        self.master.title("")
        self.master.resizable(False, False)
        self.master.tk_setPalette(background='#ececec')

        self.master.protocol('WM_DELETE_WINDOW', self.click_cancel)
        self.master.bind('<Return>', self.click_ok)
        self.master.bind('<Escape>', self.click_cancel)

        x = (self.master.winfo_screenwidth() - self.master.winfo_reqwidth()) / 2
        y = (self.master.winfo_screenheight() - self.master.winfo_reqheight()) / 3
        self.master.geometry("+{}+{}".format(x, y))

        self.master.config(menu=tk.Menu(self))

        tk.Message(self, text="Please authenticate with your username and password before continuing.",
                   font='System 14 bold', justify='left', aspect=800).pack(pady=(15, 0))

        dialog_frame = tk.Frame(self)
        dialog_frame.pack(padx=20, pady=15, anchor='w')

        tk.Label(dialog_frame, text='Username:').grid(row=0, column=0, sticky='w')

        self.user_input = tk.Entry(dialog_frame, background='white', width=24)
        self.user_input.grid(row=0, column=1, sticky='w')
        self.user_input.focus_set()

        tk.Label(dialog_frame, text='Password:').grid(row=1, column=0, sticky='w')

        self.pass_input = tk.Entry(dialog_frame, background='white', width=24, show='*')
        self.pass_input.grid(row=1, column=1, sticky='w')

        button_frame = tk.Frame(self)
        button_frame.pack(padx=15, pady=(0, 15), anchor='e')

        tk.Button(button_frame, text='OK', height=1, width=6, default='active', command=self.click_ok).pack(side='right')

        tk.Button(button_frame, text='Cancel', height=1, width=6, command=self.click_cancel).pack(side='right', padx=10) 
Example #7
Source File: Tkinter_Widget_Examples.py    From MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter with MIT License 5 votes vote down vote up
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.pack()

        lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut " \
                      "labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " \
                      "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in " \
                      "voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat " \
                      "cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

        tk.Label(self, text="This is a message (under a label)").pack()

        tk.Message(self, text=lorem_ipsum, justify='left').pack(pady=(10, 10)) 
Example #8
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return tkinter.Message(self.root, **kwargs) 
Example #9
Source File: __init__.py    From PyMsgBox with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def _buttonbox(msg, title, choices, root=None, timeout=None):
    """
    Display a msg, a title, and a set of buttons.
    The buttons are defined by the members of the choices list.
    Return the text of the button that the user selected.

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    """
    global boxRoot, __replyButtonText, __widgetTexts, buttonsFrame

    # Initialize __replyButtonText to the first choice.
    # This is what will be used if the window is closed by the close button.
    __replyButtonText = choices[0]

    if root:
        root.withdraw()
        boxRoot = tk.Toplevel(master=root)
        boxRoot.withdraw()
    else:
        boxRoot = tk.Tk()
        boxRoot.withdraw()

    boxRoot.title(title)
    boxRoot.iconname("Dialog")
    boxRoot.geometry(rootWindowPosition)
    boxRoot.minsize(400, 100)

    # ------------- define the messageFrame ---------------------------------
    messageFrame = tk.Frame(master=boxRoot)
    messageFrame.pack(side=tk.TOP, fill=tk.BOTH)

    # ------------- define the buttonsFrame ---------------------------------
    buttonsFrame = tk.Frame(master=boxRoot)
    buttonsFrame.pack(side=tk.TOP, fill=tk.BOTH)

    # -------------------- place the widgets in the frames -----------------------
    messageWidget = tk.Message(messageFrame, text=msg, width=400)
    messageWidget.configure(font=(PROPORTIONAL_FONT_FAMILY, PROPORTIONAL_FONT_SIZE))
    messageWidget.pack(side=tk.TOP, expand=tk.YES, fill=tk.X, padx="3m", pady="3m")

    __put_buttons_in_buttonframe(choices)

    # -------------- the action begins -----------
    # put the focus on the first button
    __firstWidget.focus_force()

    boxRoot.deiconify()
    if timeout is not None:
        boxRoot.after(timeout, timeoutBoxRoot)
    boxRoot.mainloop()
    try:
        boxRoot.destroy()
    except tk.TclError:
        if __replyButtonText != TIMEOUT_RETURN_VALUE:
            __replyButtonText = None

    if root:
        root.deiconify()
    return __replyButtonText