本文整理汇总了Python中pyjamas.ui.TextArea.TextArea.setFocus方法的典型用法代码示例。如果您正苦于以下问题:Python TextArea.setFocus方法的具体用法?Python TextArea.setFocus怎么用?Python TextArea.setFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.TextArea.TextArea
的用法示例。
在下文中一共展示了TextArea.setFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onSelectionChange
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import setFocus [as 别名]
class SelectionTest:
def onSelectionChange(self, selection):
self.refresh(selection)
"""*
* This is the entry point method.
"""
def onModuleLoad(self):
dlp = DockPanel(Width="100%", Height="100%")
self.m_rte = RichTextArea(Width="500px", Height="400px")
self.m_tb = RichTextToolbar(self.m_rte, self)
buts = FlowPanel()
self.m_getCurr = Button("Refresh v", self)
self.m_setHtml = Button("Set html ^", self)
self.m_setHtml.setTitle("Set html from the lower left text area")
self.m_toSCursor = Button("< To Cursor", self)
self.m_toSCursor.setTitle("Set the selection to be a cursor at the beginning of the current selection")
self.m_toECursor = Button("To Cursor >", self)
self.m_toECursor.setTitle("Set the selection to be a cursor at the end of the current selection")
self.m_surround1 = Button("Surround1", self)
self.m_surround2 = Button("Surround2", self)
self.m_font1 = Button("Times New Roman", self)
self.m_font2 = Button("Arial", self)
grid = Grid(2, 2)
self.m_startNode = self.createTextBox(1)
self.m_startOffset = self.createTextBox(3)
self.m_endNode = self.createTextBox(4)
self.m_endOffset = self.createTextBox(5)
self.m_select = Button("`>Select", self)
self.m_select.setTitle("Select the texts/offsets in the boxes above")
self.m_cursor = Button("`>Cursor", self)
self.m_cursor.setTitle("Set cursor to text/offset of top 2 boxes above")
grid.setWidget(0, 0, self.m_startNode)
grid.setWidget(0, 1, self.m_startOffset)
grid.setWidget(1, 0, self.m_endNode)
grid.setWidget(1, 1, self.m_endOffset)
self.m_deleteSel = Button("Delete", self)
self.m_reset = Button("Reset", self)
buts.add(self.m_getCurr)
buts.add(self.m_setHtml)
buts.add(self.m_toSCursor)
buts.add(self.m_toECursor)
buts.add(self.m_font1)
buts.add(self.m_font2)
buts.add(self.m_surround1)
buts.add(self.m_surround2)
buts.add(grid)
buts.add(self.m_select)
buts.add(self.m_cursor)
buts.add(self.m_deleteSel)
buts.add(self.m_reset)
dlp.add(buts, DockPanel.WEST)
textPanels = DockPanel()
self.m_html = TextArea()
self.m_html.setSize("100%", "100%")
self.m_sel = TextArea()
self.m_sel.setSize("100%", "100%")
textPanels.add(self.m_sel, DockPanel.EAST)
textPanels.add(self.m_html, DockPanel.WEST)
dlp.add(textPanels, DockPanel.SOUTH)
dlp.add(self.m_tb, DockPanel.NORTH)
dlp.add(self.m_rte, DockPanel.CENTER)
rp = RootPanel.get()
rp.add(dlp)
DeferredCommand.add(getattr(self, "set_html_focus"))
self.reset()
def set_html_focus(self):
self.m_html.setFocus(True)
def createTextBox(self, startVal):
res = TextBox()
res.setWidth("35px")
res.setText(str(startVal))
return res
def reset(self):
self.m_rte.setHTML(
"The <span style=\"font-weight: bold;\">quick</span> " +
"<span style=\"font-style: italic;\">brown </span>" +
"fox jumped<br>ov" +
"<a href=\"http:#google.com\">er </a>" +
"<span style=\"text-decoration: underline;\">" +
"<a href=\"http:#google.com\">th</a>e la</span>zy dogs<br>" +
"Some spaces<br>")
#.........这里部分代码省略.........