Python tkinter.ttk.Entry() Examples

The following are 30 code examples of tkinter.ttk.Entry(). 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.ttk , 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: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 7 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1) 
Example #3
Source File: Embed_tkinter.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
def tkinterApp():
    import tkinter as tk
    from tkinter import ttk
    win = tk.Tk()    
    win.title("Python GUI")
    aLabel = ttk.Label(win, text="A Label")
    aLabel.grid(column=0, row=0)    
    ttk.Label(win, text="Enter a name:").grid(column=0, row=0)
    name = tk.StringVar()
    nameEntered = ttk.Entry(win, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1)
    nameEntered.focus() 
     
    def buttonCallback():
        action.configure(text='Hello ' + name.get())
    action = ttk.Button(win, text="Print", command=buttonCallback) 
    action.grid(column=2, row=1)
    win.mainloop()

#================================================================== 
Example #4
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)
        self.username_entry.focus_force()

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1)

        self.login_event = self.bind("<Return>", self.login) 
Example #5
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_parameters_frame(self, parent):
        parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        parameters.grid(sticky='nsew')

        heading = ttk.Label(parameters, text='Analysis parameters')
        heading.grid(column=0, row=0, sticky='n')

        for i, param in enumerate(self.parameters, start=1):
            param_label = ttk.Label(parameters, text=param._name)
            param_label.grid(row=i, column=0, sticky='nsew')
            if type(param) == tk.BooleanVar:
                param_entry = ttk.Checkbutton(parameters, variable=param)
            elif hasattr(param, '_choices'):
                param_entry = ttk.OptionMenu(parameters, param, param.get(),
                                             *param._choices.keys())
            else:
                param_entry = ttk.Entry(parameters, textvariable=param)
            param_entry.grid(row=i, column=1, sticky='nsew') 
Example #6
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        ttk.Label(
            self,
            text="ABQ Data Entry Application",
            font=("TkDefaultFont", 16)
        ).grid(row=0)


        self.recordform = DataRecordForm(self)
        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky="e", row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky="we", row=3, padx=10)

        self.records_saved = 0 
Example #7
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, parent, label='', input_class=ttk.Entry,
                 input_var=None, input_args=None, label_args=None,
                 **kwargs):
        super().__init__(parent, **kwargs)
        input_args = input_args or {}
        label_args = label_args or {}
        self.variable = input_var

        if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
            input_args["text"] = label
            input_args["variable"] = input_var
        else:
            self.label = ttk.Label(self, text=label, **label_args)
            self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
            input_args["textvariable"] = input_var

        self.input = input_class(self, **input_args)
        self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
        self.columnconfigure(0, weight=1)
        self.error = getattr(self.input, 'error', tk.StringVar())
        self.error_label = ttk.Label(self, textvariable=self.error)
        self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E)) 
Example #8
Source File: views.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def body(self, parent):
        lf = tk.Frame(self)
        ttk.Label(lf, text='Login to ABQ',
                  font='TkHeadingFont').grid(row=0)

        ttk.Style().configure('err.TLabel',
                background='darkred', foreground='white')
        if self.error.get():
            ttk.Label(lf, textvariable=self.error,
                      style='err.TLabel').grid(row=1)
        ttk.Label(lf, text='User name:').grid(row=2)
        self.username_inp = ttk.Entry(lf, textvariable=self.user)
        self.username_inp.grid(row=3)
        ttk.Label(lf, text='Password:').grid(row=4)
        self.password_inp = ttk.Entry(lf, show='*', textvariable=self.pw)
        self.password_inp.grid(row=5)
        lf.pack()
        return self.username_inp 
Example #9
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, parent, label='', input_class=ttk.Entry,
                 input_var=None, input_args=None, label_args=None,
                 **kwargs):
        super().__init__(parent, **kwargs)
        input_args = input_args or {}
        label_args = label_args or {}
        self.variable = input_var

        if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
            input_args["text"] = label
            input_args["variable"] = input_var
        else:
            self.label = ttk.Label(self, text=label, **label_args)
            self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
            input_args["textvariable"] = input_var

        self.input = input_class(self, **input_args)
        self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
        self.columnconfigure(0, weight=1) 
Example #10
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        ttk.Label(
            self,
            text="ABQ Data Entry Application",
            font=("TkDefaultFont", 16)
        ).grid(row=0)

        self.recordform = DataRecordForm(self)
        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky=tk.E, row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky=(tk.W + tk.E), row=3, padx=10)

        self.records_saved = 0 
