def onLoad(self): self.tabs = TabPanel(FlowTabBar()) self.tabs.getTabBar().addStyleName('shortcuts') self.tabs.getDeckPanel().addStyleName('blockDrawer') #------------------------------------------------------------------------------------------ self.input = CategoriesHardware.Input() self.tabs.add(self.input, CategoriesHardware.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesHardware.Output() self.tabs.add(self.output, CategoriesHardware.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 600) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px')
def onModuleLoad(self): self.tabs = TabPanel() tab_overview = TabContainer() self.tabs.add(tab_overview, 'Overview') self.tab_events = TabRaphaelContainer() self.tab_events.set_headline('Events Example') self.tab_events.set_raphael(events.Events(width=600, height=300)) self.tab_events.set_status('Execute events on Raphael Elemnts') self.tabs.add(self.tab_events, 'Events') self.tab_graffle = TabRaphaelContainer() self.tab_graffle.set_headline( 'This is a simple example of the Raphael Graffle') self.tab_graffle.set_raphael(graffle.Graffle(width=600, height=300)) self.tabs.add(self.tab_graffle, 'Graffle') self.tab_spinner = TabRaphaelContainer() self.tab_spinner.set_headline('This Raphael Spinner Example') self.tab_spinner.set_raphael(spinner.Spinner(width=600, height=300)) self.tabs.add(self.tab_spinner, 'Spinner') self.tabs.selectTab(0) self.tabs.setWidth("100%") self.tabs.setHeight("100%") RootPanel().add(self.tabs)
def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.addTabListener(self) self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662 (disabled)") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs)
def __init__(self, tabBar=None, *kwargs): TabPanel.__init__(self, tabBar, *kwargs) self.parent_buoy = None self.tabs = [{'hovertype' : ListBox(), 'name' : 'Cost'}, {'hovertype' : ListBox(), 'name' : 'Speed'}] self.cost = self.tabs[0]['hovertype'] items = ['cheap','next to cheap','average','above average','expensive','if you have to ask'] self.cost.setVisibleItemCount(len(items)) for item in items: self.cost.addItem(item) self.cost.addChangeListener(self) self.speed = self.tabs[1]['hovertype'] items = ['very slow','slow','average','above average','fast','quick','hyper','turbo','lightening','light'] self.speed.setVisibleItemCount(len(items)) for item in items: self.speed.addItem(item) self.speed.addChangeListener(self) for tab in self.tabs: h = HorizontalPanel() h.add(tab['hovertype']) self.add(h, tab['name'])
def panel ( ui ): """ Creates a panel-based user interface for a specified UI object. """ # Bind the context values to the 'info' object: ui.info.bind_context() # Get the content that will be displayed in the user interface: content = ui._groups nr_groups = len(content) if nr_groups == 0: panel = None if nr_groups == 1: panel = _GroupPanel(content[0], ui).control elif nr_groups > 1: panel = TabPanel() _fill_panel(panel, content, ui) panel.ui = ui # If the UI is scrollable then wrap the panel in a scroll area. if ui.scrollable and panel is not None: sp = ScrollPanel() sp.add(panel) panel = sp return panel
def add(self, tab, text, closable=False): t = text if closable: t += " <a href\=""about:black\" onClick=\"document.modules.main.main.tps.get(%d).removeByKey(%d); return false;\">[x]</a>"%(self.id,self.key) TabPanel.add(self, tab, t, closable) tab.key = self.key self.k2w[self.key]=tab self.key+=1
def __init__(self): global tps global tpid tps[tpid] = self self.id = tpid tpid += 1 self.k2w = {} self.key=0 TabPanel.__init__(self)
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName']=self.DEFAULT_STYLENAME if kwargs.has_key('TabBar'): tabbar = kwargs.pop('TabBar') else: tabbar = DecoratedTabBar() TabPanel.__init__(self, tabbar, **kwargs) self.getTabBar().setStyleName(DecoratedTabBar.STYLENAME_DEFAULT)
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName'] = self.DEFAULT_STYLENAME if kwargs.has_key('TabBar'): tabbar = kwargs.pop('TabBar') else: tabbar = DecoratedTabBar() TabPanel.__init__(self, tabbar, **kwargs) self.getTabBar().setStyleName(DecoratedTabBar.STYLENAME_DEFAULT)
def __init__(self): SimplePanel.__init__(self) tabs = TabPanel(Width="100%", Height="250px") tabs.add(HTML("The quick brown fox jumps over the lazy dog."), "Tab 1") tabs.add(HTML("The early bird catches the worm."), "Tab 2") tabs.add(HTML("The smart money is on the black horse."), "Tab 3") tabs.selectTab(0) self.add(tabs)
def __init__(self, tabBar=None, **kwargs): TabPanel.__init__(self, tabBar, **kwargs) self.buoy = None # 3 tabs but only Hovercraft() has complexity self.tabs = [{'tab' : Hovercraft(), 'name' : 'Hovercraft'}, {'tab' : Ships(), 'name' : 'Ship'}, {'tab' : Surfboard(), 'name' : 'Surfboard'}] for tab in self.tabs: self.add(tab['tab'], tab['name'])
def __init__(self): self.remote_case = CaseService() self.base_panel = VerticalPanel() self.tab_panel = TabPanel() self.base_panel.add(self.tab_panel) self.tab_panel.add(self.get_case_panel(), "Case") self.tab_panel.add(self.get_buses_panel(), "Buses") self.tab_panel.selectTab(0) self.status = Label() self.base_panel.add(self.status) RootPanel().add(self.base_panel)
def __init__(self): TabPanel.__init__(self, StyleName='tab-panel', Width='100%') loginPanel = login.LoginPanel() topPanel = toppanel.TopPanel(loginPanel) self.simple = simple.Simple(topPanel) self.intermediate = intermediate.Intermediate(topPanel) self.advanced = advanced.Advanced(topPanel) self.about = about.About(topPanel) self.add(self.simple, 'Simple') self.add(self.intermediate, 'Intermediate') self.add(self.advanced, 'Advanced') self.add(self.about, 'About') self.add(HTML(' '), None) self.add(HTML(' '), loginPanel)
def onModuleLoad(self): self.tabs = TabPanel() tab_overview=TabContainer() self.tabs.add(tab_overview, 'Overview') self.tab_events=TabRaphaelContainer() self.tab_events.set_headline('Events Example') self.tab_events.set_raphael(events.Events(width=600,height=300)) self.tab_events.set_status('Execute events on Raphael Elemnts') self.tabs.add(self.tab_events, 'Events') self.tab_graffle=TabRaphaelContainer() self.tab_graffle.set_headline('This is a simple example of the Raphael Graffle') self.tab_graffle.set_raphael(graffle.Graffle(width=600,height=300)) self.tabs.add(self.tab_graffle, 'Graffle') self.tab_spinner=TabRaphaelContainer() self.tab_spinner.set_headline('This Raphael Spinner Example') self.tab_spinner.set_raphael(spinner.Spinner(width=600,height=300)) self.tabs.add(self.tab_spinner, 'Spinner') self.tabs.selectTab(0) self.tabs.setWidth("100%") self.tabs.setHeight("100%") RootPanel().add(self.tabs)
def onLoad(self): self.tabs = TabPanel(FlowTabBar()) # self.tabs.getTabBar().addStyleName('shortcuts') === gwt-TabBar # self.tabs.getDeckPanel().addStyleName('blockDrawer') === gwt-TabPanelBottom{ #------------------------------------------------------------------------------------------ self.control = CategoriesBlock.Control() self.tabs.add(self.control, CategoriesBlock.TabTitle(_('Control'), 'control_btn')) #------------------------------------------------------------------------------------------ self.operators = CategoriesBlock.Operators() self.tabs.add( self.operators, CategoriesBlock.TabTitle(_('Operators'), 'operators_btn')) #------------------------------------------------------------------------------------------ self.input = CategoriesBlock.Input() self.tabs.add(self.input, CategoriesBlock.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesBlock.Output() self.tabs.add(self.output, CategoriesBlock.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.utilities = CategoriesBlock.Setup() self.tabs.add(self.utilities, CategoriesBlock.TabTitle(_('Utilities'), 'config_btn')) #------------------------------------------------------------------------------------------ self.variables = CategoriesBlock.Variables() self.tabs.add( self.variables, CategoriesBlock.TabTitle(_('Variables'), 'variables_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 510) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px')
def __init__(self): """ Constructs a new OpenPowerSystem instance. """ self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.base_panel = HorizontalPanel() self.tab_panel = TabPanel() self.tab_panel.add(self.get_upload_panel(), "Upload") # self.tab_panel.add(self.get_home_panel(), "OpenPowerSystem") # self.tab_panel.add(self.get_map_panel(), "Map") # self.tab_panel.add(self.get_edit_panel(), "Edit") self.tab_panel.selectTab(0) self.base_panel.add(self.tab_panel) RootPanel().add(self.base_panel)
def onTabSelected(self, sender, tabIndex): page_name = self.tabs[tabIndex]['name'] buoy = self.parent_buoy.new(page_name, {page_name: None}) if tabIndex == 0: buoy.navigate() self.tabs[tabIndex]['tab'].set(buoy) else: buoy.end() return TabPanel.onTabSelected(self, sender, tabIndex)
def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs)
def onTabSelected(self, sender, tabIndex): page_name = self.tabs[tabIndex]['name'] self.buoy = self.parent_buoy.new(page_name, {'hovertype' : self.tabs[tabIndex]['name']}) params = self.buoy.navigate() if 'hovertype' in params: if params['hovertype'] == 'Cost': self.set_cost(self.buoy) elif params['hovertype'] == 'Speed': self.set_speed(self.buoy) else: self.set_cost(self.buoy) return TabPanel.onTabSelected(self, sender, tabIndex)
def onTabSelected(self, sender, tabIndex): page_name = self.tabs[tabIndex]['name'] buoy = self.parent_buoy.new(page_name, {page_name : None}) if tabIndex == 0: buoy.navigate() self.tabs[tabIndex]['tab'].set(buoy) else: buoy.end() return TabPanel.onTabSelected(self, sender, tabIndex)
def __init__ (self, **kwargs): ZillaWindow.__init__(self, kwargs) FocusPanel.__init__(self, kwargs) area1 = TextArea() area1.setText("Zakładka 1") area2 = TextArea() area2.setText("Zakładka 2") area3 = TextArea() area3.setText("Zakładka 2") tabs = TabPanel() tabs.add(area2, tabText="Gra nr 1") tabs.add(area1, tabText="Pokój gier") tabs.add(area3, tabText="Pokój gier") self.add (tabs) lwindow = LoginWindow(centered=True) lwindow.setPopupPosition (100, 100) lwindow.show()
def __init__(self, **kwargs): ZillaWindow.__init__(self, kwargs) FocusPanel.__init__(self, kwargs) area1 = TextArea() area1.setText("Zakładka 1") area2 = TextArea() area2.setText("Zakładka 2") area3 = TextArea() area3.setText("Zakładka 2") tabs = TabPanel() tabs.add(area2, tabText="Gra nr 1") tabs.add(area1, tabText="Pokój gier") tabs.add(area3, tabText="Pokój gier") self.add(tabs) lwindow = LoginWindow(centered=True) lwindow.setPopupPosition(100, 100) lwindow.show()
class Tabs(Sink): def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs) def onShow(self): pass def createImage(self, imageUrl): image = Image(imageUrl) image.setStyleName("ks-images-Image") p = VerticalPanel() p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) p.add(image) return p
def onModuleLoad(self): self.popupsubtraca = PopupSub(id="sub",datasrc="fsubtracao.pjs") self.popupsoma = PopupSoma(id="soma",datasrc="fsoma.pjs") self.popupmultescalar = PopupEscalar(id="escalar",datasrc="fmultescalar.pjs") self.popupmult = PopupProduto(id="mult",datasrc="fmult.pjs") self.popupsoma.iniciado = False; tabpanel = TabPanel() grid = Grid(4,2) imgbtnSoma = Image("images/Soma_Matriz_sum_matrix.png",StyleName="gwt-ImageButton") imgbtnSubtracao = Image("images/subtracao_Matriz_subtract_matrix.png",StyleName="gwt-ImageButton") imgbtnMultiplicacao = Image("images/multiplicacao_Matriz_product_matrix.png",StyleName="gwt-ImageButton") imgbtnMultiplicacaoPorEscalar = Image("images/multiplicacao_por_escalar.png",StyleName="gwt-ImageButton") #eventos imgbtnSoma.addClickListener(self.onSomaButtonClick) imgbtnSubtracao.addClickListener(self.onSubtracaoButtonClick) imgbtnMultiplicacao.addClickListener(self.onMultiplicacaoButtonClick) imgbtnMultiplicacaoPorEscalar.addClickListener(self.onMulPorEscalarButtonClick) contents = VerticalPanel() contents.setSpacing(4) contents.add(HTML('You can place any contents you like in a dialog box.')) grid.setWidget(0,0,imgbtnSoma) grid.setWidget(0,1,imgbtnSubtracao) grid.setWidget(2,0,imgbtnMultiplicacao) grid.setWidget(2,1,imgbtnMultiplicacaoPorEscalar) grid.setStyleName(element) tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Modulo de introducao a Matrizes</h2>", True) tabpanel.add(grid,"<h2> Matrizes </h2>", True) tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Ajuda para usar a ferramenta</h2>", True) tabpanel.setSize("90%"," 70%") tabpanel.selectTab(1) #self.popupsoma.show() RootPanel("conteudo").add(tabpanel)
class Tabs(Sink): def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.addTabListener(self) self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662 (disabled)") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs) def onShow(self): pass def createImage(self, imageUrl): image = Image(imageUrl) image.setStyleName("ks-images-Image") p = VerticalPanel() p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) p.add(image) return p def onBeforeTabSelected(self, sender, tabIndex): # Returning False disables the tab. if tabIndex == 4: return False return True def onTabSelected(self, sender, tabIndex): bar = self.fTabs.getTabBar() if tabIndex == 0: bar.getTabWidget(0).setText('1634 (selected)') else: bar.getTabWidget(0).setText('1634 (not selected)')
class Pylon: def __init__(self): self.remote_case = CaseService() self.base_panel = VerticalPanel() self.tab_panel = TabPanel() self.base_panel.add(self.tab_panel) self.tab_panel.add(self.get_case_panel(), "Case") self.tab_panel.add(self.get_buses_panel(), "Buses") self.tab_panel.selectTab(0) self.status = Label() self.base_panel.add(self.status) RootPanel().add(self.base_panel) def get_case_panel(self): panel = VerticalPanel() title = HTML("""Case""") panel.add(title) tree = self.get_case_tree() panel.add(tree) return panel 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 create_item(self, proto): proto.item = TreeItem(proto.text) proto.item.setUserObject(proto) if len(proto.children) > 0: proto.item.addItem(PendingItem()) def get_buses_panel(self): panel = VerticalPanel() title = HTML("""Buses""") panel.add(title) return panel # JSON handler interface -------------------------------------------------- # The handler object should implement # onRemoteResponse(value, requestInfo) # to accept the return value of the remote method, and # onRemoteError(code, error_dict, requestInfo) # code = http-code or 0 # error_dict is an jsonrpc 2.0 error dict: # { # 'code': jsonrpc-error-code (integer) , # 'message': jsonrpc-error-message (string) , # 'data' : extra-error-data # } # to handle errors. def onRemoteResponse(self, response, request_info): print "RESPONSE:", response # self.tree.clear() self.buses.removeItems() for bus_name in response: proto = Proto(str(bus_name)) self.create_item(proto) self.buses.addItem(proto.item) def onRemoteError(self, code, errobj, request_info): print "ERROR:", errobj['message'] message = errobj['message'] if code != 0: self.status.setText("HTTP error %d: %s" % (code, message)) else: code = errobj['code'] self.status.setText("JSONRPC Error %s: %s" % (code, message))
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName']=self.DEFAULT_STYLENAME TabPanel.__init__(self, DecoratedTabBar(), **kwargs) self.getTabBar().setStyleName(DecoratedTabBar.STYLENAME_DEFAULT)
class Tabs(Sink): def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs) def onShow(self): pass def createImage(self, imageUrl): image = Image(imageUrl) image.setStyleName("ks-images-Image") p = VerticalPanel() p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) p.add(image) return p
class BlockList(DropWidget, DragContainer, VerticalPanel): _blockDragListeners = [] def __init__(self): VerticalPanel.__init__(self, StyleName='drophere') DropWidget.__init__(self) DragContainer.__init__(self) def changeTexts(self): for category in self.tabs.getChildren(): category.changeTexts() for i in range(1, self.tabs.getTabBar().panel.getWidgetCount() - 1): self.tabs.getTabBar().panel.getWidget( i).getFocusablePanel().getWidget().changeTexts() def onLoad(self): self.tabs = TabPanel(FlowTabBar()) # self.tabs.getTabBar().addStyleName('shortcuts') === gwt-TabBar # self.tabs.getDeckPanel().addStyleName('blockDrawer') === gwt-TabPanelBottom{ #------------------------------------------------------------------------------------------ self.control = CategoriesBlock.Control() self.tabs.add(self.control, CategoriesBlock.TabTitle(_('Control'), 'control_btn')) #------------------------------------------------------------------------------------------ self.operators = CategoriesBlock.Operators() self.tabs.add( self.operators, CategoriesBlock.TabTitle(_('Operators'), 'operators_btn')) #------------------------------------------------------------------------------------------ self.input = CategoriesBlock.Input() self.tabs.add(self.input, CategoriesBlock.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesBlock.Output() self.tabs.add(self.output, CategoriesBlock.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.utilities = CategoriesBlock.Setup() self.tabs.add(self.utilities, CategoriesBlock.TabTitle(_('Utilities'), 'config_btn')) #------------------------------------------------------------------------------------------ self.variables = CategoriesBlock.Variables() self.tabs.add( self.variables, CategoriesBlock.TabTitle(_('Variables'), 'variables_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 510) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px') def refreshComponentBlocks(self, components): self.input.removeAllSubComp() self.output.removeAllSubComp() listName = set([]) for comp in components: if hasattr(comp, 'listBlockName'): for name in comp.listBlockName: if not listName.__contains__(name): listName.add(name) block = getattr(ArduinoBlocks, name)() block.changeTexts() if comp.mode == INPUT: self.input.getSubComp(comp.text).addBlock(block) elif comp.mode == OUTPUT: self.output.getSubComp(comp.text).addBlock(block) self.input.changeTexts() self.output.changeTexts() def reload(self): self.showMainBlock() for cat in self.tabs.children: cat.reload() def onDragStart(self, event): #print "Left: onDragStart" setDragStartPosition( event ) #verificar se realmente � necess�rio REMOVI (talvez tenha que colocar para undo) for listener in self._blockDragListeners: listener.onBlockDragStart(event, getWorkspace().getMovingBlock()) def onDragEnd(self, event): for listener in self._blockDragListeners: listener.onBlockDragEnd(event, getWorkspace().getMovingBlock()) getWorkspace().setMovingBlock(None) def onDragEnter(self, event): DOM.eventPreventDefault(event) def onDragOver(self, event): if getWorkspace().getMovingBlock() is None: return dt = event.dataTransfer dt.dropEffect = 'copy' if not getWorkspace().getMovingBlock().original: self.addStyleName('dragover') self.trashCan.setStyleName('trashCanOpen') DOM.eventPreventDefault(event) def onDragLeave(self, event): #print "Left: onDragLeave" if getWorkspace().getMovingBlock() is None: return dt = event.dataTransfer dt.dropEffect = 'none' if not getWorkspace().getMovingBlock().original: self.removeStyleName('dragover') self.trashCan.setStyleName('trashCanClose trashCanCloseFadeIn') def onDrop(self, event): #print "Left: onDrop" if getWorkspace().getMovingBlock() is None: return self.removeStyleName('dragover') if not getWorkspace().getMovingBlock().original: #do = (self.removeBlocks, [getWorkspace().getMovingBlock()]) self.removeBlocks(getWorkspace().getMovingBlock()) # #history.add(do, getWorkspace().getUndo()) # � preciso saber de onde vem for listener in self._blockDragListeners: listener.onBlockDragEnd(event, getWorkspace().getMovingBlock()) getWorkspace().getMovingBlock().onDragEnd() #finaliza - para undo getWorkspace().setMovingBlock(None) from edu.uca.util.Serializable import stateChange stateChange() self.trashCan.setStyleName("trashCanClose") def removeBlocks( self, root): # remove o bloco e seus subblocos da lista de blocos if root is None: return getWorkspace().removeBlock(root) # Tentando remover um bloco original for holder in root.holderArguments: self.removeBlocks(holder.subBlock) for holder in root.holderChildren: self.removeBlocks(holder.subBlock) if root.holderSiblingDown is not None: self.removeBlocks(root.holderSiblingDown.subBlock) if isinstance(root, MainBlock): self.showMainBlock() getWorkspace().setMainBlock(None) root.removeFromParent() #-------------------------------------------------------------------------------------------------------------- def hideMainBlock(self): self.control.hideMainBlock() def showMainBlock(self): self.control.showMainBlock() #-------------------------------------------------------------------------------------------------------------- def addBlockDragListener(self, listener): self._blockDragListeners.append(listener) def removeBlockDragListener(self, listener): self._blockDragListeners.remove(listener)
class OpenPowerSystem: """ Defines the main panel for OpenPowerSystem. """ def __init__(self): """ Constructs a new OpenPowerSystem instance. """ self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.base_panel = HorizontalPanel() self.tab_panel = TabPanel() self.tab_panel.add(self.get_upload_panel(), "Upload") # self.tab_panel.add(self.get_home_panel(), "OpenPowerSystem") # self.tab_panel.add(self.get_map_panel(), "Map") # self.tab_panel.add(self.get_edit_panel(), "Edit") self.tab_panel.selectTab(0) self.base_panel.add(self.tab_panel) RootPanel().add(self.base_panel) def get_home_panel(self): panel = VerticalPanel() title = HTML("""OpenPowerSystem""") panel.add(title) subtitle = HTML("""The Open Power System data repository.""") panel.add(subtitle) return panel # def get_map_panel(self): # panel = VerticalPanel() # # self.map = OpenMap(Width="900px", Height="900px") # panel.add(self.map) # # self.wms = OpenWMSLayer("OpenLayers WMS", # "http://labs.metacarta.com/wms/vmap0", layers="basic") # self.map.addLayer(self.wms) # # return panel # def get_edit_panel(self): # edit_page = edit_panel.EditPanel() # return edit_page.panel def get_upload_panel(self): # Create a FormPanel and point it at a service. self.form = FormPanel() self.form.setAction("/upload") # Add an event handler to the form. handler = UploadFormHandler() handler.form = self.form self.form.addFormHandler(handler) # Because we're going to add a FileUpload widget, we'll need to set the # form to use the POST method, and multipart MIME encoding. self.form.setEncoding(FormPanel.ENCODING_MULTIPART) self.form.setMethod(FormPanel.METHOD_POST) panel = VerticalPanel() panel.setSpacing(8) panel.setStyleName("panel") # same name as in OpenPowerSystem.css. self.form.setWidget(panel) info = HTML(r'Upload CIM RDF/XML instance file.') panel.add(info) # Create a list box for choice of profile. self.profiles = [("UCTE (CIM 14)", "ucte"), ("CPSM (CIM13)", "cpsm"), ("CDPSM (CIM 14)", "cdpsm"), ("Dynamics (CIM 14)", "dynamics")] self.profile = ListBox(VisibleItemCount=1) self.profile.setName("profileType") for n, v in self.profiles: self.profile.addItem(n, v) panel.add(self.profile) # Create a FileUpload widget. rdfxml_file = FileUpload() rdfxml_file.setName("uploadFormElement") panel.add(rdfxml_file) # Add a 'submit' button. upload = Button("Upload", handler) panel.add(upload) return self.form
def make_tabs(self): tabs = TabPanel() tabs.add(self.make_alarm_widget(), 'alarms') tabs.add(self.make_test_widget(), 'test') tabs.selectTab(0) return tabs
class HardwareList(DropWidget, DragContainer, VerticalPanel): def __init__(self): VerticalPanel.__init__(self, StyleName='drophere') DropWidget.__init__(self) DragContainer.__init__(self) def changeTexts(self): for category in self.tabs.getChildren(): category.changeTexts() for i in range(1, self.tabs.getTabBar().panel.getWidgetCount() - 1): self.tabs.getTabBar().panel.getWidget( i).getFocusablePanel().getWidget().changeTexts() def onLoad(self): self.tabs = TabPanel(FlowTabBar()) self.tabs.getTabBar().addStyleName('shortcuts') self.tabs.getDeckPanel().addStyleName('blockDrawer') #------------------------------------------------------------------------------------------ self.input = CategoriesHardware.Input() self.tabs.add(self.input, CategoriesHardware.TabTitle(_('Input'), 'input_btn')) #------------------------------------------------------------------------------------------ self.output = CategoriesHardware.Output() self.tabs.add(self.output, CategoriesHardware.TabTitle(_('Output'), 'output_btn')) #------------------------------------------------------------------------------------------ self.tabs.selectTab(0) panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%') panel.append(self.tabs) #------------------------------------------------------------------------------------------ self.trashCan = Widget(Element=DOM.createDiv(), StyleName='trashCanClose') panel.append(self.trashCan) self.add(panel) #------------------------------------------------------------------------------------------ bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom') resize = ResizeWidget(self.parent, 200, 600) resize.addStyleName('float_right') bottom.append(resize) self.add(bottom) self.setCellHeight(bottom, '20px') def reload(self): pass def onDragStart(self, event): setDragStartPosition(event) def onDragEnd(self, event): getWorkspace().setMovingBlock(None) def onDragOver(self, event): if getWorkspace().getMovingBlock() is None: return dt = event.dataTransfer dt.dropEffect = 'copy' if hasattr(getWorkspace().getMovingBlock(), 'original'): if not getWorkspace().getMovingBlock().original: self.addStyleName('dragover') self.trashCan.setStyleName('trashCanOpen') DOM.eventPreventDefault(event) def onDragLeave(self, event): dt = event.dataTransfer dt.dropEffect = 'none' if hasattr(getWorkspace().getMovingBlock(), 'original'): if not getWorkspace().getMovingBlock().original: self.removeStyleName('dragover') self.trashCan.setStyleName('trashCanClose trashCanCloseFadeIn') def onDrop(self, event): if getWorkspace().getMovingBlock() is None: return self.removeStyleName('dragover') if hasattr(getWorkspace().getMovingBlock(), 'original'): if not getWorkspace().getMovingBlock().original: getWorkspace().getMovingBlock().removeFromParent() del hardwares[getWorkspace().getMovingBlock().getCompleteText( )] # remove da lista de componentes getWorkspace().setMovingBlock(None) from edu.uca.util.Serializable import stateChange stateChange() self.trashCan.setStyleName("trashCanClose") DOM.eventPreventDefault(event)
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName'] = self.DEFAULT_STYLENAME TabPanel.__init__(self, DecoratedTabBar(), **kwargs) self.getTabBar().setStyleName(DecoratedTabBar.STYLENAME_DEFAULT)
class Tabs(Sink): def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.addTabListener(self) self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662 (disabled)") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs) def onShow(self): pass def createImage(self, imageUrl): image = Image(imageUrl) image.setStyleName("ks-images-Image") p = VerticalPanel() p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) p.add(image) return p def onBeforeTabSelected(self, sender, tabIndex): # Returning False disables the tab. if tabIndex == 4: return False return True def onTabSelected(self, sender, tabIndex): bar = self.fTabs.getTabBar() if tabIndex == 0: bar.getTabWidget(0).setText('1634 (selected)') else: bar.getTabWidget(0).setText('1634 (not selected)')