def __init__(self): SimplePanel.__init__(self) panel = VerticalPanel() panel.setBorderWidth(1) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) part1 = Label("Part 1") part2 = Label("Part 2") part3 = Label("Part 3") part4 = Label("Part 4") panel.add(part1) panel.add(part2) panel.add(part3) panel.add(part4) panel.setCellHeight(part1, "10%") panel.setCellHeight(part2, "70%") panel.setCellHeight(part3, "10%") panel.setCellHeight(part4, "10%") panel.setCellHorizontalAlignment(part3, HasAlignment.ALIGN_RIGHT) panel.setWidth("50%") panel.setHeight("300px") self.add(panel)
def __init__(self): SimplePanel.__init__(self) panel = VerticalPanel(BorderWidth=1, HorizontalAlignment=HasAlignment.ALIGN_CENTER, VerticalAlignment=HasAlignment.ALIGN_MIDDLE, Width="50%", Height="300px") part1 = Label("Part 1") part2 = Label("Part 2") part3 = Label("Part 3") part4 = Label("Part 4") panel.add(part1) panel.add(part2) panel.add(part3) panel.add(part4) panel.setCellHeight(part1, "10%") panel.setCellHeight(part2, "70%") panel.setCellHeight(part3, "10%") panel.setCellHeight(part4, "10%") panel.setCellHorizontalAlignment(part3, HasAlignment.ALIGN_RIGHT) self.add(panel)
class DayFilterWidget(Composite): def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.initWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER) def setAllCheckBoxes(self, checked): for widget in self.outer: if hasattr(widget, "setChecked"): widget.setChecked(checked) self.dayCheckBoxListener.onClick(widget) def onClick(self, sender): if self.buttonAll == sender: self.setAllCheckBoxes(True) elif self.buttonNone == sender: self.setAllCheckBoxes(False)
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 ) : self.cbcList=ListBox(MultipleSelect=True, VisibleItemCount=4) self.channelList=ListBox(MultipleSelect=True, VisibleItemCount=20) self.updateButton=Button("Update") controls=VerticalPanel() controls.add(self.updateButton) controls.add(self.cbcList) controls.add(self.channelList) controls.setCellHorizontalAlignment( self.updateButton, HasHorizontalAlignment.ALIGN_CENTER ) self.cbcList.setWidth("95%") self.channelList.setWidth("95%") self.cbcList.addItem( "waiting..." ) for index in range(0,254) : self.channelList.addItem( "Channel %3d"%index ) self.histogram = Image() self.mainPanel = HorizontalPanel() self.mainPanel.add( controls ) self.mainPanel.add( self.histogram ) self.histogram.setUrl( "defaultScurveHistogram.png" )
class ParamGroup(object): def __init__(self, container, kind, parent=None, level=0, draw=True, title=None): self.container = container self.kind = kind self.parent = parent self.level = level self.title = title self.panel = SimplePanel(StyleName='aur-search-advanced-group') if level % 2 == 0: self.panel.addStyleName('aur-search-advanced-group-nested') self.childPanel = VerticalPanel(StyleName='aur-search-advanced-group-list', Width='100%') self.paramPanel = VerticalPanel(StyleName='aur-search-advanced-param-list', Width='100%') self.listPanel = VerticalPanel(StyleName='aur-search-advanced-list-boundary', Width='100%', Visible=False) self.paramChooser = ListBox() self.children = [] self.parameters = [] self.isInverted = False self.operator = 'and' # assigned by parent, visual use only self.op = None if parent else Label('and') if draw: self.draw() def draw(self): cont = VerticalPanel(Width='100%') header = HorizontalPanel(Width='100%', VerticalAlignment='middle', StyleName='aur-search-advanced-group-header') params = self.paramChooser addParam = Image(url='/ico/tick.png', Title='Add parameter to this group') addGroup = Image(url='/ico/table_add.png', Title='Nest group within this group') addGroupFull = Image(url='/ico/table_lightning.png', Title='Nest group within this group; all parameters') invertSelf = Image(url='/ico/exclamation.png', Title='Invert this parameter group') self.container.add(self.panel) self.panel.setWidget(cont) cont.add(header) if self.parent: d = Image(url='/ico/cross.png', Title='Delete this parameter group') d.addStyleName('aur-search-advanced-delete') header.add(d) header.setCellWidth(d, '1px') d.addClickListener(getattr(self, 'delSelf')) if self.title: t = Label(self.title, StyleName='aur-search-advanced-group-header-title') header.add(t) header.setCellWidth(t, '1px') header.add(params) header.add(addParam) header.add(addGroup) header.add(addGroupFull) header.add(invertSelf) header.setCellWidth(params, '1px') header.setCellWidth(addGroup, '1px') header.setCellWidth(addGroupFull, '1px') header.setCellWidth(invertSelf, '1px') for x in self.kind: params.addItem(x['item'], x['index']) cont.add(self.listPanel) self.listPanel.add(self.paramPanel) self.listPanel.add(self.childPanel) addParam.addClickListener(getattr(self, 'addParam')) addGroup.addClickListener(getattr(self, 'addGroup')) addGroupFull.addClickListener(getattr(self, 'addGroupFull')) invertSelf.addClickListener(getattr(self, 'invertSelf')) def addGroup(self, sender): self.listPanel.setVisible(True) op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-group-op', Visible=False) op.addClickListener(getattr(self, 'invertOperator')) if len(self.children) > 0 or len(self.parameters) > 0: op.setVisible(True) self.childPanel.add(op) self.childPanel.setCellHorizontalAlignment(op, 'right') g = ParamGroup(self.childPanel, self.kind, self, self.level+1) g.op = op self.children.append(g) def addGroupFull(self, sender): # this is a little hacky, but it's so fast you don't see it self.addGroup(None) group = self.children[len(self.children)-1] for x in range(group.paramChooser.getItemCount()): group.paramChooser.setSelectedIndex(x) group.addParam(None) group.paramChooser.setSelectedIndex(0) def addParam(self, sender): self.listPanel.setVisible(True) op = Label(self.operator, Title='Invert group operator', StyleName='aur-search-advanced-param-op', Visible=False) op.addClickListener(getattr(self, 'invertOperator')) if len(self.parameters) > 0: op.setVisible(True) self.paramPanel.add(op) self.paramPanel.setCellHorizontalAlignment(op, 'right') k = self.kind[self.paramChooser.getSelectedValues()[0]] p = Param(self.paramPanel, k, self) p.op = op self.parameters.append(p) if len(self.children) > 0: self.children[0].op.setVisible(True) def addParamFull(self, sender): # this is a little hacky, but it's so fast you don't see it old = self.paramChooser.getSelectedIndex() for x in range(self.paramChooser.getItemCount()): self.paramChooser.setSelectedIndex(x) self.addParam(None) self.paramChooser.setSelectedIndex(old) def delGroup(self, child): self.children.remove(child) self.childPanel.remove(child.op) self.childPanel.remove(child.panel) lp = len(self.parameters) lc = len(self.children) if lp == 0 and lc > 0: self.children[0].op.setVisible(False) if lp == 0 and lc == 0: self.listPanel.setVisible(False) def delParam(self, param): self.parameters.remove(param) self.paramPanel.remove(param.op) self.paramPanel.remove(param.panel) lp = len(self.parameters) lc = len(self.children) if lp > 0: self.parameters[0].op.setVisible(False) if lp == 0 and lc > 0: self.children[0].op.setVisible(False) if lp == 0 and lc == 0: self.listPanel.setVisible(False) def delSelf(self, sender): self.parent.delGroup(self) def invertSelf(self, sender): if self.isInverted: self.isInverted = False self.panel.removeStyleName('aur-search-advanced-group-inverted') self.op.setText(self.operator) else: self.isInverted = True self.panel.addStyleName('aur-search-advanced-group-inverted') self.op.setText(self.operator + ' not') def invertOperator(self, sender): self.operator = 'or' if self.operator == 'and' else 'and' for x in self.parameters: suffix = ' not' if x.isInverted else '' x.op.setText(self.operator + suffix) for x in self.children: suffix = ' not' if x.isInverted else '' x.op.setText(self.operator + suffix)