Python tkinter.Entry() Examples

The following are 30 code examples of tkinter.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 , 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: 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 #3
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 #4
Source File: pynpuzzle.py    From pynpuzzle with MIT License 6 votes vote down vote up
def draw_puzzle(puzzle_frame, n, read_only=False):
    """
    Fills a frame widget with n + 1 entry widget.

    puzzle_frame : The puzzle frame to get filled by entry widgets.
    n : Puzzle type (n-puzzle).
    read_only : Should widgets be read-only or not
    """
    n = int(math.sqrt(n + 1))

    for i in range(n):
        for j in range(n):
            entry = tkinter.Entry(puzzle_frame, width=4, justify='center')
            entry.grid(row=i, column=j, sticky='WENS')

            if read_only:
                # Bind the widget validation command to return_false_validate command and therefore
                #   OUTPUT_EDITABLE global variable.
                entry.config(validatecommand=return_false_validate, validate=tkinter.ALL)

        puzzle_frame.grid_columnconfigure(i, weight=1)
        puzzle_frame.grid_rowconfigure(i, weight=1) 
Example #5
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 #6
Source File: workflowcreator.py    From CEASIOMpy with Apache License 2.0 6 votes vote down vote up
def __init__(self, master=None, **kwargs):

        tk.Frame.__init__(self, master, **kwargs)
        self.pack(fill=tk.BOTH)

        self.Options = WorkflowOptions()

        space_label = tk.Label(self, text=' ')
        space_label.grid(column=0, row=0)

        # Input CPACS file
        self.label = tk.Label(self, text='  Input CPACS file')
        self.label.grid(column=0, row=1)

        self.path_var = tk.StringVar()
        self.path_var.set(self.Options.cpacs_path)
        value_entry = tk.Entry(self, textvariable=self.path_var, width= 45)
        value_entry.grid(column=1, row=1)

        self.browse_button = tk.Button(self, text="Browse", command=self._browse_file)
        self.browse_button.grid(column=2, row=1, pady=5)

        # Notebook for tabs
        self.tabs = ttk.Notebook(self)
        self.tabs.grid(column=0, row=2, columnspan=3,padx=10,pady=10)

        self.TabPre = Tab(self, 'Pre')
        self.TabOptim = Tab(self, 'Optim')
        self.TabPost = Tab(self, 'Post')

        self.tabs.add(self.TabPre, text=self.TabPre.name)
        self.tabs.add(self.TabOptim, text=self.TabOptim.name)
        self.tabs.add(self.TabPost, text=self.TabPost.name)

        # General buttons
        self.close_button = tk.Button(self, text='Save & Quit', command=self._save_quit)
        self.close_button.grid(column=2, row=3) 
Example #7
Source File: download_cl1024_images.py    From pythonprojects with MIT License 6 votes vote down vote up
def __init__(self, root=None, **args):
        super(DownloadFrame, self).__init__(root=root, **args)
        self.entry = tk.StringVar()
        self.cnt = 0
        self.num = tk.StringVar()
        self.num.set(300)
        self.name = 0
        self.flag = False

        row = 0

        tk.Label(self.root, text='----请输入要下载的免翻地址---').grid(row=row, column=1)

        row += 1
        tk.Label(self.root,width=10, justify='right' ,text='地址').grid(row=row, column=0)
        tk.Entry(self.root, textvariable=self.entry, width=24).grid(row=row, column=1)
        tk.Button(self.root, width=9,text='下载图片', command=self.downloadnow).grid(row=row, column=2)


        row += 1

        tk.Label(self.root,   text='---代理功能更新中---').grid(row=row, column=1) 
Example #8
Source File: price_display.py    From hwk-mirror with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, text, textvariable, **kwargs):
        super().__init__(parent, **kwargs)
        self.label = tk.Label(self, 
                text=text,
                font=self.font,
                anchor=tk.E)
        
        self.entry = tk.Entry(self,
                textvariable=textvariable,
                font=self.font,
                width=len("$ 000.00"),
                state=tk.DISABLED,
                disabledforeground="black",
                disabledbackground="white")

        self.label.grid(row=0, column=0, sticky="nswe")
        self.entry.grid(row=0, column=1, sticky="nswe") 
Example #9
Source File: console.py    From hwk-mirror with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent):
        super().__init__(parent)
        var = tk.StringVar(self)
        label = tk.Label(self, text="$ ", width=2, bg="grey26", fg="white", relief=tk.FLAT, bd=0)
        self.entry = entry = tk.Entry(self, 
                width=78,
                bg="grey26",
                fg="white",
                relief=tk.FLAT,
                bd=0,
                highlightthickness=0,
                textvariable=var,
                insertbackground="white")
        
        label.grid(row=1, column=0)
        entry.grid(row=1, column=1)
        self.set = var.set
        self.get = var.get
        entry.bind("<Return>", self.on_enter) 
