本文整理汇总了Python中tkinter.ttk.Entry方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Entry方法的具体用法?Python ttk.Entry怎么用?Python ttk.Entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk
的用法示例。
在下文中一共展示了ttk.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_parameters_frame
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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')
示例2: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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))
示例3: body
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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
示例4: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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)
示例5: tkinterApp
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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()
#==================================================================
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:22,代码来源:Embed_tkinter.py
示例6: build_window
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def build_window(self):
"""
Generates the window.
:author: Pablo Sanz Alguacil
"""
self.root = Toplevel()
self.root.geometry('310x200')
self.root.resizable(width=False, height=False)
self.root.title('DoS Attack')
self.root.protocol("WM_DELETE_WINDOW", self.destroy_window)
self.labelframe_info = LabelFrame(self.root)
self.labelframe_info.pack(fill="both", expand="no", pady=15)
self.label_info = Label(self.labelframe_info, pady=15, text="With this tool yo can perform a DoS Attack."
"\n\nIntroduce the attack's duration in seconds."
"\nIntroduce 0 for infite time attack."
"\nWait until the tool finishes the attack. ")
self.label_info.pack()
self.labelframe_buttons = LabelFrame(self.root)
self.labelframe_buttons.pack(fill="both", expand="no", pady=5)
self.label_time = Label(self.labelframe_buttons, text="Time: ")
self.label_time.grid(column=0, row=0, padx=5, pady=5)
self.entry = ttk.Entry(self.labelframe_buttons)
self.entry.grid(column=1, row=0, padx=5, pady=5)
self.button_start = Button(self.labelframe_buttons, text="Start", command=self.start_dos)
self.button_start.grid(column=2, row=0, padx=5, pady=5)
示例7: show_login_screen
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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)
示例8: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def __init__(self, master, **kwargs):
super().__init__(**kwargs )
self.geometry('350x100')
self.title('Find and Replace')
self.text_to_find = tk.StringVar()
self.text_to_replace_with = tk.StringVar()
top_frame = tk.Frame(self)
middle_frame = tk.Frame(self)
bottom_frame = tk.Frame(self)
find_entry_label = tk.Label(top_frame, text="Find: ")
self.find_entry = ttk.Entry(top_frame, textvar=self.text_to_find)
replace_entry_label = tk.Label(middle_frame, text="Replace: ")
self.replace_entry = ttk.Entry(middle_frame, textvar=self.text_to_replace_with)
self.find_button = ttk.Button(bottom_frame, text="Find", command=self.on_find)
self.replace = ttk.Button(bottom_frame, text="Replace", command=self.on_replace)
self.cancel_button = ttk.Button(bottom_frame, text="Cancel", command=self.destroy)
find_entry_label.pack(side=tk.LEFT, padx=(20, 0))
self.find_entry.pack(side=tk.LEFT, fill=tk.X, expand=1)
replace_entry_label.pack(side=tk.LEFT)
self.replace_entry.pack(side=tk.LEFT, fill=tk.X, expand=1)
self.find_button.pack(side=tk.LEFT, padx=(85, 0))
self.cancel_button.pack(side=tk.RIGHT, padx=(0, 30))
top_frame.pack(side=tk.TOP, expand=1, fill=tk.X, padx=30)
middle_frame.pack(side=tk.TOP, expand=1, fill=tk.X, padx=30)
bottom_frame.pack(side=tk.TOP, expand=1, fill=tk.X)
示例9: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def __init__(self, master):
super().__init__()
self.master = master
self.transient(master)
self.geometry("250x100")
self.title("Add a Friend")
main_frame = ttk.Frame(self)
username_label = ttk.Label(main_frame, text="Username")
self.username_entry = ttk.Entry(main_frame)
add_button = ttk.Button(main_frame, text="Add", command=self.add_friend)
username_label.grid(row=0, column=0)
self.username_entry.grid(row=0, column=1)
self.username_entry.focus_force()
add_button.grid(row=1, column=0, columnspan=2)
for i in range(2):
tk.Grid.columnconfigure(main_frame, i, weight=1)
tk.Grid.rowconfigure(main_frame, i, weight=1)
main_frame.pack(fill=tk.BOTH, expand=1)
示例10: show_login_screen
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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)
示例11: __init__
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def __init__(self, master):
self.label = ttk.Label(master, text='Enter the text below')
self.label.pack()
self.entry = ttk.Entry(master, width = 30) # number of characters along the width
self.entry.pack()
self.button = ttk.Button(master, text = "Get Entry")
self.button.pack()
self.tkstrvar = tk.StringVar() # create tk string variable
self.tkstrvar.set('Nothing is done yet!') # set the value of tk string variable
self.button.config(command = self.getEntry)
self.msg = ttk.Label(master, text = self.tkstrvar.get()) # get the value of string variable
self.msg.pack()
self.btn1 = ttk.Button(master, text='Delete the entry', command = self.btn1func)
self.btn1.pack()
self.crypt = tk.StringVar()
self.crypt.set('Encrypt')
self.btn2 = ttk.Button(master, text = "{} Text in Entry Field".format(self.crypt.get()), command = self.changecrypt)
self.btn2.pack()
#self.entryText = ttk.Entry(master, width=30)
ttk.Button(master, text = 'Disable Entry Field', command = self.btn3func).pack()
ttk.Button(master, text = 'Enable Entry Field', command = self.btn4func).pack()
ttk.Button(master, text = 'Readonly Entry Field', command = self.btn5func).pack()
ttk.Button(master, text = 'Edit Entry Field', command = self.btn6func).pack()
示例12: changecrypt
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def changecrypt(self):
if self.crypt.get()=='Encrypt':
self.entry.config(show='*')
self.crypt.set('Decrypt')
self.btn2.config(text = "{} Text in Entry Field".format(self.crypt.get()))
else:
self.entry.config(show='')
self.crypt.set('Encrypt')
self.btn2.config(text = "{} Text in Entry Field".format(self.crypt.get()))
示例13: btn1func
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def btn1func(self):
self.entry.delete(0, tk.END) # delete all from 0 to END character in Entry Widget
示例14: preferences
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
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
#
示例15: add_entry
# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Entry [as 别名]
def add_entry(self, variable, row, column, **kwargs):
name = self._canonicalize(variable)
extra = "" if kwargs.get("kind") != "password" else ', show="*"'
create = "self.{}Entry = ttk.Entry(self{})".format(name, extra)
layout = """self.{}Entry.grid(row={}, column={}, sticky=(\
tk.W, tk.E), padx="0.75m", pady="0.75m")""".format(name, row, column)
self.statements.extend((create, layout))