def draw(self): Popup.draw(self) namePanel = HorizontalPanel() namePanel.add(Label(_('Name') + ':')) self.textBox = TextBox() self.textBox.setMaxLength(15) self.textBox.setStyleAttribute('marginLeft', 10) namePanel.add(self.textBox) self.center.add(namePanel) self.choose = ChooseTypeVarPanel() self.center.add(self.choose) self.textBox.addInputListener(self) self.message = Element(Element=DOM.createDiv()) self.message.add(Widget(Element=DOM.createDiv(), StyleName='not_image')) self.message.add( Label(text=_('Name already used'), wordWrap=False, StyleName='not_message')) self.onInput()
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 itemClick(self, value): if self.block.original: return oldValue = self.block.name if self.groupLabel is None: DOM.setInnerHTML(self.title.getElement(), _(value)) self.block.name = self.group[value] else: DOM.setInnerHTML(self.title.getElement(), _(self.groupLabel[value])) self.block.name = self.group[self.groupLabel[value]] if oldValue != value: from edu.uca.util.Serializable import stateChange stateChange()
def __init__(self): CategoryPanel.__init__(self) self.label = 'control_lbl' self.subLoop = SubCategoryPanel(_('Loops'), self.label) self.mainBlock = forever() self.subLoop.addBlock(self.mainBlock, 'help_forever') self.subLoop.addBlock(repeat_()) self.subLoop.addBlock(while_()) #self.subLoop.addBlock(doWhile()) todo: resize self.add(self.subLoop) self.sub = SubCategoryPanel(_('Flow Controls'), self.label) self.sub.addBlock(if_(), 'help_if') self.sub.addBlock(if_else_()) self.sub.addBlock(delay_()) self.sub.addBlock(delayUntil()) self.add(self.sub)
def __init__(self, feedBack, value, **kw): Element.__init__(self, Element=DOM.createElement('li'), **kw) ClickHandler.__init__(self) self.value = value DOM.setInnerHTML(self.getElement(), _(value).replace(' ', ' ')) self.addClickListener(self) self.feedBack = feedBack
def changeTexts(self): #self.buttonReload.setText(_('Reload')) self.buttonMakeBlock.setText(_('Building Block')) self.buttonTranslate.setText(_('Translate')) self.dropdownTranslate.changeTexts() self.buttonHarwares.setText(_('Components')) self.buttonBlocks.setText(_('Blocks')) self.buttonSave.setText(_('Save')) self.buttonOpen.setText(_('Open')) self.buttonUndo.setText(_('Undo')) self.buttonRedo.setText(_('Redo'))
def __init__(self): CategoryPanel.__init__(self) self.label = 'config_lbl' sub = SubCategoryPanel(_('Alphanumeris Commands'), self.label) sub.addBlock(glue()) sub.addBlock(intToStr()) sub.addBlock(boolToStr()) sub.addBlock(StrToInt()) sub.addBlock(str_equals()) self.add(sub) sub = SubCategoryPanel('Comunicação Serial', self.label, openList=False) sub.addBlock(println()) sub.addBlock(available()) sub.addBlock(getMsg()) sub.addBlock(waitForAnyMsg()) sub.addBlock(waitForTheMsg()) self.add(sub) sub = SubCategoryPanel(_('Math Functions'), self.label, openList=False) sub.addBlock(min_()) sub.addBlock(max_()) sub.addBlock(sqrt_()) sub.addBlock(abs_()) sub.addBlock(round_()) #sub.addBlock(modulo_()) Operador #sub.addBlock(constrains_()) #sub.addBlock(map_()) #sub.addBlock(map2_()) self.add(sub) sub = SubCategoryPanel(_('Trigonometrics Functions'), self.label, openList=False) sub.addBlock(sin_()) sub.addBlock(cos_()) sub.addBlock(tan_()) self.add(sub) sub = SubCategoryPanel(_('Others'), self.label, openList=False) sub.addBlock(millis()) sub.addBlock(random()) sub.addBlock(random_min_max()) #sub.addBlock(map_()) self.add(sub)
def showInfo(self, sender): if sender.block.name in [ 'commandType', 'numericType', 'logicType', 'alphaNumericType' ]: createdBlocks[sender.block.varName].show() else: popup = Popup('<b>' + _('Help') + '</b>', None, None) popup.center.append( Widget(Element=DOM.createDiv(), StyleName=sender.classHelp)) popup.caption.setStyleAttribute('text-align', 'center') popup.show()
def draw(self): self.setHTML(self.title) panelSouth = VerticalPanel(StyleName='dialog_south') self.south = Element(Element=DOM.createDiv(), Width='100%') if (self.options == CONFIRM_CANCEL): cancel = Button(_('Cancel'), self.myCancelClick, classIcon="icon-cancel") cancel.addStyleName('float_right') self.south.add(cancel) self.okButton = Button(_('Confirm'), self.myOkClick, classIcon="icon-ok") self.okButton.addStyleName('float_right') self.south.add(self.okButton) panelSouth.add(self.south) panelSouth.setCellHorizontalAlignment(self.south, HasHorizontalAlignment.ALIGN_RIGHT) widget = VerticalPanel(Width='100%') widget.add(self.center) widget.add(panelSouth) self.setWidget(widget)
def __init__(self): CategoryPanel.__init__(self) self.label = 'operators_lbl' sub = SubCategoryPanel(_('Arithmetic'), self.label) sub.addBlock(plus()) sub.addBlock(minus()) sub.addBlock(multiply()) sub.addBlock(divide()) self.add(sub) sub = SubCategoryPanel(_('Relational'), self.label) sub.addBlock(equals()) sub.addBlock(lesser()) sub.addBlock(greater()) self.add(sub) sub = SubCategoryPanel(_('Logic'), self.label) sub.addBlock(and_()) sub.addBlock(or_()) sub.addBlock(not_()) sub.addBlock(true_()) sub.addBlock(false_()) self.add(sub)
def __init__(self): HorizontalPanel.__init__(self, StyleName="type_block select_block") self.add(Label(_('Type') + ':')) fake = Element(Element=DOM.createDiv()) self.color = 'grey' self.commandBlock = getattr(ArduinoBlocks, 'commandType')('comando', 'grey', off=True) fake.append(self.commandBlock) self.commandType = RadioButton("groupType", fake.getElement().innerHTML, True) self.commandType.setChecked(True) self.commandType.addClickListener(getattr(self, "onClickCommandType")) self.add(self.commandType) fake.removeAll() self.booleanBlock = getattr(ArduinoBlocks, 'logicType')('logico', 'grey', off=True) fake.append(self.booleanBlock) self.logicType = RadioButton("groupType", fake.getElement().innerHTML, True) self.logicType.addClickListener(getattr(self, "onClickLogicType")) self.add(self.logicType) fake.removeAll() self.numberBlock = getattr(ArduinoBlocks, 'numericType')('numerico', 'grey', off=True) fake.append(self.numberBlock) self.numericType = RadioButton("groupType", fake.getElement().innerHTML, True) self.numericType.addClickListener(getattr(self, "onClickNumericType")) self.add(self.numericType) fake.removeAll() self.stringBlock = getattr(ArduinoBlocks, 'alphaNumericType')('alfanumerico', 'grey', off=True) fake.append(self.stringBlock) self.alphaNumericType = RadioButton("groupType", fake.getElement().innerHTML, True) self.alphaNumericType.addClickListener( getattr(self, "onClickAlphanumericType")) self.add(self.alphaNumericType) self.onClickCommandType()
def __init__(self): CategoryPanel.__init__(self) self.label = 'variables_lbl' buttonsTab = SubCategoryPanel() self.add(buttonsTab) self.buttonAddVar = Button(_('Add Variable'), self.addVarClick) buttonsTab.addWidget(self.buttonAddVar) self.dropdownRemoveVar = Dropdown(_('Remove Variable'), self.menuClick, self.itemClick, StyleName='dropdown_btn') self.dropdownRemoveVar.setStyleAttribute('display', 'none') buttonsTab.addWidget(self.dropdownRemoveVar) self.alphanumericTab = SubCategoryPanel(_('Alphanumerics'), self.label) self.numericTab = SubCategoryPanel(_('Numerics'), self.label) self.logicTab = SubCategoryPanel(_('Logics'), self.label) self.genericLogicBlocks = [] self.genericNumericBlocks = [] self.genericAlphaNumericBlocks = []
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 changeTexts(self): CategoryPanel.changeTexts(self) self.buttonAddVar.setText(_('Add Variable')) self.dropdownRemoveVar.setText(_('Remove Variable'))
def changeTexts(self): if self.number is not None: DOM.setInnerHTML(self.td.getElement(), _(self.text) + str(self.number)) else: DOM.setInnerHTML(self.td.getElement(), _(self.text))
def changeTexts(self): DOM.setInnerHTML(self.title.getElement(), _(self.value))
def __init__(self, okClick, cancelClick): Popup.__init__(self, '<b>' + _('New Block') + '</b>', okClick, cancelClick, CONFIRM_CANCEL)
def changeTitle(self, count): # faz perder o collapse DOM.setInnerHTML(self.title.getElement(), _(self.subCategoryName) + ': #' + str(count)) self.title.add(self.collapse) self.count = count
def changeTexts(self): if self.subCategoryName != '': DOM.setInnerHTML(self.title.getElement(), _(self.subCategoryName)) self.title.add(self.collapse) for block in self.blocks: block.changeTexts()
def __init__(self, changeLanguage, **kwargs): FlowPanel.__init__(self, **kwargs) self.setID('header') #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group2') self.buttonBlocks = Button(_('Blocks'), self.showBlocks, classIcon="icon-selected") div.add(self.buttonBlocks) self.buttonHarwares = Button(_('Components'), self.showHardwares, classIcon="icon-deselected") div.add(self.buttonHarwares) self.add(div) #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group2 groupHidden') self.buttonMakeBlock = Button(_('Building Block'), self.makeBlock, classIcon="icon-buildBlock") div.add(self.buttonMakeBlock) #self.dropdownMakeBlock = Dropdown('', None, self.makeBlockItemClick, StyleName='dropdown_btn', rootPanel=div) #self.dropdownMakeBlock.addValue('Importar Bloco', 'icon-ImportBlock') #self.dropdownMakeBlock.addValue('Exportar Bloco', 'icon-ExportBlock') #div.add(self.dropdownMakeBlock) self.add(div) #--------------------------------------------------------------------------------------------------- #div = Element(Element=DOM.createDiv(), StyleName='btn-group2') #self.buttonReload = Button(_('Reload'), self.reloadClick, classIcon="icon-repeat") #div.add(self.buttonReload) #self.add(div) #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group2 groupHidden') self.buttonUndo = Button(_('Undo'), undo, classIcon="icon-undo") div.add(self.buttonUndo) self.buttonRedo = Button(_('Redo'), redo, classIcon="icon-redo") div.add(self.buttonRedo) self.add(div) #self.buttonUndo2 = Button("Desfazer2", self.undo2) #self.add(self.buttonUndo2) #self.buttonRedo2 = Button("Refazer2", self.redo2) #self.add(self.buttonRedo2) #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group2 groupHidden') self.buttonOpen = Button(_('Open'), loadState, classIcon="icon-open") div.add(self.buttonOpen) self.buttonSave = Button(_('Save'), saveState, classIcon="icon-download") self.buttonSave.setID("btnSave") div.add(self.buttonSave) self.add(div) #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group') self.codeGenerator = GenerateCodeButtonListener( getWorkspace().getCodePanel()) self.buttonTranslate = Button(_("Translate"), self.codeGenerator) self.buttonTranslate.addMouseListener(self) div.add(self.buttonTranslate) self.dropdownTranslate = Dropdown('', None, self.translateItemClick, StyleName='dropdown_btn', rootPanel=div) self.isAutomatic = False self.dropdownTranslate.addValue(gettext_noop('Manual'), 'icon-selected') self.dropdownTranslate.addValue(gettext_noop('Automatic'), 'icon-deselected') div.add(self.dropdownTranslate) self.add(div) #--------------------------------------------------------------------------------------------------- div = Element(Element=DOM.createDiv(), StyleName='btn-group2') self.changeLanguage = changeLanguage self.dropdownFlag = Dropdown('', None, self.flagItemClick, StyleName='dropdown_btn flag', classIcon='icon-pt_BR') self.dropdownFlag.addValue('Português', 'icon-pt_BR') self.dropdownFlag.addValue('English', 'icon-en_US') self.dropdownFlag.addValue('Español', 'icon-es_ES') self.dropdownFlag.addValue('Italiano', 'icon-it_IT') self.dropdownFlag.addMouseListener(TooltipListener("Idioma")) div.add(self.dropdownFlag) self.add(div) #--------------------------------------------------------------------------------------------------- self.mainStack = []
def changeTexts(self): DOM.setInnerHTML(self.getElement(), _(self.tabName))
def addSubCategory(self, block): if self.myBlocksSubCat == None: self.myBlocksSubCat = SubCategoryPanel(_('My Blocks'), self.label) self.add(self.myBlocksSubCat) self.myBlocksSubCat.addBlock(block)
def changeTexts(self): if self.text != '': DOM.setInnerHTML(self.title.getElement(), _(self.text))