本文整理汇总了Python中pyjamas.ui.Label.Label.setStyleName方法的典型用法代码示例。如果您正苦于以下问题:Python Label.setStyleName方法的具体用法?Python Label.setStyleName怎么用?Python Label.setStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Label.Label
的用法示例。
在下文中一共展示了Label.setStyleName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Form_Row
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
class Form_Row(SimplePanel):
'''
Create row that will be put in the Form
'''
def __init__(self, name, widget, help=''):
SimplePanel.__init__(self)
# Container
self.mainpanel = VerticalPanel()
self.lbl = Label(name)
self.hlp = Label(help)
self.lbl.setStyleName('h3')
self.hlp.setStyleName('text-muted')
self.wdg = widget
self.mainpanel.add(self.lbl)
self.mainpanel.add(self.wdg)
self.mainpanel.add(self.hlp)
def panel(self):
return self.mainpanel
def widget(self):
return self.wdg
def help(self):
return self.hlp
示例2: addDropWidget
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
def addDropWidget(self):
s = len(self.children)
w = Label(Element=DOM.createElement('li'))
w.setID('effectdrop' + str(s))
w.setStyleName('drophere')
w.setText('Drop %s (%s)' % (s, self.data[s]))
self.append(w)
示例3: __init__
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
def __init__(self, start_date, can_delete=True):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.vpanel = VerticalPanel()
desc_panel = VerticalPanel()
self.desc_box = TextBox()
self.desc_box.setVisibleLength(44)
self.desc_box.setStyleName('form-control')
desc_lbl = Label('impediment description')
desc_lbl.setStyleName('text-muted')
desc_panel.add(self.desc_box)
desc_panel.add(desc_lbl)
# Set to False if loaded from database
self.can_delete = can_delete
status_panel = VerticalPanel()
self.status_lst = ListBox(Height='34px')
self.status_lst.setStyleName('form-control input-lg')
self.status_lst.addItem('Open')
self.status_lst.addItem('Closed')
# we put date here
self.status_lbl = Label('')
self.set_start_date(start_date)
self.status_lbl.setStyleName('text-muted')
status_panel = VerticalPanel()
status_panel.add(self.status_lst)
status_panel.add(self.status_lbl)
self.comment = Text_Area_Row('', 'why it exists or is being closed')
hpanel = HorizontalPanel()
hpanel.add(desc_panel)
hpanel.add(Label(Width='10px'))
hpanel.add(status_panel)
self.vpanel.add(hpanel)
self.vpanel.add(self.comment.panel())
示例4: addDragWidget
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
def addDragWidget(self):
s = len(self.children)
w = Label(Element=DOM.createElement('li'))
w.setID('effectdrag' + str(s))
w.setStyleName('dragme')
w.setText('Drag %s (%s)' % (s, self.data[s]))
self.add(w)
makeDraggable(w)
示例5: __init__
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
def __init__(self, contact):
# The popup's constructor's argument is a boolean specifying that it
# auto-close itself when the user clicks outside of it.
PopupPanel.__init__(self, True)
inner = VerticalPanel()
nameLabel = Label(contact.name)
emailLabel = Label(contact.email)
inner.add(nameLabel)
inner.add(emailLabel)
panel = HorizontalPanel()
panel.setSpacing(4)
panel.add(Image(contact.photo))
panel.add(inner)
self.add(panel)
self.setStyleName("mail-ContactPopup")
nameLabel.setStyleName("mail-ContactPopupName")
emailLabel.setStyleName("mail-ContactPopupEmail")
示例6: Game
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
class Game(VerticalPanel):
def __init__(self, row, column=0):
super(Game, self).__init__(StyleName='game')
self.sinkEvents(Event.ONCONTEXTMENU) # to disable right click
self.row = row
self.column = column or row
self.level = 1
self.toppers = [[], [], []] # storage for top scorers for 3 levels.
self.remote = DataService()
self.remote_handler = RemoteHandler(self)
self.remote.get_scores(self.remote_handler)
# contents of Game
menubar = MineMenuBar(self)
score_board = HorizontalPanel(StyleName='score-board')
self.grid_panel = SimplePanel(StyleName='grid-panel')
self.add(menubar)
self.add(score_board)
self.add(self.grid_panel)
# contents of score_board
self.counter = Label('000', StyleName='digit counter')
self.face = Smiley(self)
self.timer = Label('000', StyleName='digit timer')
for one in (self.counter, self.face, self.timer):
score_board.add(one)
score_board.setCellWidth(self.face, '100%')
self.create_grid()
self.start()
def onBrowserEvent(self, event):
# prevent right click context menu as well as all the other events.
DOM.eventPreventDefault(event)
def create_grid(self):
# contents of self.grid_panel
self.grid = CustomGrid(self, self.row, self.column)
self.grid_panel.add(self.grid)
def start(self, no_of_bomb=0):
self.time = -1
self.started = True
self.first_click = True
self.bombed_cells = []
self.flagged_cells = []
self.to_be_released = [] # cells to be released after being pressed
self.count_opened_cells = 0
self.no_of_click = 0
self.squares = self.row * self.column
self.no_of_bomb = no_of_bomb or int((self.squares * 10) / 64)
self.no_of_safe_zones = self.squares - self.no_of_bomb
self.set_counter()
self.timer.setText('000')
self.generate_bombs()
self.face.setStyleName('facesmile')
def get_all_cells(self):
for i in xrange(self.row):
for j in xrange(self.column):
one = self.grid.getCell(i, j)
yield one
def get_neighbors(self, cell):
x = cell.x
y = cell.y
row, column = self.row, self.column
for i in xrange(x-1, x+2):
if 0 <= i < row:
for j in xrange(y-1, y+2):
if 0 <= j < column:
if (i,j) != (x, y):
one = self.grid.getCell(i, j)
yield one
def set_counter(self):
next_value = self.no_of_bomb - len(self.flagged_cells)
if next_value == 0 and self.started:
self.counter.setStyleName('digit counter-blue')
self.counter.addClickListener(RemainingMineHandler(self))
else:
self.counter.setStyleName('digit counter')
self.counter._clickListeners = []
if next_value < 0:
template = '-00'
next_value = abs(next_value)
else:
template = '000'
value = str(next_value)
value = template[:-len(value)] + value
self.counter.setText(value)
#.........这里部分代码省略.........
示例7: Milestones_Row
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
class Milestones_Row(SimplePanel):
'''
Create and edit projects
'''
def __init__(self, milestone_names, milestone_dates):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.milestone_dates = milestone_dates
self.hpanel = HorizontalPanel()
self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
self.name = ListBox(Height='34px', Width='208px')
self.name.setStyleName('form-control input-lg')
self.name.addChangeListener(getattr(self, 'on_milestone_changed'))
for m in milestone_names:
self.name.addItem(m)
if len(self.milestone_dates) > 0:
self.planned_completion = Label(self.milestone_dates[0])
else:
self.planned_completion = Label('Undefined')
self.planned_completion.setStyleName('form-control text-normal')
self.expected_completion = Report_Date_Field(cal_ID='end')
self.expected_completion.getTextBox().setStyleName('form-control')
self.expected_completion.setRegex(DATE_MATCHER)
self.expected_completion.appendValidListener(self._display_ok)
self.expected_completion.appendInvalidListener(self._display_error)
self.expected_completion.validate(None)
self.hpanel.add(self.name)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.planned_completion)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.expected_completion)
def get_name_txt(self):
'''Return project name.
'''
return self.name.getText()
def get_milestone_data(self):
'''Get milestone data and return in the form suitable for passing to
the model.
'''
name = self.name.getItemText(self.name.getSelectedIndex())
planned_completion = self.planned_completion.getText()
expected_completion = self.expected_completion.getTextBox().getText()
return (name, planned_completion, expected_completion)
def _display_ok(self, obj):
obj.setStyleName('form-input')
def _display_error(self, obj):
if len(obj.getTextBox().getText()) > 0:
obj.setStyleName('form-group has-error')
def on_milestone_changed(self, event):
'''
Change completion date if milestone changed
'''
ind = self.name.getSelectedIndex()
self.planned_completion.setText(self.milestone_dates[ind])
示例8: Impediments
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
class Impediments(SimplePanel):
'''
Create and edit projects
'''
def __init__(self, start_date, can_delete=True):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.vpanel = VerticalPanel()
desc_panel = VerticalPanel()
self.desc_box = TextBox()
self.desc_box.setVisibleLength(44)
self.desc_box.setStyleName('form-control')
desc_lbl = Label('impediment description')
desc_lbl.setStyleName('text-muted')
desc_panel.add(self.desc_box)
desc_panel.add(desc_lbl)
# Set to False if loaded from database
self.can_delete = can_delete
status_panel = VerticalPanel()
self.status_lst = ListBox(Height='34px')
self.status_lst.setStyleName('form-control input-lg')
self.status_lst.addItem('Open')
self.status_lst.addItem('Closed')
# we put date here
self.status_lbl = Label('')
self.set_start_date(start_date)
self.status_lbl.setStyleName('text-muted')
status_panel = VerticalPanel()
status_panel.add(self.status_lst)
status_panel.add(self.status_lbl)
self.comment = Text_Area_Row('', 'why it exists or is being closed')
hpanel = HorizontalPanel()
hpanel.add(desc_panel)
hpanel.add(Label(Width='10px'))
hpanel.add(status_panel)
self.vpanel.add(hpanel)
self.vpanel.add(self.comment.panel())
def set_start_date(self, start_date):
date_str = 'added on: ' + start_date
self.status_lbl.setText(date_str)
def get_impediment_data(self):
'''Get impediment data as a list suitable to passing to model.
'''
desc = self.desc_box.getText()
comment = self.comment.widget().getText()
state = self.status_lst.getItemText(self.status_lst.getSelectedIndex())
lbl_text = self.status_lbl.getText()
#
ind = lbl_text.find(':') + 1
# We need just date
start_date = lbl_text[ind:].strip()
if state == 'Open':
end_date = None
else:
end_date = datetime.date.today().strftime('%d/%m/%Y')
return (desc, comment, start_date, end_date, state)
示例9: TweetEditor
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setStyleName [as 别名]
class TweetEditor(Grid):
def __init__(self, query, nUsers, tabName, popup, preparePanel, topPanel):
Grid.__init__(self, 3, 2)
self.tweet = text.TextAreaFocusHighlight(
Text="Tickery query %r has %d results. See them at" % (
query, nUsers),
VisibleLines=3, MaxLength=1000, StyleName='large-query-area')
self.tweet.addKeyboardListener(self)
self.query = query
self.tabName = tabName
self.popup = popup
self.preparePanel = preparePanel
self.topPanel = topPanel
self.button = Button('Tweet!', self)
self.count = Label('')
self.setWidget(0, 0, HTML(_instructions))
self.setWidget(0, 1, self.count)
self.setWidget(1, 0, self.tweet)
self.setWidget(1, 1, self.button)
formatter = self.getCellFormatter()
formatter.setVerticalAlignment(0, 1, 'bottom')
formatter.setVerticalAlignment(1, 1, 'bottom')
self.setCount()
def onClick(self, sender):
self.button.setEnabled(False)
text = self.tweet.getText().strip()
remote = server.TickeryService()
id = remote.tweet(
self.topPanel.loginPanel.oauthCookie, text, self.query,
self.tabName, userlist._sortKey, self)
if id < 0:
self.setWidget(2, 0, Label('Oops!'))
def onRemoteResponse(self, response, request_info):
self.button.setEnabled(True)
if response['result']:
self.popup.hide()
self.preparePanel.link.setHTML('<a href="%s"> %s</a>' %
(response['URL'], _doneText))
else:
self.setWidget(2, 0, Label('Oops: %r' % response))
def onRemoteError(self, code, message, request_info):
self.button.setEnabled(True)
self.setWidget(2, 0,
Label('Server Err or Invalid Response: ERROR %d - %s' %
(code, message)))
def onKeyDown(self, sender, keycode, modifiers):
pass
def onKeyUp(self, sender, keycode, modifiers):
pass
def onKeyPress(self, sender, keycode, modifiers):
self.setCount()
def setCount(self):
n = TWEET_LIMIT - len(self.tweet.getText())
if n >= 0:
self.count.setStyleName('tweet-char-count-ok')
else:
self.count.setStyleName('tweet-char-count-excessive')
self.count.setText(str(n))