本文整理汇总了Python中tkinter.Entry.focus_force方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.focus_force方法的具体用法?Python Entry.focus_force怎么用?Python Entry.focus_force使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Entry
的用法示例。
在下文中一共展示了Entry.focus_force方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_random_swiss
# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import focus_force [as 别名]
def new_random_swiss(main):
players = []
def add_player(event):
if e.get() is "":
return
players.append(e.get())
Lb.delete(0,END)
for x in players:
Lb.insert(0,x)
e.delete(0,END)
def remove_player():
l=len(players)-1
if Lb.curselection():
for x in Lb.curselection():
Lb.delete(x)
players.pop(l-x)
else:
Lb.delete(0)
players.pop(-1)
Lb.delete(0,END)
for x in players:
Lb.insert(0,x)
top = Toplevel(main)
top.title("New Random Swiss")
top.bind("<Return>",add_player)
center_size(top,360,180)
Label(top, text='Name:').grid(row=0,column=0)
e = Entry(top,width=12)
e.grid(row=0,column=1)
e.focus_force()
Button(top,text='Add', command=lambda:add_player(None) ).grid(row=1,column=0)
Button(top,text='Remove', command=remove_player ).grid(row=1,column=1)
Button(top,text='Cancel', command=top.destroy ).grid(row=2,column=0)
Button(top,text='Finish', command=lambda:create_single_swiss(players,main)).grid(row=2,column=1)
Sb = Scrollbar(top)
Sb.grid(row=0,column=3,rowspan=3)
Lb = Listbox(top,selectmode=EXTENDED,yscrollcommand=Sb.set)
Lb.grid(row=0,rowspan=3,column=2)
Sb.config(command=Lb.yview)