本文整理汇总了Python中tkinter.Listbox.focus_set方法的典型用法代码示例。如果您正苦于以下问题:Python Listbox.focus_set方法的具体用法?Python Listbox.focus_set怎么用?Python Listbox.focus_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Listbox
的用法示例。
在下文中一共展示了Listbox.focus_set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import focus_set [as 别名]
def initUI(self):
self.parent.title("TVstream manager")
self.stytle = ttk.Style()
self.pack(fill=BOTH, expand=1)
self.columnconfigure(0, weight=1, pad=2)
self.columnconfigure(2, weight=1, pad=2)
self.columnconfigure(4, pad=7)
#self.rowconfigure(3, weight=1)
#self.rowconfigure(4, weight=1, pad=7)
lbll = Label(self, text="Lingua")
lbll.grid(row=0,column=0,sticky=W, pady=4, padx=5)
lble = Label(self, text="Emittenti")
lble.grid(row=0,column=2,sticky=W, pady=1, padx=5)
global langlst
scrollang = Scrollbar(self)
langlst = Listbox(self,font='Arial 9',yscrollcommand=scrollang.set)
scrollang.config(command = langlst.yview)
for i in lingue:
langlst.insert(END, i)
langlst.focus_set()
langlst.bind("<<ListboxSelect>>", self.onSelectLang)
langlst.grid(row=1,column=0, columnspan=2, padx=6,sticky=E+W+S+N)
scrollang.grid(row=1,column=1, sticky=E+S+N)
global emitlst
scrollemit = Scrollbar(self)
emitlst = Listbox(self,font='Arial 9',yscrollcommand=scrollemit.set)
scrollemit.config(command = emitlst.yview )
emitlst.bind("<<ListboxSelect>>", self.onSelectEmittente)
emitlst.grid(row=1,column=2, columnspan=2, padx=5,sticky=E+W+S+N)
scrollemit.grid(row=1,column=3,sticky=E+S+N)
lbltxt = Label(self, text="Output log")
lbltxt.grid(row=2,column=0, columnspan=3, sticky=W, pady=4, padx=5)
global area
area = Text(self,height=10,font='Arial 9')
area.grid(row=3, column=0, columnspan=5, rowspan=1, padx=5, sticky=E+W+S+N)
scrolltxt = Scrollbar(self)
scrolltxt.config(command = area.yview)
scrolltxt.grid(row=3,column=4, columnspan=1, rowspan=1, sticky=E+N+S)
play = Button(self, text='Play', command=self.playUrl,
bg='gray', fg='black')
play.grid(row=1,column=4,padx=4,sticky=E+W)
示例2: ListboxVidget
# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import focus_set [as 别名]
#.........这里部分代码省略.........
self.handler_notify(self.ITEMCUR_CHANGE_SOON, notify_arg)
# If old active index is valid
if self.index_is_valid(old_indexcur):
# Set old active item's background color to normal color
self._listbox.itemconfig(old_indexcur, background=self._normal_bg)
# Set old active item's foreground color to normal color
self._listbox.itemconfig(old_indexcur, foreground=self._normal_fg)
# Cache new active index
self._indexcur = index
# Clear listbox widget's selection
self._listbox.selection_clear(0, END)
# Set listbox widget's selection
self._listbox.selection_set(index)
# Set listbox widget's activated index
self._listbox.activate(index)
# If new active index is valid
if index != -1:
# Set new active item's background color to active color
self._listbox.itemconfig(index, background=self._active_bg)
# Set new active item's foreground color to active color
self._listbox.itemconfig(index, foreground=self._active_fg)
# If set focus
if focus:
# Set focus on the listbox widget
self._listbox.focus_set()
# If new active index is valid
if index != -1:
# Make the active item visible
self._listbox.see(index)
# If notify events
if notify:
# Notify post-change event
self.handler_notify(self.ITEMCUR_CHANGE_DONE, notify_arg)
# Set resetting flag off
self._is_resetting = False
# Set changing flag off
self._is_changing = False
def indexcur_set_by_event(
self,
event,
focus=False,
notify=True,
notify_arg=None,
):
"""
Set active index using a Tkinter event object that contains coordinates
of the active item.
@param event: Tkinter event object.
@param focus: Whether set focus on the listbox widget.