Example #11
Source File: views.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def body(self, parent):
        lf = tk.Frame(self)
        ttk.Label(lf, text='Login to ABQ',
                  font='TkHeadingFont').grid(row=0)

        ttk.Style().configure('err.TLabel',
                background='darkred', foreground='white')
        if self.error.get():
            ttk.Label(lf, textvariable=self.error,
                      style='err.TLabel').grid(row=1)
        ttk.Label(lf, text='User name:').grid(row=2)
        self.username_inp = ttk.Entry(lf, textvariable=self.user)
        self.username_inp.grid(row=3)
        ttk.Label(lf, text='Password:').grid(row=4)
        self.password_inp = ttk.Entry(lf, show='*', textvariable=self.pw)
        self.password_inp.grid(row=5)
        lf.pack()
        return self.username_inp 
Example #12
Source File: views.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def body(self, parent):
        lf = tk.Frame(self)
        ttk.Label(lf, text='Login to ABQ',
                  font='TkHeadingFont').grid(row=0)

        ttk.Style().configure('err.TLabel',
                background='darkred', foreground='white')
        if self.error.get():
            ttk.Label(lf, textvariable=self.error,
                      style='err.TLabel').grid(row=1)
        ttk.Label(lf, text='User name:').grid(row=2)
        self.username_inp = ttk.Entry(lf, textvariable=self.user)
        self.username_inp.grid(row=3)
        ttk.Label(lf, text='Password:').grid(row=4)
        self.password_inp = ttk.Entry(lf, show='*', textvariable=self.pw)
        self.password_inp.grid(row=5)
        lf.pack()
        return self.username_inp 
Example #13
Source File: GUI_embed_frames_align_west.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #14
Source File: scaleentry.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def cget_entry(self, key):
        """
        Query the Entry widget's option.

        :param key: option name
        :type key: str
        :return: value of the option
        """
        return self._entry.cget(key) 
Example #15
Source File: GUI_title.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #16
Source File: scaleentry.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def config_entry(self, cnf={}, **kwargs):
        """Configure resources of the Entry widget."""
        self._entry.config(cnf, **kwargs) 
Example #17
Source File: GUI_progressbar.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #18
Source File: GUI_spinbox_two_ridge.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #19
Source File: GUI_spinbox_small.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #20
Source File: GUI_icon.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #21
Source File: GUI_message_box_yes_no_cancel.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #22
Source File: GUI_message_box_error.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #23
Source File: GUI_canvas.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #24
Source File: GUI_spinbox_small_bd_scrol_values.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #25
Source File: GUI_message_box_warning.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #26
Source File: GUI_message_box.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #27
Source File: GUI_spinbox_small_bd_scrol.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #28
Source File: GUI_spinbox_small_bd.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(): 
    action.configure(text='Hello ' + name.get() + ' ' + 
                     number_chosen.get())

# Adding a Textbox Entry widget 
Example #29
Source File: autocomplete_entry.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def autocomplete(self, delta=0):
        """
        Autocomplete the Entry.

        :param delta: 0, 1 or -1: how to cycle through possible hits
        :type delta: int
        """
        if delta:  # need to delete selection otherwise we would fix the current position
            self.delete(self.position, tk.END)
        else:  # set position to end so selection starts where textentry ended
            self.position = len(self.get())
        # collect hits
        _hits = []
        for element in self._completion_list:
            if element.lower().startswith(self.get().lower()):  # Match case-insensitively
                _hits.append(element)
        # if we have a new hit list, keep this in mind
        if _hits != self._hits:
            self._hit_index = 0
            self._hits = _hits
        # only allow cycling if we are in a known hit list
        if _hits == self._hits and self._hits:
            self._hit_index = (self._hit_index + delta) % len(self._hits)
        # now finally perform the auto completion
        if self._hits:
            self.delete(0, tk.END)
            self.insert(0, self._hits[self._hit_index])
            self.select_range(self.position, tk.END) 
Example #30
Source File: scaleentry.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def _on_scale(self, event):
        """
        Callback for the Scale widget, inserts an int value into the Entry.

        :param event: Tkinter event
        """
        self._entry.delete(0, tk.END)
        self._entry.insert(0, str(self._variable.get()))