def __init__(self, application, testmanager): """ Initializes all listeners and registers itself with the eventmanager. """ self._application = application self._engine = self._application.engine self._eventmanager = self._engine.getEventManager() self._testmanager = testmanager fife.IKeyListener.__init__(self) self._eventmanager.addKeyListener(self) fife.ICommandListener.__init__(self) self._eventmanager.addCommandListener(self) self._console = get_manager().getConsole() fife.ConsoleExecuter.__init__(self) self._console.setConsoleExecuter(self) keyfilter = KeyFilter([fife.Key.ESCAPE, fife.Key.F10, fife.Key.PRINT_SCREEN]) keyfilter.__disown__() self._eventmanager.setKeyFilter(keyfilter) self.quit = False # Init Pychan pychan.loadFonts("data/fonts/freefont.fontdef") pychan.loadFonts("data/fonts/samanata.fontdef") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self._application.mainLoop, self._application.breakFromMainLoop)
def __init__(self, settings_file='settings-dist.xml'): setting = Setting(settings_file=settings_file) super(GuichanDesignerApplication, self).__init__(setting=setting) # PyChanDesigner fonts pychan.loadFonts('fonts/freefont.fontdef') pychan.setupModalExecution(self.mainLoop, self.breakFromMainLoop) # pychan default settings need an overwrite, because we don't like some aspects (like opaque widgets) screen_width, screen_height = \ [int(dimension) for dimension in setting.get('FIFE', 'ScreenResolution').split('x')] self.xml_script_path = '' self.active_widget = None self.selected_widget = None self.widget_stack = [] self.logger = logging.getLogger('PychanDesignerApplication') self.xml_editor = pychan.loadXML('gui/xml_editor.xml') self.console = pychan.loadXML('gui/console.xml') with file('gui/pychan_designer.xml') as xml_file: self.gui = pychan.loadXML(xml_file) self.gui.min_size = (screen_width, screen_height) self.gui.max_size = (screen_width, screen_height) editor = self.gui.findChild(name='editor') editor.content = self.xml_editor self.gui.mapEvents( { 'exitButton': self.quit, 'reloadButton': self.reloadXml, 'applyButton': self.applyXml, 'saveButton': self.saveXml, 'xmlEditorTab': self.showXmlEditor, 'consoleTab': self.showConsole, } ) self.gui.adaptLayout() self.gui.show()
def __init__(self, setting=None): if setting: self._setting = setting else: self._setting = Setting(app_name="", settings_file="./settings.xml", settings_gui_xml="") self.engine = fife.Engine() self.initLogging() self.loadSettings() self.engine.init() """ we are giving users a valid screen resolution option that is supported """ screen_modes = self.engine.getDeviceCaps().getSupportedScreenModes() resolutions = list( set([(mode.getWidth(), mode.getHeight()) for mode in screen_modes])) resolutions = [ "{0}x{1}".format(item[0], item[1]) for item in sorted(resolutions)[1:] ] self._setting.setValidResolutions(resolutions) pychan.init(self.engine, debug=self._finalSetting['PychanDebug']) pychan.setupModalExecution(self.mainLoop, self.breakFromMainLoop) self.quitRequested = False self.breakRequested = False self.returnValues = []
def __init__(self, setting=None): if setting: self._setting = setting else: self._setting = Setting(app_name="", settings_file="./settings.xml", settings_gui_xml="") self.engine = fife.Engine() self.initLogging() self.loadSettings() self.engine.init() """ we are giving users a valid screen resolution option that is supported """ screen_modes = self.engine.getDeviceCaps().getSupportedScreenModes() resolutions = list(set([(mode.getWidth(), mode.getHeight()) for mode in screen_modes])) resolutions = ["{0}x{1}".format(item[0], item[1]) for item in sorted(resolutions)[1:]] self._setting.setValidResolutions(resolutions) pychan.init(self.engine, debug = self._finalSetting['PychanDebug']) pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) self.quitRequested = False self.breakRequested = False self.returnValues = []
def __init__(self): # Let the ApplicationBase initialise FIFE super(DemoApplication,self).__init__() # Init Pychan pychan.loadFonts("fonts/freefont.fontdef") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) # Build the main GUI self.gui = pychan.loadXML('gui/demoapp.xml') self.gui.min_size = self.engine.getRenderBackend().getScreenWidth(),self.engine.getRenderBackend().getScreenHeight() eventMap = { 'creditsLink' : self.showCredits, 'closeButton' : self.quit, 'demoList' : self.selectExample, } self.gui.mapEvents(eventMap) # A simple hover-effect for the credits label credits = self.gui.findChild(name="creditsLink") # setEnterCallback is deprecated - we use it here to test it. credits.setEnterCallback(TextSetter(u"CREDITS")) # Note that we can't simply write: # credits.capture(credits._setText(u"Credits"), event_name="mouseExited") # that's because that would call credits._setText _NOW_ and we want to call # it later. credits.capture(lambda : credits._setText(u"Credits"), event_name="mouseExited") # import example modules from dynamic import DynamicExample from styling import StylingExample from sliders import SliderExample from colortester import ColorExample from poc_gui_animation import PocAnimations # Our list of examples # We keep a dictionary of these and fill # the ListBox on the left with its names. self.examples = { 'Absolute Positioning' : PyChanExample('gui/absolute.xml'), 'All Widgets' : PyChanExample('gui/all_widgets.xml'), 'Basic Styling' : StylingExample(), 'Dynamic Widgets' : DynamicExample(), 'Sliders' : SliderExample(), 'ScrollArea' : PyChanExample('gui/scrollarea.xml'), 'Colortester': ColorExample(), 'GuiAnimations' : PocAnimations(), } self.demoList = self.gui.findChild(name='demoList') self.demoList.items = sorted(self.examples.keys()) # Finally show the main GUI self.gui.show() self.currentExample = None self.creditsWidget = None
def create(self, engine, application): self._application = application self._engine = engine self._running = False # Init Pychan pychan.loadFonts("data/fonts/freefont.fontdef") pychan.loadFonts("data/fonts/samanata.fontdef") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self._application.mainLoop, self._application.breakFromMainLoop) # Build the main GUI self.gui = pychan.loadXML('data/gui/demoapp.xml') self.gui.min_size = self._engine.getRenderBackend().getScreenWidth(),self._engine.getRenderBackend().getScreenHeight() eventMap = { 'creditsLink' : self.showCredits, 'closeButton' : self._application.testmanager.stopTest, 'demoList' : self.selectExample, } self.gui.mapEvents(eventMap) # A simple hover-effect for the credits label credits = self.gui.findChild(name="creditsLink") # Note that we can't simply write: # credits.capture(credits._setText(u"CREDITS"), event_name="mouseEntered") # that's because that would call credits._setText NOW and we want to call # it later. credits.capture(lambda : credits._setText(u"CREDITS"), event_name="mouseEntered") # Note that we can't simply write: # credits.capture(credits._setText(u"Credits"), event_name="mouseExited") # that's because that would call credits._setText NOW and we want to call # it later. credits.capture(lambda : credits._setText(u"Credits"), event_name="mouseExited") self._examples = { 'Absolute Positioning' : PyChanExample('data/gui/absolute.xml'), 'All Widgets' : PyChanExample('data/gui/all_widgets.xml'), 'Basic Styling' : StylingExample(), 'Dynamic Widgets' : DynamicExample(), 'Sliders' : SliderExample(), 'ScrollArea' : PyChanExample('data/gui/scrollarea.xml'), 'Colortester': ColorExample(), 'GuiAnimations' : PocAnimations(), 'Show Hide Test' : ShowHideTest(), } self.demoList = self.gui.findChild(name='demoList') self.demoList.items = sorted(self._examples.keys()) self.currentExample = None
def __init__(self, setting=None): if setting: self._setting = setting else: self._setting = Setting(app_name="", settings_file="./settings.xml", settings_gui_xml="") self.engine = fife.Engine() self.loadSettings() self.initLogging() self.engine.init() self._animationloader = XMLAnimationLoader(self.engine.getImagePool(), self.engine.getVFS()) self.engine.getAnimationPool().addResourceLoader(self._animationloader) pychan.init(self.engine, debug=self._setting.get("FIFE", "PychanDebug", False)) pychan.setupModalExecution(self.mainLoop, self.breakFromMainLoop) self.quitRequested = False self.breakRequested = False self.returnValues = []
def __init__(self, application, testmanager): """ Initializes all listeners and registers itself with the eventmanager. """ self._application = application self._engine = self._application.engine self._eventmanager = self._engine.getEventManager() self._testmanager = testmanager fife.IKeyListener.__init__(self) self._eventmanager.addKeyListener(self) fife.ICommandListener.__init__(self) self._eventmanager.addCommandListener(self) self._console = get_manager().getConsole() fife.ConsoleExecuter.__init__(self) self._console.setConsoleExecuter(self) keyfilter = KeyFilter( [fife.Key.ESCAPE, fife.Key.F10, fife.Key.PRINT_SCREEN]) keyfilter.__disown__() self._eventmanager.setKeyFilter(keyfilter) self.quit = False # Init Pychan pychan.loadFonts("data/fonts/freefont.xml") pychan.loadFonts("data/fonts/samanata.xml") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self._application.mainLoop, self._application.breakFromMainLoop)
def __init__(self, setting=None): super(PychanApplicationBase, self).__init__(setting) pychan.init(self.engine, debug=self._finalSetting['PychanDebug']) pychan.setupModalExecution(self.mainLoop, self.breakFromMainLoop)
def __init__(self): # Let the ApplicationBase initialise FIFE super(DemoApplication,self).__init__() # Init Pychan pychan.loadFonts("fonts/freefont.xml") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) # Build the main GUI self.gui = pychan.loadXML('gui/demoapp.xml') self.gui.min_size = self.engine.getRenderBackend().getScreenWidth(),self.engine.getRenderBackend().getScreenHeight() eventMap = { 'creditsLink' : self.showCredits, 'closeButton' : self.quit, 'demoList' : self.selectExample, 'xmlButton' : self.loadRuntimeXML, } self.gui.mapEvents(eventMap) # A simple hover-effect for the credits label credits = self.gui.findChild(name="creditsLink") # Note that we can't simply write: # credits.capture(credits._setText(u"Credits"), event_name="mouseExited") # that's because that would call credits._setText _NOW_ and we want to call # it later. credits.capture(lambda : credits._setText(u"CREDITS"), event_name="mouseEntered") credits.capture(lambda : credits._setText(u"Credits"), event_name="mouseExited") # import example modules from dynamic import DynamicExample from styling import StylingExample from sliders import SliderExample from colortester import ColorExample from poc_gui_animation import PocAnimations from stretching import StretchingExample from tabbedarea import TabbedAreaExample from dynamicgraph import DynamicGraphExample from iconprogressbar import IconProgressBarExample from imageprogressbar import ImageProgressBarExample from modalfocus import ModalFocusExample from showhide import ShowHideExample # Our list of examples # We keep a dictionary of these and fill # the ListBox on the left with its names. self.examples = { 'Absolute Positioning' : PyChanExample('gui/absolute.xml', self), 'Adjusting Container' : PyChanExample('gui/adjustingcontainer.xml'), 'All Widgets' : PyChanExample('gui/all_widgets.xml'), 'Basic Styling' : StylingExample(), 'Circular Box' : PyChanExample('gui/circularcontainer.xml'), 'Dynamic Widgets' : DynamicExample(), 'Sliders' : SliderExample(), 'ScrollArea' : PyChanExample('gui/scrollarea.xml'), 'Colortester': ColorExample(), 'GuiAnimations' : PocAnimations(), 'Tabbed Area' : TabbedAreaExample(), 'Image Stretching' : StretchingExample(), 'Resizable Window' : PyChanExample('gui/resizable.xml'), 'Dock Area' : PyChanExample('gui/dockarea.xml'), 'Graph Widgets' : PyChanExample('gui/graphwidgets.xml'), 'Dynamic Graph' : DynamicGraphExample(), 'Icon Progress Bar' : IconProgressBarExample(), 'Image Progress Bar' : ImageProgressBarExample(), 'Flow Container' : PyChanExample('gui/flowcontainer.xml'), 'Animation Icon' : PyChanExample('gui/animationicon.xml'), 'Modal Focus' : ModalFocusExample(), 'Show and Hide' : ShowHideExample(), } self.demoList = self.gui.findChild(name='demoList') self.demoList.items = sorted(self.examples.keys()) # Finally show the main GUI self.gui.show() self.currentExample = None self.creditsWidget = None
def __init__(self): # Let the ApplicationBase initialise FIFE super(DemoApplication, self).__init__() # Init Pychan pychan.loadFonts("fonts/freefont.fontdef") pychan.manager.setDefaultFont("FreeSans") pychan.setupModalExecution(self.mainLoop, self.breakFromMainLoop) # Build the main GUI self.gui = pychan.loadXML('gui/demoapp.xml') self.gui.min_size = self.engine.getRenderBackend().getScreenWidth( ), self.engine.getRenderBackend().getScreenHeight() eventMap = { 'creditsLink': self.showCredits, 'closeButton': self.quit, 'demoList': self.selectExample, } self.gui.mapEvents(eventMap) # A simple hover-effect for the credits label credits = self.gui.findChild(name="creditsLink") # Note that we can't simply write: # credits.capture(credits._setText(u"Credits"), event_name="mouseExited") # that's because that would call credits._setText _NOW_ and we want to call # it later. credits.capture(lambda: TextSetter(u"CREDITS"), event_name="mouseEntered") credits.capture(lambda: credits._setText(u"Credits"), event_name="mouseExited") # import example modules from dynamic import DynamicExample from styling import StylingExample from sliders import SliderExample from colortester import ColorExample from poc_gui_animation import PocAnimations from stretching import StretchingExample # Our list of examples # We keep a dictionary of these and fill # the ListBox on the left with its names. self.examples = { 'Absolute Positioning': PyChanExample('gui/absolute.xml'), 'All Widgets': PyChanExample('gui/all_widgets.xml'), 'Basic Styling': StylingExample(), 'Dynamic Widgets': DynamicExample(), 'Sliders': SliderExample(), 'ScrollArea': PyChanExample('gui/scrollarea.xml'), 'Colortester': ColorExample(), 'GuiAnimations': PocAnimations(), 'Image Stretching': StretchingExample(), } self.demoList = self.gui.findChild(name='demoList') self.demoList.items = sorted(self.examples.keys()) # Finally show the main GUI self.gui.show() self.currentExample = None self.creditsWidget = None
def __init__(self, setting=None): super(PychanApplicationBase, self).__init__(setting) pychan.init(self.engine, debug = self._finalSetting['PychanDebug']) pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop)