本文整理汇总了Python中fife.extensions.pychan.widgets.Icon.hide方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.hide方法的具体用法?Python Icon.hide怎么用?Python Icon.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fife.extensions.pychan.widgets.Icon
的用法示例。
在下文中一共展示了Icon.hide方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import hide [as 别名]
class Background:
"""
Display a centered background image on top of a black screen.
"""
def __init__(self):
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
self.bg_images = deque(available_images)
latest_bg = horizons.globals.fife.get_uh_setting("LatestBackground")
try:
# If we know the current background from an earlier session,
# show all other available ones before picking that one again.
self.bg_images.remove(latest_bg)
self.bg_images.append(latest_bg)
except ValueError:
pass
(res_width, res_height) = horizons.globals.fife.get_fife_setting('ScreenResolution').split('x')
self._black_box = Container()
self._black_box.size = int(res_width), int(res_height)
self._black_box.base_color = (0, 0, 0, 255)
self._image = Icon(position_technique='center:center')
self.rotate_image()
def rotate_image(self):
"""Select next background image to use in the game menu.
Triggered by the "Change background" main menu button.
"""
self.bg_images.rotate(1)
self._image.image = self.bg_images[0]
# Save current background choice to settings.
# This keeps the background image consistent between sessions.
horizons.globals.fife.set_uh_setting("LatestBackground", self.bg_images[0])
horizons.globals.fife.save_settings()
def show(self):
self._black_box.show()
self._image.show()
def hide(self):
self._image.hide()
self._black_box.hide()
@property
def visible(self):
return self._image.isVisible()
示例2: Gui
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import hide [as 别名]
class Gui(object):
"""This class handles all the out of game menu, like the main and pause menu, etc.
"""
log = logging.getLogger("gui")
def __init__(self):
self.mainlistener = MainListener(self)
self.windows = WindowManager()
# temporary aliases for compatibility with rest of the code
self.show_popup = self.windows.show_popup
self.show_error_popup = self.windows.show_error_popup
self._background = Icon(image=self._get_random_background(),
position_technique='center:center')
self._background.show()
self.subscribe()
self.singleplayermenu = SingleplayerMenu(self.windows)
self.multiplayermenu = MultiplayerMenu(self, self.windows)
self.help_dialog = HelpDialog(self.windows)
self.loadingscreen = LoadingScreen()
self.settings_dialog = SettingsDialog(self.windows)
self.mainmenu = MainMenu(self, self.windows)
self.fps_display = FPSDisplay()
def subscribe(self):
"""Subscribe to the necessary messages."""
GuiAction.subscribe(self._on_gui_action)
def unsubscribe(self):
GuiAction.unsubscribe(self._on_gui_action)
def show_main(self):
"""Shows the main menu """
if not self._background.isVisible():
self._background.show()
self.windows.show(self.mainmenu)
def show_select_savegame(self, mode):
window = SelectSavegameDialog(mode, self.windows)
return self.windows.show(window)
def load_game(self):
saved_game = self.show_select_savegame(mode='load')
if saved_game is None:
return False # user aborted dialog
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def on_help(self):
self.windows.toggle(self.help_dialog)
def show_credits(self):
"""Shows the credits dialog. """
window = CreditsPickbeltWidget(self.windows)
self.windows.show(window)
def on_escape(self):
self.windows.on_escape()
def close_all(self):
self.windows.close_all()
self._background.hide()
def show_loading_screen(self):
if not self._background.isVisible():
self._background.show()
self.windows.show(self.loadingscreen)
def randomize_background(self):
"""Randomly select a background image to use. This function is triggered by
change background button from main menu."""
self._background.image = self._get_random_background()
def _get_random_background(self):
"""Randomly select a background image to use through out the game menu."""
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
#get latest background
latest_background = horizons.globals.fife.get_uh_setting("LatestBackground")
#if there is a latest background then remove it from available list
if latest_background is not None:
available_images.remove(latest_background)
background_choice = random.choice(available_images)
#save current background choice
horizons.globals.fife.set_uh_setting("LatestBackground", background_choice)
horizons.globals.fife.save_settings()
return background_choice
def _on_gui_action(self, msg):
AmbientSoundComponent.play_special('click')
def show_editor_start_menu(self):
editor_start_menu = EditorStartMenu(self.windows)
self.windows.show(editor_start_menu)
示例3: Window
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import hide [as 别名]
class Window(object):
def __init__(self, windows=None):
# Reference to the window manager. Use it to show new windows or close
# this window.
self._windows = windows
self._modal_background = None
def show(self, **kwargs):
"""Show the window.
After this call, the window should be visible. If you decide to not show
the window here (e.g. an error occurred), you'll need to call
`self._windows.close()` to remove the window from the manager.
"""
raise NotImplementedError
def hide(self):
"""Hide the window.
After this call, the window should not be visible anymore. However, it remains
in the stack of open windows and will be visible once it becomes the topmost
window again.
You should *never* call this directly in your code, other than in `close()`
when you overwrote it in your subclass.
"""
raise NotImplementedError
def close(self):
"""Closes the window.
You should *never* call this directly in your code. Use `self._windows.close()`
to ask the WindowManager to remove the window instead.
"""
self.hide()
def on_escape(self):
"""Define what happens when ESC is pressed.
By default, the window will be closed.
"""
self._windows.close()
def on_return(self):
"""Define what happens when RETURN is pressed."""
pass
def _show_modal_background(self):
"""
Loads transparent background that de facto prohibits access to other
gui elements by eating all input events.
"""
height = horizons.globals.fife.engine_settings.getScreenHeight()
width = horizons.globals.fife.engine_settings.getScreenWidth()
image = horizons.globals.fife.imagemanager.loadBlank(width, height)
image = fife.GuiImage(image)
self._modal_background = Icon(image=image)
self._modal_background.position = (0, 0)
self._modal_background.show()
def _hide_modal_background(self):
self._modal_background.hide()
示例4: Gui
# 需要导入模块: from fife.extensions.pychan.widgets import Icon [as 别名]
# 或者: from fife.extensions.pychan.widgets.Icon import hide [as 别名]
class Gui(object):
"""This class handles all the out of game menu, like the main and pause menu, etc.
"""
log = logging.getLogger("gui")
def __init__(self):
self.mainlistener = MainListener(self)
self.windows = WindowManager()
# temporary aliases for compatibility with rest of the code
self.show_popup = self.windows.show_popup
self.show_error_popup = self.windows.show_error_popup
# Main menu background image setup.
available_images = glob.glob('content/gui/images/background/mainmenu/bg_*.png')
self.bg_images = deque(available_images)
latest_bg = horizons.globals.fife.get_uh_setting("LatestBackground")
try:
# If we know the current background from an earlier session,
# show all other available ones before picking that one again.
self.bg_images.remove(latest_bg)
self.bg_images.append(latest_bg)
except ValueError:
pass
self._background = Icon(position_technique='center:center')
self.rotate_background()
self._background.show()
self.singleplayermenu = SingleplayerMenu(self.windows)
self.multiplayermenu = MultiplayerMenu(self, self.windows)
self.help_dialog = HelpDialog(self.windows)
self.loadingscreen = LoadingScreen()
self.settings_dialog = SettingsDialog(self.windows)
self.mainmenu = MainMenu(self, self.windows)
self.fps_display = FPSDisplay()
def show_main(self):
"""Shows the main menu """
GuiAction.subscribe(self._on_gui_action)
if not self._background.isVisible():
self._background.show()
self.windows.show(self.mainmenu)
def show_select_savegame(self, mode):
window = SelectSavegameDialog(mode, self.windows)
return self.windows.show(window)
def load_game(self):
saved_game = self.show_select_savegame(mode='load')
if saved_game is None:
return False # user aborted dialog
options = StartGameOptions(saved_game)
horizons.main.start_singleplayer(options)
return True
def on_help(self):
self.windows.toggle(self.help_dialog)
def show_credits(self):
"""Shows the credits dialog. """
window = CreditsPickbeltWidget(self.windows)
self.windows.show(window)
def on_escape(self):
self.windows.on_escape()
def on_return(self):
self.windows.on_return()
def close_all(self):
GuiAction.discard(self._on_gui_action)
self.windows.close_all()
self._background.hide()
def show_loading_screen(self):
if not self._background.isVisible():
self._background.show()
self.windows.show(self.loadingscreen)
def rotate_background(self):
"""Select next background image to use in the game menu.
Triggered by the "Change background" main menu button.
"""
# Note: bg_images is a deque.
self.bg_images.rotate()
self._background.image = self.bg_images[0]
# Save current background choice to settings.
# This keeps the background image consistent between sessions.
horizons.globals.fife.set_uh_setting("LatestBackground", self.bg_images[0])
horizons.globals.fife.save_settings()
def _on_gui_action(self, msg):
AmbientSoundComponent.play_special('click')
def show_editor_start_menu(self):
#.........这里部分代码省略.........