本文整理汇总了Python中muntjac.api.Label.setContentMode方法的典型用法代码示例。如果您正苦于以下问题:Python Label.setContentMode方法的具体用法?Python Label.setContentMode怎么用?Python Label.setContentMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类muntjac.api.Label
的用法示例。
在下文中一共展示了Label.setContentMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LabelRichExample
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
class LabelRichExample(VerticalLayout, IClickListener):
def __init__(self):
super(LabelRichExample, self).__init__()
self.setSpacing(True)
self._editor = RichTextArea()
self._richText = Label('<h1>Rich text example</h1>'
'<p>The <b>quick</b> brown fox jumps <sup>over</sup> '
'the <b>lazy</b> dog.</p>'
'<p>This text can be edited with the <i>Edit</i> -button</p>')
self._richText.setContentMode(Label.CONTENT_XHTML)
self.addComponent(self._richText)
self._b = Button('Edit')
self._b.addListener(self, IClickListener)
self.addComponent(self._b)
self._editor.setWidth('100%')
def buttonClick(self, event):
if self.getComponentIterator().next() == self._richText:
self._editor.setValue(self._richText.getValue())
self.replaceComponent(self._richText, self._editor)
self._b.setCaption('Apply')
else:
self._richText.setValue(self._editor.getValue())
self.replaceComponent(self._editor, self._richText)
self._b.setCaption('Edit')
示例2: TextAreaExample
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
class TextAreaExample(HorizontalLayout, IValueChangeListener):
_initialText = 'The quick brown fox jumps over the lazy dog.'
def __init__(self):
super(TextAreaExample, self).__init__()
self.setSpacing(True)
self.setWidth('100%')
self._editor = TextArea(None, self._initialText)
self._editor.setRows(20)
self._editor.setColumns(20)
self._editor.addListener(self, IValueChangeListener)
self._editor.setImmediate(True)
self.addComponent(self._editor)
# the TextArea is immediate, and it's valueCahnge updates the Label,
# so this button actually does nothing
self.addComponent(Button('>'))
self._plainText = Label(self._initialText)
self._plainText.setContentMode(Label.CONTENT_XHTML)
self.addComponent(self._plainText)
self.setExpandRatio(self._plainText, 1)
# Catch the valuechange event of the textfield and update the value of the
# label component
def valueChange(self, event):
text = self._editor.getValue()
if text is not None:
# replace newline with BR, because we're using Label.CONTENT_XHTML
text = text.replace('\n', '<br/>')
self._plainText.setValue(text)
示例3: __init__
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
def __init__(self):
super(LabelPlainExample, self).__init__()
self.setSpacing(True)
plainText = Label('This is an example of a Label'
' component. The content mode of this label is set'
' to CONTENT_TEXT. This means that it will display'
' the content text as is. HTML and XML special characters'
' (<,>,&) are escaped properly to allow displaying them.')
plainText.setContentMode(Label.CONTENT_TEXT)
self.addComponent(plainText)
示例4: __init__
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
def __init__(self):
super(LabelPreformattedExample, self).__init__()
self.setSpacing(True)
preformattedText = Label('This is an example of a Label component.\n'
'\nThe content mode of this label is set'
'\nto CONTENT_PREFORMATTED. This means'
'\nthat it will display the content text'
'\nusing a fixed-width font. You also have'
'\nto insert the line breaks yourself.\n'
'\n\tHTML and XML special characters'
'\n\t(<,>,&) are escaped properly to'
'\n\tallow displaying them.')
preformattedText.setContentMode(Label.CONTENT_PREFORMATTED)
self.addComponent(preformattedText)
示例5: __init__
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
def __init__ ( self, parent, html, scale_dx, scale_dy ):
""" Initializes the object.
"""
super(HTMLHelpWindow, self).__init__()
self.setParent(parent)
layout = VerticalLayout()
layout.setMargin(False)
# Create the html control
html_control = Label(html)
html_control.setContentMode(Label.CONTENT_XHTML)
layout.addComponent(html_control)
# Create the OK button
ok = Button('OK')
# FIXME: add event handler
layout.addComponent(ok)
layout.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT)
# Position and show the dialog
position_window(self, parent=parent)
self.show()
示例6: MuntjacHtml
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
class MuntjacHtml(MuntjacControl, AbstractTkHtml):
""" A Muntjac implementation of Html.
"""
#--------------------------------------------------------------------------
# Setup methods
#--------------------------------------------------------------------------
def create(self, parent):
""" Creates the underlying widget to display HTML.
"""
self.widget = Label()
self.widget.setContentMode(Label.CONTENT_XHTML)
parent.addComponent(self.widget)
def initialize(self):
""" Initializes the attributes of the control.
"""
super(MuntjacHtml, self).initialize()
self.set_page_source(self.shell_obj.source)
#--------------------------------------------------------------------------
# Implementation
#--------------------------------------------------------------------------
def shell_source_changed(self, source):
""" The change handler for the 'source' attribute.
"""
self.set_page_source(source)
def set_page_source(self, source):
""" Sets the page source for the underlying control.
"""
self.widget.setValue(source)
示例7: setFeature
# 需要导入模块: from muntjac.api import Label [as 别名]
# 或者: from muntjac.api.Label import setContentMode [as 别名]
def setFeature(self, feature):
from muntjac.demo.sampler.SamplerApplication import SamplerApplication
if feature != self._currentFeature:
self._currentFeature = feature
self._right.removeAllComponents()
self._left.removeAllComponents()
self._left.addComponent(self._controls)
self._title.setValue('<span>' + feature.getName() + '</span>')
if feature.getSinceVersion().isNew():
self._title.addStyleName('new')
else:
self._title.removeStyleName('new')
self._left.addComponent(self.getExampleFor(feature))
self._right.setCaption('Description and Resources')
# Do not show parent description if it's directly inside the root
alll = SamplerApplication.getAllFeatures()
parent = alll.getParent(feature)
isRoot = alll.getParent(parent) is None
desc = parent.getDescription()
hasParentDesc = False
if parent is not None and not isRoot:
parentLabel = Label(parent.getDescription())
if desc is not None and desc != '':
parentLabel.setContentMode(Label.CONTENT_XHTML)
self._right.addComponent(parentLabel)
hasParentDesc = True
desc = feature.getDescription()
if desc is not None and desc != '':
# Sample description uses additional decorations if a parent
# description is found
l = Label(("<div class=\"outer-deco\"><div class=\"deco\">"
"<span class=\"deco\"></span>")
+ desc + "</div></div>", Label.CONTENT_XHTML)
self._right.addComponent(l)
if hasParentDesc:
l.setStyleName('sample-description')
else:
l.setStyleName('description')
# open src in new window -link
self._showSrc.setTargetName(self._currentFeature.getFragmentName())
er = ExternalResource(self.getApplication().getURL()
+ 'src/' + self._currentFeature.getFragmentName())
self._showSrc.setResource(er)
resources = feature.getRelatedResources()
if resources is not None:
res = VerticalLayout()
self.caption = Label("<span>Additional Resources</span>",
Label.CONTENT_XHTML)
self.caption.setStyleName('section')
self.caption.setWidth('100%')
res.addComponent(self.caption)
res.setMargin(False, False, True, False)
for r in resources:
l = Link(r.getName(), r)
l.setIcon( ThemeResource('../runo/icons/16/note.png') )
res.addComponent(l)
self._right.addComponent(res)
apis = feature.getRelatedAPI()
if apis is not None:
api = VerticalLayout()
self.caption = Label("<span>API Documentation</span>",
Label.CONTENT_XHTML)
self.caption.setStyleName('section')
self.caption.setWidth('100%')
api.addComponent(self.caption)
api.setMargin(False, False, True, False)
for r in apis:
l = Link(r.getName(), r)
ic = ThemeResource('../runo/icons/16/document-txt.png')
l.setIcon(ic)
api.addComponent(l)
self._right.addComponent(api)
features = feature.getRelatedFeatures()
if features is not None:
rel = VerticalLayout()
self.caption = Label("<span>Related Samples</span>",
Label.CONTENT_XHTML)
self.caption.setStyleName('section')
self.caption.setWidth('100%')
rel.addComponent(self.caption)
rel.setMargin(False, False, True, False)
for c in features:
f = SamplerApplication.getFeatureFor(c)
if f is not None:
er = ExternalResource(self.getApplication().getURL()
+ '#' + f.getFragmentName())
al = ActiveLink(f.getName(), er)
if isinstance(f, FeatureSet):
ic = ThemeResource('../sampler/icons/category.gif')
#.........这里部分代码省略.........