本文整理汇总了Python中popup.Popup.deiconify方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.deiconify方法的具体用法?Python Popup.deiconify怎么用?Python Popup.deiconify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popup.Popup
的用法示例。
在下文中一共展示了Popup.deiconify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Menu
# 需要导入模块: from popup import Popup [as 别名]
# 或者: from popup.Popup import deiconify [as 别名]
class Menu(object):
def __init__(self, items, x, y, alwaysHighlight = False, delegate = None, *args, **kwargs):
# activestyle = tk.None suppresses the box in OS X and underline elsewhere.
defaults = {'activestyle': tk.NONE,
'borderwidth': 0,
'exportselection': False,
# Approximate the colors used in OS X:
'selectbackground': '#0950CF',
'selectforeground': '#FFF',
# Normally tk has a weird fake-3D effect - remove that.
'relief': tk.FLAT}
self._popup = Popup(x = x, y = y)
self._listbox = tk.Listbox(self._popup, *args, **dict(defaults, **kwargs))
self._listbox.pack()
self.alwaysHighlight = alwaysHighlight
self._priorSelection = None
self.delegate = delegate
self.items = items
self._listbox.bind('<<ListboxSelect>>', self._selectionChanged)
self._listbox.bind('<Return>', self.selectHighlighted)
self._listbox.bind('<Button-1>', self.selectHighlighted)
self._listbox.bind('<Enter>', self._snapHighlightToMouse)
self._listbox.bind('<Motion>', self._snapHighlightToMouse)
if not self.alwaysHighlight:
self._listbox.bind('<Leave>', self.unhighlight)
@property
def items(self):
return self.__items
@items.setter
def items(self, items):
if items == getattr(self, '__items', None):
return
self._listbox['height'] = len(items)
self._listbox['width' ] = max(len(item) for item in items)
self.__items = items
self._listbox.delete(0, tk.END)
for item in items:
self._listbox.insert(tk.END, str(item))
if self.alwaysHighlight:
self._listbox.selection_set(0)
self._selectionChanged()
@property
def columns(self):
return self._listbox['width']
@columns.setter
def columns(self, columns):
self._listbox['width'] = columns
def destroy(self):
self._listbox.destroy()
self._popup .destroy()
def _snapHighlightToMouse(self, event):
''' This is a private method. Don't touch it. '''
self._setHighlight(self._listbox.nearest(event.y))
def _setHighlight(self, index):
''' This is a private method. Don't touch it. '''
self._listbox.selection_clear(0, tk.END)
self._listbox.selection_set(index)
self._selectionChanged()
def unhighlight(self, *args):
self._listbox.selection_clear(0, tk.END)
def _selectionChanged(self, *args):
''' This is a private method. Don't touch it. '''
currentSelection = self.items[self._listbox.curselection()[0]]
if currentSelection == self._priorSelection:
return
self._priorSelection = currentSelection
self.onHighlight(currentSelection)
def selectHighlighted(self, *args):
'''
Triggers onSelect for the highlighted item.
'''
self.onSelect(self.items[self._listbox.curselection()[0]])
def moveHighlight(self, amount):
newIndex = self._listbox.curselection()[0] + amount
newIndex = max(0, min(newIndex, len(self.items) - 1))
self._setHighlight(newIndex)
def hide(self):
self._popup.withdraw()
def show(self):
self._popup.deiconify()
@event
#.........这里部分代码省略.........