Example #10
Source File: options.py    From hwk-mirror with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, item, **kwargs):
        super().__init__(parent, **kwargs)
        self.grid_columnconfigure(0, weight=1)
        label = tk.Label(self, font=self.font, text=f"{item.name}", width=25, justify=tk.LEFT, anchor=tk.NW)
        self.ticket = item
        self.options = [lib.ToggleSwitch(self, text=option, font=self.font, width=15) for option in item.options]
        self._comments = tk.StringVar(self)
        comment = item.parameters.get("comments", "")
        self._comments.set(comment if comment else "Comments")
        self.comments = tk.Entry(self, textvariable=self._comments, font=self.font)
        self.grid_columnconfigure(0, weight=1)

        label.grid(row=0, column=0, columnspan=2, sticky="nswe", padx=5, pady=5)
        tk.Label(self, text="    ", font=self.font).grid(row=1, column=0, sticky="nswe")
        for i, option in enumerate(self.options):
            if option["text"] in item.selected_options:
                option.state = True
            option.grid(row=i+1, column=1, sticky="nwe", padx=5, pady=5)
        
        self.grid_rowconfigure(len(self.options) + 2, weight=1)
        self.comments.grid(row=len(self.options) + 2, column=0, columnspan=2, pady=5, padx=5, sticky="swe")
        self.comments.bind("<FocusIn>", self.on_entry_focus) 
Example #11
Source File: options_frame_gui.py    From pyDEA with MIT License 6 votes vote down vote up
def set_multi_tol(self):
        ''' Sets the value of Entry with multiplier model tolerance
            according to a given value
            if this value is valid (non-negative float). If the given value
            is invalid, a warning is displayed.
        '''
        tol_str = self.params.get_parameter_value('MULTIPLIER_MODEL_TOLERANCE')
        try:
            tol = float(tol_str)
            if (tol < 0):
                self._show_multi_tol_warning(tol_str)
                self.multi_tol_strvar.set('0')
            else:
                self.multi_tol_strvar.set(tol_str)
        except ValueError:
            self._show_multi_tol_warning(tol_str)
            self.multi_tol_strvar.set('0') 
Example #12
Source File: ttk.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, master=None, widget=None, **kw):
        """Constructs a Ttk Entry widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand

        WIDGET-SPECIFIC OPTIONS

            exportselection, invalidcommand, justify, show, state,
            textvariable, validate, validatecommand, width

        VALIDATION MODES

            none, key, focus, focusin, focusout, all
        """
        Widget.__init__(self, master, widget or "ttk::entry", kw) 
Example #13
Source File: update_gui.py    From Trade-Dangerous with Mozilla Public License 2.0 6 votes vote down vote up
def addInput(self, item, defValue, row):
        pos = len(row)
        
        inputVal = tk.StringVar()
        inputVal.set(str(defValue))
        
        inputEl = tk.Entry(self.interior,
                width=10,
                justify=tk.RIGHT,
                textvariable=inputVal)
        inputEl.item = item
        inputEl.row = row
        inputEl.pos = pos
        inputEl.val = inputVal
        
        inputEl.bind('<Shift-Key-Tab>', self.onShiftTab)
        inputEl.bind('<Key-Tab>', self.onTab)
        inputEl.bind('<Key-Return>', self.onReturn)
        inputEl.bind('<Key-Down>', self.onDown)
        inputEl.bind('<Key-Up>', self.onUp)
        inputEl.bind('<FocusOut>', lambda evt: self.validateRow(evt.widget.row))
        self.addWidget(inputEl, sticky='E')
        row.append((inputEl, inputVal)) 
Example #14
Source File: ttk.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def __init__(self, master=None, widget=None, **kw):
        """Constructs a Ttk Entry widget with the parent master.

        STANDARD OPTIONS

            class, cursor, style, takefocus, xscrollcommand

        WIDGET-SPECIFIC OPTIONS

            exportselection, invalidcommand, justify, show, state,
            textvariable, validate, validatecommand, width

        VALIDATION MODES

            none, key, focus, focusin, focusout, all
        """
        Widget.__init__(self, master, widget or "ttk::entry", kw) 
