def manageRootPanel(panel, id=None): if len(rootPanels) < 1: panelManager = RootPanelManager() Window.addWindowCloseListener(panelManager) rootPanels[id] = panel return panel
def __init_UI(self): ## Two-phase to mimic flex_ui class Window.addWindowCloseListener(self) self.ws_dh = WSdataHandler(self, self.callback) location = Window.getLocation() search = location.getSearch()[1:] params = '/'.join(search.split('&')) full_resource = self.resource + '/' + params self.ws = websocketclient.WebSocketClient(full_resource, self.ws_dh, fallback=bool(self.fallback)) self.ws.connect(self.server) self.php_dh = PHPdataHandler(self, self.callback) self.php_script = self.resource + '.php' if not isinstance(self.fallback, bool): self.php_script = self.fallback
def hookWindowClosing(cls): Window.addWindowCloseListener(cls)
def __init__(self, delayMillis=0, notify=None): '''Called with no arguments, create a timer that will call its run() method when it is scheduled and fired. This usage requires subclassing to implement the run() method. This is GWT's interface and behaviour. There are two enhancements to pyjamas' implementation when specified with special keyword arguments, one of which obviates the need for subclassing:: timer = Timer(delayMillis=ms) is identical to:: timer = Timer() timer.schedule(ms) and:: timer = Timer(notify=object_or_func) is the same as:: timer = Timer() run = getattr(object_or_func, 'onTimer', object_or_func) if not callable(run): raise ValueError, msg i.e., the value passed to notify is checked to see if it has an onTimer attribute; if so, it is used as the callable, if not, the object itself is used as the callable. NOTE: when notify is specified, the function or method will be called with one argument: the instance of the timer. So, this would be proper usage:: def timer_cb(timer): ... timer = Timer(notify=timer_cb) or:: class myclass: def __init__(self): ... self.timer = Timer(notify=self) def onTimer(self, timer): ... ''' # initialize a few house keeping vars self.__tid = None self.__onTimer = lambda: self.run() Window.addWindowCloseListener(Timer.__WindowCloseListener()) # check notify if notify is not None: run = getattr(notify, 'onTimer', notify) if not callable(run): raise ValueError, 'Programming error: notify must be callable' self.__onTimer = lambda: run(self) # ugly, ugly, ugly, but there's no other way to get # implementation-specific initialization (without subclassing, # which the override system doesn't do). The default is a # no-op. We do it here, so the instance can be init'd before # the possible scheduling of the timer. self.__impl_init_hook() # schedule? if delayMillis != 0: self.schedule(delayMillis)