本文整理汇总了Python中pyjamas.ui.VerticalPanel.VerticalPanel.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Python VerticalPanel.setVisible方法的具体用法?Python VerticalPanel.setVisible怎么用?Python VerticalPanel.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.VerticalPanel.VerticalPanel
的用法示例。
在下文中一共展示了VerticalPanel.setVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ParamGroup
# 需要导入模块: from pyjamas.ui.VerticalPanel import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel.VerticalPanel import setVisible [as 别名]
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)
#.........这里部分代码省略.........
示例2: AlarmWidget
# 需要导入模块: from pyjamas.ui.VerticalPanel import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel.VerticalPanel import setVisible [as 别名]
class AlarmWidget(object):
weekday_name = { 0: 'Mo', 1: 'Di', 2: 'Mi', 3: 'Do', 4: 'Fr', 5: 'Sa', 6: 'So' }
def __init__(self):
self.alarms = Alarms(self)
self.make_table()
self.fill_table()
self.status = Label()
self.panel = self.make_panel()
def make_panel(self):
message = Label(
'The configuration has been changed.\n'
'You must apply the changes in order for them to take effect.')
DOM.setStyleAttribute(message.getElement(), "whiteSpace", 'pre')
msgbox = Grid(1, 2, StyleName='changes')
msgbox.setWidget(0, 0, Image('icons/exclam.png'))
msgbox.setWidget(0, 1, message)
msgbox.getCellFormatter().setStyleName(0, 0, 'changes-image')
msgbox.getCellFormatter().setStyleName(0, 1, 'changes-text')
button = Button('apply changes')
button.addClickListener(self.apply_clicked)
self.changes = VerticalPanel()
self.changes.setHorizontalAlignment('right')
self.changes.setVisible(False)
self.changes.add(msgbox)
self.changes.add(button)
panel = VerticalPanel()
panel.setSpacing(10)
panel.add(self.table)
panel.add(self.status)
panel.add(self.changes)
return panel
def make_table(self):
self.table = FlexTable(StyleName='alarms')
self.table.setBorderWidth(1)
self.make_header()
self.make_footer()
def make_header(self):
headers = [ 'Time', 'Days', 'Duration' ]
for col, text in enumerate(headers):
self.table.setText(0, col, text)
self.table.getCellFormatter().setStyleName(0, col, 'tablecell header')
def make_footer(self):
self.time = {}
self.time['hour'] = ListBox()
self.time['hour'].setVisibleItemCount(1)
for hour in range(24):
self.time['hour'].addItem('%02d' % hour)
self.time['hour'].setSelectedIndex(12)
self.time['minute'] = ListBox()
self.time['minute'].setVisibleItemCount(1)
for minute in range(0, 60, 5):
self.time['minute'].addItem('%02d' % minute)
self.time['minute'].setSelectedIndex(0)
time_panel = HorizontalPanel()
time_panel.setVerticalAlignment('center')
time_panel.add(self.time['hour'])
time_panel.add(Label(':'))
time_panel.add(self.time['minute'])
self.table.setWidget(1, 0, time_panel)
weekdays_panel = HorizontalPanel()
weekdays_panel.setSpacing(5)
self.weekdays = {}
for i in range(7):
self.weekdays[i] = CheckBox(AlarmWidget.weekday_name[i])
self.weekdays[i].setChecked(i < 6)
weekdays_panel.add(self.weekdays[i])
self.table.setWidget(1, 1, weekdays_panel)
self.duration = ListBox()
self.duration.setVisibleItemCount(1)
choices = [ 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60 ]
for seconds in choices:
self.duration.addItem(
'%ds' % seconds if seconds < 60 else '%dm' % (seconds / 60),
seconds)
self.duration.setSelectedIndex(2)
self.table.setWidget(1, 2, self.duration)
image = Image('icons/plus.png')
image.setTitle('add');
image.addClickListener(self.plus_clicked)
self.table.setWidget(1, 3, image)
for col in range(4):
self.table.getCellFormatter().setStyleName(1, col, 'tablecell noborder')
#.........这里部分代码省略.........