Example #15
Source File: recipe-577525.py    From code with MIT License 6 votes vote down vote up
def __init__(self, master):
        # Initialize the Frame object.
        super().__init__(master)
        # Create every opening widget.
        self.intro = Label(self, text=self.PROMPT)
        self.group = LabelFrame(self, text='Filename')
        self.entry = Entry(self.group, width=35)
        self.click = Button(self.group, text='Browse ...', command=self.file)
        self.enter = Button(self, text='Continue', command=self.start)
        # Make Windows entry bindings.
        def select_all(event):
            event.widget.selection_range(0, tkinter.END)
            return 'break'
        self.entry.bind('<Control-Key-a>', select_all)
        self.entry.bind('<Control-Key-/>', lambda event: 'break')
        # Position them in this frame.
        options = {'sticky': tkinter.NSEW, 'padx': 5, 'pady': 5}
        self.intro.grid(row=0, column=0, **options)
        self.group.grid(row=1, column=0, **options)
        self.entry.grid(row=0, column=0, **options)
        self.click.grid(row=0, column=1, **options)
        self.enter.grid(row=2, column=0, **options) 
Example #16
Source File: toolkit.py    From PickTrue with MIT License 5 votes vote down vote up
def __init__(self, master=None, name=None, **kwargs):
        super(NamedInput, self).__init__(master=master, **kwargs)
        assert name is not None
        self._name = name
        label = tk.Label(self, text=name)
        label.pack(side=tk.LEFT)

        self.entry = tk.Entry(self)
        self.entry.pack(side=tk.LEFT, fill=tk.X, expand=1)
        self.pack(fill=tk.X) 
Example #17
Source File: toolkit.py    From PickTrue with MIT License 5 votes vote down vote up
def __init__(self, master=None, name=None, **kwargs):
        super(PasswordInput, self).__init__(master=master, **kwargs)
        assert name is not None
        self._name = name
        label = tk.Label(self, text=name)
        label.pack(side=tk.LEFT)

        self.entry = tk.Entry(self, show="*")
        self.entry.pack(side=tk.LEFT, fill=tk.X, expand=1)
        self.pack(fill=tk.X) 
Example #18
Source File: ui_launch.py    From Andromeda with MIT License 5 votes vote down vote up
def __make_select_text(self, frame, row, column, tag, text, sele=True):
        entry = tk.Entry(frame, width=35, textvariable=text)
        entry.grid(row=row, column=column)
        if sele:
            button = tk.Button(frame, text='选择', width=10,)
            button.grid(row=row, column=column + 1)
            button['command'] = (lambda:
                                 self.__click_select(entry, tag)) 
Example #19
Source File: ui_input.py    From Andromeda with MIT License 5 votes vote down vote up
def __make_select_text(self, frame, row, column, tag, text, sele=True):
        entry = tk.Entry(frame, width=35, textvariable=text)
        entry.grid(row=row, column=column)
        if sele:
            button = tk.Button(frame, text='选择')
            button.grid(row=row, column=column + 1)
            button['command'] = (lambda:
                                 self.__click_select(entry, tag)) 
Example #20
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 #21
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 #22
Source File: fleetConnectionWindow.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def addEntrySetting(self, var, labelText, descriptorText):
        centerFrame = tk.Frame(self)
        centerFrame.grid(row=self.counter, column="1", columnspan="2", sticky="w")
        label = tk.Label(centerFrame, text=labelText)
        label.grid(row=self.counter, column="1", sticky="w")
        entry = tk.Entry(centerFrame, textvariable=var, width=25)
        entry.grid(row=self.counter, column="2", sticky="w")
        descriptor = tk.Label(self, text=descriptorText)
        font = tkFont.Font(font=descriptor['font'])
        font.config(slant='italic')
        descriptor['font'] = font
        descriptor.grid(row=self.counter+1, column="1", columnspan="2", sticky="w")
        tk.Frame(self, height="10", width="10").grid(row=self.counter+2, column="1", columnspan="5")
        self.counter += 3 
Example #23
Source File: lineSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def expandCustomizationSettings(self, frame, settingsList):
        index = 0
        for setting in settingsList:
            removeButton = tk.Button(frame, text="X", command=lambda i=index:self.removeLine(i, settingsList, frame))
            font = tkFont.Font(font=removeButton['font'])
            font.config(weight='bold')
            removeButton['font'] = font
            removeButton.grid(row=index, column="0")
            initialLabel = tk.Label(frame, text="Threshold when the line changes color:")
            initialLabel.grid(row=index, column="1")
            initialThreshold = tk.Entry(frame, textvariable=settingsList[index]["transitionValue"], width=10)
            if (index == 0):
                initialThreshold.configure(state="disabled")
                removeButton.configure(state="disabled", borderwidth="0", text=" X ")
            initialThreshold.grid(row=index, column="2")
            initialLabel = tk.Label(frame, text="Color:")
            initialLabel.grid(row=index, column="3")
            colorButton = tk.Button(frame, text="    ", 
                                    command=lambda i=index:self.colorWindow(settingsList[i], colorButton), 
                                    bg=settingsList[index]["color"])
            colorButton.grid(row=index, column="4")
            index += 1
        
        addLineButton = tk.Button(frame, text="Add Another Threshold",
                                  command=lambda:self.addLine(settingsList, frame))
        addLineButton.grid(row="100", column="1") 
