本文整理匯總了Python中horizons.gui.widgets.imagebutton.ImageButton.mapEvents方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageButton.mapEvents方法的具體用法?Python ImageButton.mapEvents怎麽用?Python ImageButton.mapEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizons.gui.widgets.imagebutton.ImageButton
的用法示例。
在下文中一共展示了ImageButton.mapEvents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw_widget
# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import mapEvents [as 別名]
def draw_widget(self):
"""
Updates whole messagewidget (all messages): draw icons.
Inactive messages need their icon hovered to display their text again
"""
button_space = self.widget.findChild(name="button_space")
button_space.removeAllChildren() # Remove old buttons
for index, message in enumerate(self.active_messages):
if (self.item + index) >= len(self.active_messages):
# Only display most recent notifications
continue
button = ImageButton()
button.name = str(index)
button.path = message.path
# show text on hover
events = {
button.name + "/mouseEntered": Callback(self.show_text, index),
button.name + "/mouseExited": self.hide_text,
}
# init callback to something callable to improve robustness
callback = Callback(lambda: None)
if message.x is not None and message.y is not None:
# move camera to source of event on click, if there is a source
callback = Callback.ChainedCallbacks(
callback, # this makes it so the order of callback assignment doesn't matter
Callback(self.session.view.center, message.x, message.y),
Callback(self.session.ingame_gui.minimap.highlight, (message.x, message.y) )
)
if message.type == "logbook":
# open logbook to relevant page
callback = Callback.ChainedCallbacks(
callback, # this makes it so the order of callback assignment doesn't matter
Callback(self.session.ingame_gui.logbook.show, message.created)
)
if callback:
events[button.name] = callback
button.mapEvents(events)
button_space.addChild(button)
button_space.resizeToContent()
self.widget.size = button_space.size