def onRemoteResponse(self, response, request_info): for name in response: item = TreeItem(name) item.addItem(PendingItem()) self.tree.addItem(item) self.status.setText('')
def onClick(self, sender): global sent,recv self.status.setText('Button pressed') if sender == self.buttonupdate: self.commobj = AMS_Comm() self.status.setText('Updating data: Press Display list button to refesh') if sender == self.button: if sent > recv: self.status.setText('Press button again: sent '+str(sent)+' recv '+str(recv)) if self.commobj.commname == 'No AMS publisher running': self.status.setText(self.commobj.commname) else: self.status.setText('Memories for AMS Comm: '+self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() for j in fields: field = memory.get_field_info(j) subtree.addItem(j+' = '+str(field[4])) self.tree.addItem(subtree) self.panel.add(self.tree)
def buildTree(self): """ Build the contents of our tree. Note that, for now, we highlight the demos which haven't been written yet. """ sections = {} # Maps section name to TreeItem object. for demo in self._demos: if demo['section'] not in sections: section = TreeItem('<b>' + demo['section'] + '</b>') DOM.setStyleAttribute(section.getElement(), "cursor", "pointer") DOM.setAttribute(section.itemTable, "cellPadding", "0") DOM.setAttribute(section.itemTable, "cellSpacing", "1") self._tree.addItem(section) sections[demo['section']] = section section = sections[demo['section']] if demo['doc'][:26] == "Documentation goes here...": item = TreeItem('<font style="color:#808080">' + demo['title'] + '</font>') else: item = TreeItem(demo['title']) DOM.setStyleAttribute(item.getElement(), "cursor", "pointer") DOM.setAttribute(item.itemTable, "cellPadding", "0") DOM.setAttribute(item.itemTable, "cellSpacing", "1") item.setUserObject(demo) section.addItem(item) # Open the branches of the tree. for section in sections.keys(): sections[section].setState(True, fireEvents=False)
def get_case_tree(self): tree = self.tree = Tree() case_item = TreeItem("Case_1") tree.addItem(case_item) buses = self.buses = TreeItem("Buses") case_item.addItem(buses) id = self.remote_case.buses("name", self) return tree
def onClick(self, sender): global statusbar, boxes statusbar.setText("Button pressed") pass if sender == self.buttonupdate: self.commobj = AMS.AMS_Comm() statusbar.setText("Updating data: Press Display list button to refesh") if sender == self.button: if AMS.sent > AMS.recv: statusbar.setText("Press button again: sent " + str(AMS.sent) + " recv " + str(AMS.recv)) if ( self.commobj.commname == "No AMS publisher running" or not self.commobj.commname or self.commobj.comm == -1 ): if self.tree: self.panel.remove(self.tree) else: statusbar.setText("Memories for AMS Comm: " + self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: if i == "Stack": continue subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() if not isinstance(fields, list): fields = [fields] block = false for j in fields: field = memory.get_field_info(j) if str(field[1]) == "AMS_READ": if j == "Publish Block": if field[4] == "true": block = true else: subtree.addItem(j + " = " + str(field[4])) else: if j == "Block" and not block: continue PN = HorizontalPanel() PN.add(Label(Text=j + " =")) tb = TextBox(Text=str(field[4])) boxes[tb] = [i, j, memory] tb.addChangeListener(self.textboxlistener) PN.add(tb) subtree.addItem(PN) self.tree.addItem(subtree) self.panel.add(self.tree)
def onModuleLoad(self): self.status = Label() self.button = Button( "Display list of all published memories and fields", self) self.buttonupdate = Button("Update data from AMS publisher", self) buttons = HorizontalPanel() buttons.add(self.button) buttons.add(self.buttonupdate) buttons.setSpacing(8) info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>""" self.panel = VerticalPanel() self.panel.add(HTML(info)) self.panel.add(buttons) self.panel.add(self.status) RootPanel().add(self.panel) self.commobj = AMS_Comm() self.tree = None if AMSJavascript.sent > AMSJavascript.recv: self.status.setText('Press button again: AMSJavascript.sent ' + str(AMSJavascript.sent) + ' AMSJavascript.recv ' + str(AMSJavascript.recv)) return if self.commobj.commname == 'No AMS publisher running': self.status.setText(self.commobj.commname) else: self.status.setText('Memories for AMS Comm: ' + str(AMSJavascript.sent) + str(AMSJavascript.recv) + self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() for j in fields: field = memory.get_field_info(j) subtree.addItem(j + ' = ' + str(field[4])) self.tree.addItem(subtree) self.panel.add(self.tree)
def onClick(self, sender): global statusbar, boxes statusbar.setText('Button pressed') pass if sender == self.buttonupdate: self.commobj = AMS.AMS_Comm() statusbar.setText( 'Updating data: Press Display list button to refesh') if sender == self.button: if AMS.sent > AMS.recv: statusbar.setText('Press button again: sent ' + str(AMS.sent) + ' recv ' + str(AMS.recv)) if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or self.commobj.comm == -1: if self.tree: self.panel.remove(self.tree) else: statusbar.setText('Memories for AMS Comm: ' + self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: if i == "Stack": continue subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() if not isinstance(fields, list): fields = [fields] block = false for j in fields: field = memory.get_field_info(j) if str(field[1]) == 'AMS_READ': if j == "Publish Block": if field[4] == "true": block = true else: subtree.addItem(j + ' = ' + str(field[4])) else: if j == "Block" and not block: continue PN = HorizontalPanel() PN.add(Label(Text=j + ' =')) tb = TextBox(Text=str(field[4])) boxes[tb] = [i, j, memory] tb.addChangeListener(self.textboxlistener) PN.add(tb) subtree.addItem(PN) self.tree.addItem(subtree) self.panel.add(self.tree)
def onModuleLoad(self): self.status=Label() self.button = Button("Display list of all published memories and fields", self) self.buttonupdate = Button("Update data from AMS publisher", self) buttons = HorizontalPanel() buttons.add(self.button) buttons.add(self.buttonupdate) buttons.setSpacing(8) info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>""" self.panel = VerticalPanel() self.panel.add(HTML(info)) self.panel.add(buttons) self.panel.add(self.status) RootPanel().add(self.panel) self.commobj = AMS_Comm() self.tree = None if AMSJavascript.sent > AMSJavascript.recv: self.status.setText('Press button again: AMSJavascript.sent '+str(AMSJavascript.sent)+' AMSJavascript.recv '+str(AMSJavascript.recv)) return if self.commobj.commname == 'No AMS publisher running': self.status.setText(self.commobj.commname) else: self.status.setText('Memories for AMS Comm: '+str(AMSJavascript.sent)+str(AMSJavascript.recv)+self.commobj.commname) result = self.commobj.get_memory_list() if self.tree: self.panel.remove(self.tree) self.tree = Tree() for i in result: subtree = TreeItem(i) memory = self.commobj.memory_attach(i) fields = memory.get_field_list() for j in fields: field = memory.get_field_info(j) subtree.addItem(j+' = '+str(field[4])) self.tree.addItem(subtree) self.panel.add(self.tree)