Example #24
Source File: generalSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def addSetting(self, var, labelText, descriptorText):
        centerFrame = tk.Frame(self)
        centerFrame.grid(row=self.counter, column="1", columnspan="2")
        label = tk.Label(centerFrame, text=labelText)
        label.grid(row=self.counter, column="1", sticky="e")
        entry = tk.Entry(centerFrame, textvariable=var, width=10)
        entry.grid(row=self.counter, column="2", sticky="w")
        descriptor = tk.Label(self, text=descriptorText)
        font = tkFont.Font(font=descriptor['font'])
        font.config(slant='italic')
        descriptor['font'] = font
        descriptor.grid(row=self.counter+1, column="1", columnspan="2")
        tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5")
        self.counter += 3 
Example #25
Source File: arduino_basics.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def create_widgets(self, **kwargs):
    """
    Widgets shown:
    - an Input text, to enter what to write on serial port.
    - a submit label, to show previous command submitted.
    - a submit button.
    """

    self.input_txt = tk.Entry(self,
                              width=self.total_width * 5 / 10,
                              font=tkFont.Font(
                                size=kwargs.get("fontsize", 13)))
    self.submit_label = tk.Label(self, text='',
                                 width=1,
                                 font=tkFont.Font(
                                   size=kwargs.get("fontsize", 13)))
    self.submit_button = tk.Button(self,
                                   text='Submit',
                                   command=self.update_widgets,
                                   width=int(self.total_width * 0.5 / 10),
                                   font=tkFont.Font(
                                     size=kwargs.get("fontsize", 13)))

    self.input_txt.bind('<Return>', self.update_widgets)
    self.input_txt.bind('<KP_Enter>', self.update_widgets)

    # Positioning
    self.input_txt.grid(row=0, column=0, sticky=tk.W)
    self.submit_label.grid(row=0, column=1)
    self.submit_button.grid(row=0, column=2, sticky=tk.E) 
Example #26
Source File: frame_objects.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def add_entry(self, **kwargs):
    """
    To add an entry box. The adding of the entry box will add an attribute,
    if no variable is specified.

    args:
    - vartype: to specify which type the variable associated with the entry
    will be. Useful to make sure the user does not enter a string when a
    number is expected.
    - variable: the variables name, which will be set as an attribute.
    - width : the width of the entry box.
    """
    widgets_dict = kwargs.pop('widgets_dict', None)
    frame = kwargs.pop('frame', None)
    entry_name = kwargs.pop('name', 'name')
    width = kwargs.pop('width', 10)
    vartype = kwargs.pop('vartype', tk.DoubleVar())
    variable = kwargs.pop("variable", None)

    if not variable:
      setattr(self, entry_name + '_var', vartype)
      widgets_dict[entry_name] = tk.Entry(frame,
                                        textvariable=getattr(self, entry_name+
                                        '_var'),
                                          width=width)
    else:
      widgets_dict[entry_name] = tk.Entry(frame,
                                          textvariable=variable,
                                          width=width) 
Example #27
Source File: basic_threading_demo.py    From Python-GUI-Programming-with-Tkinter with MIT License 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.text = tk.StringVar()
        tk.Entry(self, textvariable=self.text).pack()
        tk.Button(self, text="Run unthreaded",
                  command=self.print_unthreaded).pack()
        tk.Button(self, text="Run threaded",
                  command=self.print_threaded).pack() 
Example #28
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 #29
Source File: pyjsonviewer.py    From PyJSONViewer with MIT License 5 votes vote down vote up
def init_search_box(self):
        self.bottom_frame = tk.Frame(self)
        self.bottom_frame.grid(column=0, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))

        self.search_label = tk.Label(self.bottom_frame, text="Search:")
        self.search_label.pack(side=tk.LEFT)

        self.search_box = tk.Entry(self.bottom_frame)
        self.search_box.pack(fill='x')
        self.search_box.bind('<Key>', self.find_word) 
Example #30
Source File: pyjsonviewer.py    From PyJSONViewer with MIT License 5 votes vote down vote up
def find_window(self):
        self.search_box = tk.Entry(self.master)
        self.search_box.pack()
        self.search_box.bind('<Key>', self.find_word)