def _check_expanded_pos(self): if self.node.classList.contains('expanded'): rect = self.node.getBoundingClientRect() if not (rect.top == self._rect_to_check.top and rect.left == self._rect_to_check.left): self._collapse() else: window.setTimeout(self._check_expanded_pos, 100)
def _check_expanded_pos(self): if self.node.classList.contains('expanded'): rect = self.node.getBoundingClientRect() if not (rect.top == self._rect_to_check.top and rect.left == self._rect_to_check.left): self._collapse() else: window.setTimeout(self._check_expanded_pos, 100)
def init(self, retico_widget): self.retico_widget = retico_widget with flx.PinboardLayout( style="height: 3000px; width: 3000px;") as self.mcontainer: self.canvas = flx.CanvasWidget( style="left: 0; top: 0; height:100%; width: 100%;") self.modules = [] self.init_moving() window.setTimeout(self.center_view, 10)
def center_view(self): rect = self.node.getBoundingClientRect() h = rect.height / 2 w = rect.width / 2 if h == 0 or w == 0: window.setTimeout(self.center_view, 10) return self.node.scrollTop = 1500 - h self.node.scrollLeft = 1500 - w
def set_position(self): rect = self.node.getBoundingClientRect() mpane = self.retico_widget.mpane.node self.set_p_left(rect.left + mpane.scrollLeft) self.set_p_top(rect.top + mpane.scrollTop) self.set_p_width(rect.width) self.set_p_height(rect.height) window.setTimeout(self.set_position, 100)
def _expand(self): # Expand self.node.classList.add('expanded') # Collapse when the node changes position (e.g. scroll or layout change) rect = self.node.getBoundingClientRect() self._rect_to_check = rect window.setTimeout(self._check_expanded_pos, 100) # Collapse when the mouse is used outside the combobox (or its children) self._addEventListener(window.document, 'mousedown', self._collapse_maybe, 1) # Return rect so subclasses can use it return rect
def _expand(self): # Expand self.node.classList.add('expanded') # Collapse when the node changes position (e.g. scroll or layout change) rect = self.node.getBoundingClientRect() self._rect_to_check = rect window.setTimeout(self._check_expanded_pos, 100) # Collapse when the mouse is used outside the combobox (or its children) self._addEventListener(window.document, 'mousedown', self._collapse_maybe, 1) # Return rect so subclasses can use it return rect
def __container_changed(self, *events): id = self.container self.outernode.classList.remove('flx-main-widget') if self.parent: return # Let session keep us up to date about size changes self._session.keep_checking_size_of(self, bool(id)) if id: if id == 'body': el = window.document.body self.outernode.classList.add('flx-main-widget') window.document.title = self.title or 'Flexx app' else: el = window.document.getElementById(id) if el is None: # Try again later window.setTimeout(self.__container_changed, 100) return el.appendChild(self.outernode)
def __container_changed(self, *events): id = self.container self.outernode.classList.remove('flx-main-widget') if self.parent: return # Let session keep us up to date about size changes # (or make it stop if we dont have a container anymore) self._session.keep_checking_size_of(self, bool(id)) if id: if id == 'body': el = window.document.body self.outernode.classList.add('flx-main-widget') window.document.title = self.title or 'Flexx app' else: el = window.document.getElementById(id) if el is None: # Try again later window.setTimeout(self.__container_changed, 100) return el.appendChild(self.outernode)
def update_periodically(self): if self.running: self.model.update_module_info() window.setTimeout(self.update_periodically, 1000) else: self.model.set_module_content()
def load_connections(self): window.setTimeout(self.model.load_connections, 10)