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


Python tkinter.Entry方法代码示例

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


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

示例1: __init__

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

        self.name_text = tk.StringVar()

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

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

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

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

示例2: __init__

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

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

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

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

示例3: draw_puzzle

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:mahdavipanah,项目名称:pynpuzzle,代码行数:24,代码来源:pynpuzzle.py

示例4: addLine

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

示例5: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:kurtlab,项目名称:pythonprojects,代码行数:24,代码来源:download_cl1024_images.py

示例6: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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") 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:19,代码来源:price_display.py

示例7: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:21,代码来源:console.py

示例8: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:24,代码来源:options.py

示例9: set_multi_tol

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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') 
开发者ID:araith,项目名称:pyDEA,代码行数:19,代码来源:options_frame_gui.py

示例10: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:ttk.py

示例11: addInput

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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)) 
开发者ID:eyeonus,项目名称:Trade-Dangerous,代码行数:25,代码来源:update_gui.py

示例12: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:ActiveState,项目名称:code,代码行数:24,代码来源:recipe-577525.py

示例13: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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) 
开发者ID:winkidney,项目名称:PickTrue,代码行数:12,代码来源:toolkit.py

示例14: __make_select_text

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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)) 
开发者ID:liucaide,项目名称:Andromeda,代码行数:10,代码来源:ui_launch.py

示例15: __make_select_text

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Entry [as 别名]
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)) 
开发者ID:liucaide,项目名称:Andromeda,代码行数:10,代码来源:ui_input.py


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