本文整理汇总了Python中tkinter.ttk.Button.focus_set方法的典型用法代码示例。如果您正苦于以下问题:Python Button.focus_set方法的具体用法?Python Button.focus_set怎么用?Python Button.focus_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Button
的用法示例。
在下文中一共展示了Button.focus_set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import focus_set [as 别名]
def __init__(self, parent=None, title="", message="", button="Ok", image=None, **options):
"""
Create a message box with one button:
parent: parent of the toplevel window
title: message box title
message: message box text
button: message displayed on the button
image: image displayed at the left of the message
**options: other options to pass to the Toplevel.__init__ method
"""
Toplevel.__init__(self, parent, **options)
self.transient(parent)
self.resizable(False, False)
self.title(title)
if image:
Label(self, text=message, wraplength=335,
font="Sans 11", compound="left", image=image).grid(row=0, padx=10, pady=10)
else:
Label(self, text=message, wraplength=335,
font="Sans 11").grid(row=0, padx=10, pady=10)
b = Button(self, text=button, command=self.destroy)
b.grid(row=1, padx=10, pady=10)
self.grab_set()
b.focus_set()
self.wait_window(self)
示例2: __init__
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import focus_set [as 别名]
def __init__(self, parent, title, imageFile, body):
super(DialogAbout, self).__init__(parent)
self.parent = parent
parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
dialogX = int(parentGeometry.group(3))
dialogY = int(parentGeometry.group(4))
self.transient(self.parent)
self.title(title)
frame = Frame(self)
image = PhotoImage(file=imageFile)
aboutImage = Label(frame, image=image)
aboutBody = Label(frame, text=body, wraplength=500)
okButton = Button(frame, text=_("OK"), command=self.ok)
okButton.focus_set()
aboutImage.grid(row=0, column=0, sticky=NW, pady=20, padx=16)
aboutBody.grid(row=0, column=1, columnspan=2, sticky=EW, pady=3, padx=0)
okButton.grid(row=1, column=2, sticky=EW, pady=3)
frame.grid(row=0, column=0, sticky=(N,S,E,W))
frame.columnconfigure(1, weight=1)
window = self.winfo_toplevel()
window.columnconfigure(0, weight=1)
self.geometry("+{0}+{1}".format(dialogX+200,dialogY+200))
self.bind("<Alt-u>", lambda *ignore: okButton.focus_set())
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.close)
self.protocol("WM_DELETE_WINDOW", self.close)
self.grab_set()
self.wait_window(self)
示例3: __init__
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import focus_set [as 别名]
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Example Form")
self.pack(fill=BOTH, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='First Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.firstName = Entry(f)
self.firstName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Last Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.lastName = Entry(f)
self.lastName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='Full Name', width=10)
l.pack(side=LEFT, padx=5, pady=5)
self.fullName = Label(f, text='ALEX POOPKIN', width=10)
self.fullName.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
l = Label(f, text='', width=10)
l.pack(side=LEFT, padx=5, pady=0)
self.errorMessage = Label(f, text='Invalid character int the name!', foreground='red', width=30)
self.errorMessage.pack(fill=X, padx=5, expand=True)
f = Frame(self)
f.pack(fill=X)
b = Button(f, text='Close', command=lambda : self.parent.quit())
b.pack(side=RIGHT, padx=5, pady=10)
b['default'] = ACTIVE
b.focus_set()
self.clearButton = Button(f, text='Clear')
self.clearButton.pack(side=RIGHT, padx=5, pady=10)
self.clearButton['state'] = DISABLED
self.sendButton = Button(f, text='Send')
self.sendButton.pack(side=RIGHT, padx=5, pady=10)
示例4: __init__
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import focus_set [as 别名]
def __init__(self, parent, title=None, text=None):
self.had_focus = parent.focus_get()
Toplevel.__init__(self, parent)
if title:
self.title(title)
stext = ScrolledText(self, background="gray")
stext.pack(padx=5, pady=5)
if text is not None:
stext.insert("end", text)
stext["state"] = "disabled"
separ = Separator(self, orient="horizontal")
separ.pack(expand=1, fill="x")
b = Button(self, text=_("OK"), width=10,
command=self.destroy, default="active")
self.bind("<Escape>", self.destroy)
b.pack()
self.protocol("WM_DELETE_WINDOW", self.destroy)
b.focus_set()
self.grab_set()
self.wait_window()
示例5: _license
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import focus_set [as 别名]
def _license(self):
""" affiche la licence dans une nouvelle fenêtre """
def close():
""" ferme la fenêtre """
self.focus_set()
fen.destroy()
fen = Toplevel(self)
fen.title(_("License"))
fen.transient(self)
fen.protocol("WM_DELETE_WINDOW", close)
fen.resizable(0, 0)
fen.grab_set()
# set_icon(fen)
texte = Text(fen, width=50, height=18)
texte.pack()
texte.insert("end",
_("Sudoku-Tk is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\n"))
texte.insert("end",
_("Sudoku-Tk is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\n"))
texte.insert("end",
_("You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/."))
i = int(texte.index("5.end").split(".")[1])
texte.tag_add("link", "5.%i" % (i - 29), "5.%i" % (i - 1))
texte.tag_configure("link", foreground="#0000ff", underline=1)
texte.tag_bind("link", "<Button - 1>",
lambda event: webOpen("http://www.gnu.org/licenses/"))
texte.tag_bind("link", "<Enter>",
lambda event: texte.config(cursor="hand1"))
texte.tag_bind("link",
"<Leave>", lambda event: texte.config(cursor=""))
texte.configure(state="disabled", wrap="word")
b_close = Button(fen, text=_("Close"), command=close)
b_close.pack(side="bottom")
b_close.focus_set()
fen.wait_window(fen)