本文整理汇总了Python中horizons.gui.tabs.TabWidget类的典型用法代码示例。如果您正苦于以下问题:Python TabWidget类的具体用法?Python TabWidget怎么用?Python TabWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TabWidget类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_menu
def show_menu(self, jump_to_tabclass=None):
"""Shows tabs from self.__class__.tabs, if there are any.
@param jump_to_tabclass: open the first tab that is a subclass to this parameter
"""
# this local import prevents circular imports
from horizons.gui.tabs import TabWidget
tablist = None
if self.owner == self.session.world.player:
tablist = self.__class__.tabs
else: # this is an enemy instance with respect to the local player
tablist = self.__class__.enemy_tabs
if tablist:
tabs = [ tabclass(self) for tabclass in tablist if tabclass.shown_for(self) ]
tabwidget = TabWidget(self.session.ingame_gui, tabs=tabs)
if jump_to_tabclass:
num = None
for i in xrange( len(tabs) ):
if isinstance(tabs[i], jump_to_tabclass):
num = i
break
if num is not None:
tabwidget._show_tab(num)
self.session.ingame_gui.show_menu( tabwidget )
示例2: show_menu
def show_menu(self, jump_to_tabclass=None):
"""Shows tabwidget tabs of this instance.
Opens the first such tab unless jump_to_tabclass specifies otherwise.
@param jump_to_tabclass: open the first tab that is a subclass to this parameter
"""
from horizons.gui.tabs import TabWidget
tablist = None
if self.instance.owner is not None and self.instance.owner.is_local_player:
tablist = self.tabs
else: # this is an enemy instance with respect to the local player
tablist = self.enemy_tabs
if not tablist:
return
tabclasses = [tabclass for tabclass in tablist if tabclass.shown_for(self.instance)]
try:
active_tab_index = tabclasses.index(self.active_tab)
except ValueError:
active_tab_index = None
tabs = [tabclass(self.instance) for tabclass in tabclasses]
tabwidget = TabWidget(self.session.ingame_gui, tabs=tabs, active_tab=active_tab_index)
if jump_to_tabclass:
for i, tab in enumerate(tabs):
if isinstance(tab, jump_to_tabclass):
tabwidget.show_tab(i)
break
self.session.ingame_gui.show_menu(tabwidget)
示例3: show_menu
def show_menu(self, jump_to_tabclass=None):
"""Shows tabs from self.__class__.tabs, if there are any.
@param jump_to_tabclass: open the first tab that is a subclass to this parameter
"""
from horizons.gui.tabs import TabWidget
tablist = None
if self.instance.owner is not None and self.instance.owner.is_local_player:
tablist = self.tabs
else: # this is an enemy instance with respect to the local player
tablist = self.enemy_tabs
if tablist:
tabs = [ tabclass(self.instance) for tabclass in tablist if
tabclass.shown_for(self.instance) ]
tabwidget = TabWidget(self.session.ingame_gui, tabs=tabs)
if jump_to_tabclass:
for i, tab in enumerate(tabs):
if isinstance(tab, jump_to_tabclass):
tabwidget._show_tab(i)
break
self.session.ingame_gui.show_menu( tabwidget )
示例4: IngameGui
class IngameGui(LivingObject):
minimap = livingProperty()
keylistener = livingProperty()
message_widget = livingProperty()
def __init__(self, session):
self.session = session
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
# used by NavigationTool
LastActivePlayerSettlementManager.create_instance(self.session)
# Mocks needed to act like the real IngameGui
self.show_menu = lambda x: 0
self.hide_menu = lambda: 0
# a logbook Dummy is necessary for message_widget to work
self.logbook = DummyLogbook()
self.mainhud = load_uh_widget('minimap.xml')
self.mainhud.position_technique = "right+0:top+0"
icon = self.mainhud.findChild(name="minimap")
self.minimap = Minimap(icon,
targetrenderer=horizons.globals.fife.targetrenderer,
imagemanager=horizons.globals.fife.imagemanager,
session=self.session,
view=self.session.view)
self.mainhud.mapEvents({
'zoomIn': self.session.view.zoom_in,
'zoomOut': self.session.view.zoom_out,
'rotateRight': Callback.ChainedCallbacks(self.session.view.rotate_right, self.minimap.rotate_right),
'rotateLeft': Callback.ChainedCallbacks(self.session.view.rotate_left, self.minimap.rotate_left),
'gameMenuButton': self.toggle_pause,
})
self.mainhud.show()
ZoomChanged.subscribe(self._update_zoom)
# Hide unnecessary buttons in hud
for widget in ("build", "speedUp", "speedDown", "destroy_tool", "diplomacyButton", "logbook"):
self.mainhud.findChild(name=widget).hide()
self.windows = WindowManager()
self.message_widget = MessageWidget(self.session)
self.pausemenu = PauseMenu(self.session, self, self.windows, in_editor_mode=True)
self.help_dialog = HelpDialog(self.windows)
def end(self):
self.mainhud.mapEvents({
'zoomIn': None,
'zoomOut': None,
'rotateRight': None,
'rotateLeft': None,
'gameMenuButton': None
})
self.mainhud.hide()
self.mainhud = None
self._settings_tab.hide()
self._settings_tab = None
self.windows.close_all()
self.minimap = None
self.keylistener = None
LastActivePlayerSettlementManager().remove()
LastActivePlayerSettlementManager.destroy_instance()
ZoomChanged.unsubscribe(self._update_zoom)
if self.cursor:
self.cursor.remove()
self.cursor.end()
self.cursor = None
super(IngameGui, self).end()
def handle_selection_group(self, num, ctrl_pressed):
# Someday, maybe cool stuff will be possible here.
# That day is not today, I'm afraid.
pass
def toggle_pause(self):
self.windows.toggle(self.pausemenu)
def toggle_help(self):
self.windows.toggle(self.help_dialog)
def load(self, savegame):
self.minimap.draw()
self.cursor = SelectionTool(self.session)
def setup(self):
"""Called after the world editor was initialized."""
self._settings_tab = TabWidget(self, tabs=[SettingsTab(self.session.world_editor, self)])
self._settings_tab.show()
def minimap_to_front(self):
"""Make sure the full right top gui is visible and not covered by some dialog"""
#.........这里部分代码省略.........
示例5: setup
def setup(self):
"""Called after the world editor was initialized."""
self._settings_tab = TabWidget(self, tabs=[SettingsTab(self.session.world_editor, self)])
self._settings_tab.show()
示例6: IngameGui
class IngameGui(LivingObject):
minimap = livingProperty()
keylistener = livingProperty()
def __init__(self, session, main_gui):
self.session = session
self.main_gui = main_gui
self.cursor = None
self.coordinates_tooltip = None
self.keylistener = IngameKeyListener(self.session)
# used by NavigationTool
LastActivePlayerSettlementManager.create_instance(self.session)
# Mocks needed to act like the real IngameGui
self.show_menu = Dummy
self.hide_menu = Dummy
self.mainhud = load_uh_widget('minimap.xml')
self.mainhud.position_technique = "right+0:top+0"
icon = self.mainhud.findChild(name="minimap")
self.minimap = Minimap(icon,
targetrenderer=horizons.globals.fife.targetrenderer,
imagemanager=horizons.globals.fife.imagemanager,
session=self.session,
view=self.session.view)
self.mainhud.mapEvents({
'zoomIn': self.session.view.zoom_in,
'zoomOut': self.session.view.zoom_out,
'rotateRight': Callback.ChainedCallbacks(self.session.view.rotate_right, self.minimap.rotate_right),
'rotateLeft': Callback.ChainedCallbacks(self.session.view.rotate_left, self.minimap.rotate_left),
'gameMenuButton': self.toggle_pause,
})
self.mainhud.show()
self.session.view.add_change_listener(self._update_zoom)
# Hide unnecessary buttons in hud
for widget in ("build", "speedUp", "speedDown", "destroy_tool", "diplomacyButton", "logbook"):
self.mainhud.findChild(name=widget).hide()
self.save_map_dialog = SaveMapDialog(self.main_gui, self, self.session)
self.pausemenu = PauseMenu(self.session, self.main_gui, self, in_editor_mode=True)
def end(self):
self.mainhud.mapEvents({
'zoomIn': None,
'zoomOut': None,
'rotateRight': None,
'rotateLeft': None,
'gameMenuButton': None
})
self.minimap = None
self.keylistener = None
LastActivePlayerSettlementManager().remove()
LastActivePlayerSettlementManager.destroy_instance()
self.session.view.remove_change_listener(self._update_zoom)
if self.cursor:
self.cursor.remove()
self.cursor.end()
self.cursor = None
super(IngameGui, self).end()
def toggle_pause(self):
self.pausemenu.toggle()
def load(self, savegame):
self.minimap.draw()
self.cursor = SelectionTool(self.session)
def setup(self):
"""Called after the world editor was initialized."""
self._settings_tab = TabWidget(self, tabs=[SettingsTab(self.session.world_editor, self)])
self._settings_tab.show()
def minimap_to_front(self):
"""Make sure the full right top gui is visible and not covered by some dialog"""
self.mainhud.hide()
self.mainhud.show()
def show_save_map_dialog(self):
"""Shows a dialog where the user can set the name of the saved map."""
self.save_map_dialog.show()
def on_escape(self):
pass
def on_key_press(self, action, evt):
_Actions = KeyConfig._Actions
if action == _Actions.ESCAPE:
return self.on_escape()
def set_cursor(self, which='default', *args, **kwargs):
"""Sets the mousetool (i.e. cursor).
This is done here for encapsulation and control over destructors.
#.........这里部分代码省略.........