本文整理汇总了Python中pyjamas.ui.HTML.HTML.setText方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.setText方法的具体用法?Python HTML.setText怎么用?Python HTML.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HTML.HTML
的用法示例。
在下文中一共展示了HTML.setText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BulkDirectAdd
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class BulkDirectAdd(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Directly add in bulk:', StyleName='section'))
self.names = TextArea(VisibleLines=5)
self.add(self.names)
self.update = Button('Add', self)
self.add(self.update)
self.err = HTML()
self.add(self.err)
def onClick(self, sender):
self.err.setHTML('')
names = self.names.getText().strip()
if names == '':
return
else:
self.update.setEnabled(False)
remote = server.AdminService()
id = remote.bulkAddUsers(names, self)
if id < 0:
self.err.setText('oops: could not add')
def onRemoteResponse(self, result, request_info):
self.update.setEnabled(True)
self.err.setText('OK, adding.')
def onRemoteError(self, code, message, request_info):
self.update.setEnabled(True)
self.err.setHTML('Errors:<br/>' +
'<br/>'.join(message['data']['message']))
示例2: DisplayPanel
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class DisplayPanel(Composite):
def __init__(self, owner):
Composite.__init__(self)
self.owner = owner
self.bar = DockPanel()
self.timer_msg = HTML(" timer: ")
self.timer = TimeDisplay()
self.timer_panel = HorizontalPanel()
self.timer_panel.add(self.timer_msg)
self.timer_panel.add(self.timer)
self.counter_msg = HTML(" total moves: ")
self.counter = HTML("0")
self.counter_panel = HorizontalPanel()
self.counter_panel.add(self.counter_msg)
self.counter_panel.add(self.counter)
self.initWidget(self.bar)
self.bar.add(self.timer_panel, DockPanel.WEST)
self.bar.add(self.counter_panel, DockPanel.EAST)
self.setStyleName("Puzzle-DisplayPanel")
def incrCount(self):
count = self.counter.getText()
count = int(count) + 1
self.counter.setText(count)
def reset(self):
self.timer.setDisplay(0, 0, 0)
self.counter.setText("0")
示例3: CalibrateChannelTrimsView
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class CalibrateChannelTrimsView(object) :
"""
Class that takes care of the purely UI parts of the trim calibration
"""
def __init__( self ) :
numberOfLoopsPanel=HorizontalPanel()
numberOfLoopsPanel.add( HTML("Maximum number of loops") )
self.maximumNumberOfLoops=TextBox()
self.maximumNumberOfLoops.setText(10)
numberOfLoopsPanel.add( self.maximumNumberOfLoops )
numberOfLoopsPanel.setCellHorizontalAlignment( self.maximumNumberOfLoops, HasHorizontalAlignment.ALIGN_RIGHT )
numberOfLoopsPanel.setWidth("100%")
aimPointPanel=HorizontalPanel()
aimPointPanel.add( HTML("Aim point") )
self.aimPoint=TextBox()
self.aimPoint.setText(127)
aimPointPanel.add( self.aimPoint )
aimPointPanel.setCellHorizontalAlignment( self.aimPoint, HasHorizontalAlignment.ALIGN_RIGHT )
aimPointPanel.setWidth("100%")
self.start=Button("Start")
self.echo=HTML("Initiating...")
self.mainPanel = VerticalPanel()
self.mainPanel.add( numberOfLoopsPanel )
self.mainPanel.add( aimPointPanel )
self.mainPanel.add( self.start )
self.mainPanel.add( self.echo )
def getMaxNumberOfLoops( self ) :
return int(self.maximumNumberOfLoops.getText())
def getAimPoint( self ) :
return int(self.aimPoint.getText())
def getStartButton( self ) :
return self.start
def setEchoText( self, text ) :
self.echo.setText( text )
def enable( self ) :
self.start.setEnabled(True)
def disable( self ) :
self.start.setEnabled(False)
def getPanel( self ) :
return self.mainPanel
示例4: SimpleTweetPanel
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class SimpleTweetPanel(HorizontalPanel):
def __init__(self, screennames, nUsers, topPanel):
HorizontalPanel.__init__(self)
self.screennames = screennames
self.nUsers = nUsers
self.topPanel = topPanel
self.add(HTML(_title, StyleName='result-detail'))
self.withButton = Button(_withAtText, self, StyleName='with-at-button')
self.add(self.withButton)
self.withoutButton = Button(_withoutAtText, self,
StyleName='without-at-button')
self.add(self.withoutButton)
self.link = HTML()
self.add(self.link)
def onClick(self, sender):
self.link.setText('')
if sender == self.withButton:
self.withButton.setEnabled(False)
useAts = True
else:
self.withoutButton.setEnabled(False)
useAts = False
remote = server.TickeryService()
id = remote.simpleTweet(
self.topPanel.loginPanel.oauthCookie, self.screennames,
self.nUsers, userlist._sortKey, useAts, self)
if id < 0:
self.link.setText('Oops!')
def onRemoteResponse(self, response, request_info):
self.withButton.setEnabled(True)
self.withoutButton.setEnabled(True)
if response['result']:
self.link.setHTML('<a href="%s">%s</a>' %
(response['URL'], _doneText))
else:
self.link.setText('Oops: %r' % response)
def onRemoteError(self, code, message, request_info):
self.withButton.setEnabled(True)
self.withoutButton.setEnabled(True)
self.link.setText('Server Err or Invalid Response: ERROR %d - %s' %
(code, message))
示例5: MailList
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class MailList(Composite):
VISIBLE_EMAIL_COUNT = 10
def __init__(self, mailObject):
Composite.__init__(self)
self.countLabel = HTML()
self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True)
self.olderButton = HTML("<a href='javascript:;'>older ></a>", True)
self.startIndex = 0
self.selectedRow = -1
self.table = FlexTable()
self.navBar = HorizontalPanel()
self.mailObject = mailObject
# Setup the table.
self.table.setCellSpacing(0)
self.table.setCellPadding(2)
self.table.setWidth("100%")
# Hook up events.
self.table.addTableListener(self)
self.newerButton.addClickListener(self)
self.olderButton.addClickListener(self)
# Create the 'navigation' bar at the upper-right.
innerNavBar = HorizontalPanel()
innerNavBar.setSpacing(8)
innerNavBar.add(self.newerButton)
innerNavBar.add(self.countLabel)
innerNavBar.add(self.olderButton)
self.navBar.setStyleName("mail-ListNavBar")
self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
self.navBar.add(innerNavBar)
self.navBar.setWidth("100%")
self.initWidget(self.table)
self.setStyleName("mail-List")
self.initTable()
self.update()
def onCellDoubleClicked(self, sender, row, cell):
pass
def onCellClicked(self, sender, row, cell):
# Select the row that was clicked (-1 to account for header row).
if (row > 0):
self.selectRow(row - 1)
def onClick(self, sender):
if (sender == self.olderButton):
# Move forward a page.
self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
if (self.startIndex >= MailItems().getMailItemCount()):
self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
else:
self.styleRow(self.selectedRow, False)
self.selectedRow = -1
self.update()
elif (sender == self.newerButton):
# Move back a page.
self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
if (self.startIndex < 0):
self.startIndex = 0
else:
self.styleRow(self.selectedRow, False)
self.selectedRow = -1
self.update()
def initTable(self):
# Create the header row.
self.table.setText(0, 0, "sender")
self.table.setText(0, 1, "email")
self.table.setText(0, 2, "subject")
self.table.setWidget(0, 3, self.navBar)
self.table.getRowFormatter().setStyleName(0, "mail-ListHeader")
# Initialize the rest of the rows.
i = 0
while i < MailList.VISIBLE_EMAIL_COUNT:
self.table.setText(i + 1, 0, "")
self.table.setText(i + 1, 1, "")
self.table.setText(i + 1, 2, "")
self.table.getCellFormatter().setWordWrap(i + 1, 0, False)
self.table.getCellFormatter().setWordWrap(i + 1, 1, False)
self.table.getCellFormatter().setWordWrap(i + 1, 2, False)
self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2)
i = i + 1
def selectRow(self, row):
# When a row (other than the first one, which is used as a header) is
# selected, display its associated MailItem.
item = MailItems().getMailItem(self.startIndex + row)
if item is None:
return
#.........这里部分代码省略.........
示例6: PopupPagina
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
#.........这里部分代码省略.........
lblinha2.addItem("4", value=4)
lblinha2.addItem("5", value=5)
lbcoluna1 = ListBox()
lbcoluna1.setID("cm1")
lbcoluna1.addItem("1", value=1)
lbcoluna1.addItem("2", value=2)
lbcoluna1.addItem("3", value=3)
lbcoluna1.addItem("4", value=4)
lbcoluna1.addItem("5", value=5)
lbcoluna1.addItem("6", value=6)
lbcoluna1.addItem("7", value=7)
lbcoluna2 = ListBox()
lbcoluna2.setID("cm2")
lbcoluna2.addItem("1", value=1)
lbcoluna2.addItem("2", value=2)
lbcoluna2.addItem("3", value=3)
lbcoluna2.addItem("4", value=4)
lbcoluna2.addItem("5", value=5)
lbcoluna2.addItem("6", value=6)
lbcoluna2.addItem("7", value=7)
self.lblStatus = Label("Label para Status")
# Eventos
self.imageFechar.addClickListener(self.onFecharPopup)
# Cabeçalho da poupPanel
self.grid = Grid(1, 16)
self.grid.setWidth(self.getWidth())
self.grid.setHTML(0, 0, "<b>Matriz 1:</b> Nº Linhas:")
self.grid.setWidget(0, 1, lblinha1)
self.grid.setText(0, 2, "Nº Colunas:")
self.grid.setWidget(0, 3, lbcoluna1)
self.grid.setHTML(0, 4, "<b>Matriz 2:</b> Nº Linhas:")
self.grid.setWidget(0, 5, lblinha2)
self.grid.setText(0, 6, "Nº Colunas:")
self.grid.setWidget(0, 7, lbcoluna2)
# self.grid.setWidget(0, 3, self.txtColunas)
self.grid.setWidget(0, 8, self.btnStepByStep)
self.grid.setWidget(0, 9, self.btnDesfazer)
self.grid.setWidget(0, 10, self.btnFazer)
self.grid.setHTML(0, 11, "<b>Velocidade:</b>")
self.grid.setWidget(0, 12, self.lbVelocidade)
self.grid.setWidget(0, 13, self.btnAutomatic)
# self.grid.setWidget(0, 14, self.btnInterativo)
self.grid.setWidget(0, 15, self.imageFechar)
# self.grid.setWidget(0, 7, self.btnFechar)
self.grid.getCellFormatter().setAlignment(
0, 15, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_TOP
)
self.panel = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")
self.panel.setWidget(0, 0, self.caption)
self.panel.setWidget(1, 0, self.grid)
self.panel.getCellFormatter().setHeight(2, 0, "100%")
self.panel.getCellFormatter().setWidth(2, 0, "100%")
self.panel.getCellFormatter().setAlignment(
2, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP
)
self.panel.setID("contetepopup")
painelhorizontal = HorizontalPanel()
gridinterativa = FlexTable()
示例7: DialogBoxModal
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class DialogBoxModal(PopupPanel):
def __init__(self, identifier, autoHide=None, modal=False, rootpanel=None):
PopupPanel.__init__(self, autoHide, modal, rootpanel)
self.identifier = identifier
self.caption = HTML()
self.child = None
self.showing = False
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.panel = FlexTable()
self.closeButton = Image('cancel.png')
self.closeButton.addClickListener(self)
dock = DockPanel()
dock.setSpacing(0)
dock.add(self.closeButton, DockPanel.EAST)
dock.add(self.caption, DockPanel.WEST)
dock.setCellHorizontalAlignment(self.closeButton,
HasAlignment.ALIGN_RIGHT)
dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
dock.setCellWidth(self.caption, '100%')
dock.setWidth('100%')
self.panel.setWidget(0, 0, dock)
self.panel.setHeight('100%')
self.panel.setBorderWidth(0)
self.panel.setCellPadding(0)
self.panel.setCellSpacing(0)
self.panel.getCellFormatter().setHeight(1, 0, '100%')
self.panel.getCellFormatter().setWidth(1, 0, '100%')
#self.panel.getCellFormatter().setAlignment(1, 0,
# HasHorizontalAlignment.ALIGN_CENTER,
# HasVerticalAlignment.ALIGN_MIDDLE)
PopupPanel.setWidget(self, self.panel)
self.setStyleName('gwt-DialogBox')
self.caption.setStyleName('Caption')
self.closeButton.setStyleName('Close')
dock.setStyleName('Header')
self.caption.addMouseListener(self)
def getHTML(self):
return self.caption.getHTML()
def getText(self):
return self.caption.getText()
def onMouseDown(self, sender, x, y):
self.dragging = True
DOM.setCapture(self.caption.getElement())
self.dragStartX = x
self.dragStartY = y
def onMouseEnter(self, sender):
pass
def onMouseLeave(self, sender):
pass
def onMouseMove(self, sender, x, y):
if self.dragging:
absX = x + self.getAbsoluteLeft()
absY = y + self.getAbsoluteTop()
self.setPopupPosition(absX - self.dragStartX,
absY - self.dragStartY)
def onMouseUp(self, sender, x, y):
self.dragging = False
DOM.releaseCapture(self.caption.getElement())
def remove(self, widget):
if self.child != widget:
return False
self.panel.remove(widget)
self.child = None
return True
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def doAttachChildren(self):
PopupPanel.doAttachChildren(self)
self.caption.onAttach()
def doDetachChildren(self):
PopupPanel.doDetachChildren(self)
self.caption.onDetach()
def setWidget(self, widget):
if self.child is not None:
self.panel.remove(self.child)
#.........这里部分代码省略.........
示例8: Grimes
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class OccupancyCheckView :
"""
A class that takes of the purely UI part of the OccupanceCheckPanel.
@author Mark Grimes ([email protected])
@date 08/Feb/2014
"""
def __init__( self ) :
self.mainPanel = VerticalPanel()
self.echo = HTML('Initiating')
self.launchButton=Button("Update")
controlPanel=HorizontalPanel()
controlPanel.add(self.launchButton)
controlPanel.add(self.echo)
self.mainPanel.add(controlPanel)
self.resultGrids={}
self.resultLabels={}
def createResultGrid( self, gridName ) :
label=HTML('<br><b>'+gridName+'</b>')
grid=Grid(17,17)
# Create the column and row headers
for index in range( 1, grid.getColumnCount() ) :
grid.setWidget( 0, index, HTML('Cx%X'%(index-1)) )
for index in range( 1, grid.getRowCount() ) :
grid.setWidget( index, 0, HTML('C%Xx'%(index-1)) )
self.mainPanel.add(label)
self.mainPanel.add(grid)
self.resultLabels[gridName]=label
self.resultGrids[gridName]=grid
def getPanel( self ) :
return self.mainPanel
def getUpdateButton( self ) :
return self.launchButton
def enable( self ) :
self.launchButton.setEnabled(True)
def disable( self ) :
self.launchButton.setEnabled(False)
def clearResults( self ) :
for name in self.resultGrids.keys() :
grid=self.resultGrids[name]
# Loop over all the data cells and set them empty
for column in range( 1, grid.getColumnCount() ) :
for row in range( 1, grid.getRowCount() ) :
grid.setWidget( row, column, HTML('') )
def addResult( self, cbcName, occupancies ) :
"""
Display the occupancies for a CBC.
cbcName - string describing naming which CBC it is
occupancies - an array of length 254 where each entry is the occupancy for that channel
"""
if occupancies==None : return self.addError( cbcName )
try :
grid=self.resultGrids[cbcName]
except NameError :
self.createResultGrid( cbcName )
grid=self.resultGrids[cbcName]
# Might need to reset the label if the was an error earlier
label=self.resultLabels[cbcName]
label.setHTML( '<br><b>'+cbcName+'</b>' )
row=1
column=1
for index in range(0,len(occupancies)) :
# Work out RGB components so that it is completely red when occupancy is zero, and green when one
red=255.0*(1.0-occupancies[index])
green=255.0*occupancies[index]
blue=0
grid.setWidget( row, column, HTML('<div style="background-color:#%02X%02X%02X'%(red,green,blue)+'">%1.2f'%occupancies[index]+'</div>') )
column+=1
if column%17 == 0 :
column=1
row+=1
def addError( self, cbcName ) :
"""
Displays something to indicate that there was an error for the given CBC
"""
try :
label=self.resultLabels[cbcName]
except NameError :
self.createResultGrid( cbcName )
label=self.resultLabels[cbcName]
label.setHTML( '<br>Unable to get the results for <b>'+cbcName+'</b>' )
def setEchoMessage( self, message ) :
self.echo.setText( message )
示例9: Text
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class Text(Sink):
def __init__(self):
Sink.__init__(self)
self.fPasswordText = PasswordTextBox()
self.fTextArea = TextArea()
self.fTextBox = TextBox()
panel = VerticalPanel()
panel.setSpacing(8)
panel.add(HTML("Normal text box:"))
panel.add(self.createTextThing(self.fTextBox))
panel.add(HTML("Password text box:"))
panel.add(self.createTextThing(self.fPasswordText))
panel.add(HTML("Text area:"))
panel.add(self.createTextThing(self.fTextArea))
panel.add(HTML("""Textarea below demos oninput event. oninput allows
to detect when the content of an element has changed. This is different
from examples above, where changes are detected only if they are made with
keyboard. oninput occurs when the content is changed through any user
interface(keyboard, mouse, etc.). For example, at first type few chars, but
then paste some text to the text areas above and below by selecting 'Paste'
command from context menu or by dragging&dropping and see the difference.
oninput is similar to onchange event, but onchange event fires only when a
text-entry widget loses focus."""))
vp = VerticalPanel()
self.echo = HTML()
textArea = TextArea()
vp.add(textArea)
vp.add(self.echo)
textArea.addInputListener(self)
panel.add(vp)
self.initWidget(panel)
def onShow(self):
pass
def onInput(self, sender):
self.echo.setText(sender.getText())
def createTextThing(self, textBox):
p = HorizontalPanel()
p.setSpacing(4)
p.add(textBox)
echo = HTML()
select_all = Button("select all")
p.add(select_all)
p.add(echo)
listener=TextBoxListener(self, textBox, echo, select_all)
select_all.addClickListener(listener)
textBox.addKeyboardListener(listener)
textBox.addClickListener(listener)
return p
def updateText(self, text, echo):
echo.setHTML("Text: " + text.getText() + "<br>" + "Selection: %d" % text.getCursorPos() + ", %d" % text.getSelectionLength())
示例10: onModuleLoad
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class Client:
def onModuleLoad(self):
# Window.setTitle("CBC Test Stand")
StyleSheetCssFile("styleSheet.css")
self.TEXT_WAITING = "Waiting for response..."
self.TEXT_ERROR = "Server Error"
self.status = Label()
# This is the remote service
self.I2CPanel = I2CPanel()
self.SCurveRunPanel = SCurveRunPanel()
self.OccupancyCheckPanel = OccupancyCheckPanel()
self.CalibrateChannelTrimsPanel = CalibrateChannelTrimsPanel()
# mainPanel will have all of the working stuff in it
self.mainPanel = DockPanel()
# self.mainPanel.setSpacing(10)
titleBar = HorizontalPanel()
titleBar.add(HTML(r"CBC Test Stand (v1.1)", StyleName="titleStyle"))
self.stopTakingDataButton = Button("Stop taking data")
self.stopTakingDataButton.addClickListener(self)
self.dataTakingPercentage = HTML("0%")
self.dataTakingStatus = HTML("Initiating...")
titleBar.add(self.dataTakingPercentage)
titleBar.add(self.dataTakingStatus)
titleBar.add(self.stopTakingDataButton)
titleBar.setCellHorizontalAlignment(self.dataTakingStatus, HasHorizontalAlignment.ALIGN_RIGHT)
titleBar.setCellHorizontalAlignment(self.dataTakingPercentage, HasHorizontalAlignment.ALIGN_RIGHT)
titleBar.setCellHorizontalAlignment(self.stopTakingDataButton, HasHorizontalAlignment.ALIGN_RIGHT)
titleBar.setWidth("100%")
self.mainPanel.add(titleBar, DockPanel.NORTH)
selectionPanel = VerticalPanel()
# Register to get updates about the status of data taking, so that
# I can update the information in the title bar
self.dataRunManager = DataRunManager.instance()
self.dataRunManager.registerEventHandler(self)
self.activePanelButton = None
self.activePanel = None
self.registersButton = Label("I2C Registers", StyleName="areaStyle")
self.occupanciesButton = Label("Test Occupancies", StyleName="areaStyle")
self.scurveButton = Label("S-Curve Run", StyleName="areaStyle")
self.calibrateTrimsButton = Label("Calibrate Trims", StyleName="areaStyle")
self.registersButton.addClickListener(self)
self.occupanciesButton.addClickListener(self)
self.scurveButton.addClickListener(self)
self.calibrateTrimsButton.addClickListener(self)
selectionPanel.add(self.registersButton)
selectionPanel.add(self.occupanciesButton)
selectionPanel.add(self.scurveButton)
selectionPanel.add(self.calibrateTrimsButton)
self.mainPanel.add(selectionPanel, DockPanel.WEST)
self.mainPanel.add(self.status, DockPanel.SOUTH)
RootPanel().add(self.mainPanel)
self.setNewMainPanel(self.registersButton)
def onDataTakingEvent(self, eventCode, details):
"""
Method that receives updates from DataRunManager
"""
if eventCode == DataRunManager.DataTakingStartedEvent:
self.stopTakingDataButton.setEnabled(True)
self.dataTakingPercentage.setText("0%")
self.dataTakingStatus.setText("Starting run...")
elif eventCode == DataRunManager.DataTakingFinishedEvent:
self.stopTakingDataButton.setEnabled(False)
self.dataTakingPercentage.setText("")
self.dataTakingStatus.setText("Not taking data")
elif eventCode == DataRunManager.DataTakingStatusEvent:
self.stopTakingDataButton.setEnabled(True)
self.dataTakingPercentage.setText("%3d%%" % int(details["fractionComplete"] * 100 + 0.5))
self.dataTakingStatus.setText(details["statusString"])
def onClick(self, sender):
# (data, response_class): if the latter is 'self', then
# the response is handled by the self.onRemoteResponse() method
try:
if sender == self.stopTakingDataButton:
self.dataRunManager.stopTakingData()
else:
# I don't have any other buttons so it must be a panel change
self.setNewMainPanel(sender)
except Exception as error:
self.status.setText("Client exception was thrown: '" + str(error.__class__) + "'='" + str(error) + "'")
def setNewMainPanel(self, panelButton):
if panelButton == self.activePanelButton:
return # already the active panel so no need to do anything
# Remove the "selected" style from the current button
#.........这里部分代码省略.........
示例11: DialogBox
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class DialogBox(PopupPanel):
_props = [
("caption", "Caption", "HTML", None),
]
def __init__(self, autoHide=None, modal=True, **kwargs):
# Init section
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.child = None
self.panel = FlexTable(
Height="100%",
BorderWidth="0",
CellPadding="0",
CellSpacing="0",
)
cf = self.panel.getCellFormatter()
cf.setHeight(1, 0, "100%")
cf.setWidth(1, 0, "100%")
cf.setAlignment(
1, 0,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE,
)
# Arguments section
self.modal = modal
self.caption = HTML()
self.panel.setWidget(0, 0, self.caption)
self.caption.setStyleName("Caption")
self.caption.addMouseListener(self)
# Finalize
kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
PopupPanel.__init__(self, autoHide, modal, **kwargs)
PopupPanel.setWidget(self, self.panel)
@classmethod
def _getProps(self):
return PopupPanel._getProps() + self._props
def onEventPreview(self, event):
# preventDefault on mousedown events, outside of the
# dialog, to stop text-selection on dragging
type = DOM.eventGetType(event)
if type == 'mousedown':
target = DOM.eventGetTarget(event)
elem = self.caption.getElement()
event_targets_popup = target and DOM.isOrHasChild(elem, target)
if event_targets_popup:
DOM.eventPreventDefault(event)
return PopupPanel.onEventPreview(self, event)
def getHTML(self):
return self.caption.getHTML()
def getText(self):
return self.caption.getText()
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def onMouseDown(self, sender, x, y):
self.dragging = True
GlassWidget.show(self.caption)
self.dragStartX = x
self.dragStartY = y
def onMouseEnter(self, sender):
pass
def onMouseLeave(self, sender):
pass
def onMouseMove(self, sender, x, y):
if not self.dragging:
return
absX = x + self.getAbsoluteLeft()
absY = y + self.getAbsoluteTop()
self.setPopupPosition(absX - self.dragStartX,
absY - self.dragStartY)
def onMouseUp(self, sender, x, y):
self.endDragging()
def onMouseGlassEnter(self, sender):
pass
def onMouseGlassLeave(self, sender):
self.endDragging()
def endDragging(self):
if not self.dragging:
return
self.dragging = False
GlassWidget.hide()
#.........这里部分代码省略.........
示例12: CollapserPanel
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class CollapserPanel(SimplePanel):
def __init__(self, sink):
SimplePanel.__init__(self)
self.sink = sink
self.caption = HTML()
self.child = None
self.showing = False
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.panel = FlexTable()
self.collapse = Image("./images/cancel.png")
self.collapse.addClickListener(self)
dock = DockPanel()
dock.setSpacing(0)
dock.add(self.collapse, DockPanel.EAST)
dock.add(self.caption, DockPanel.WEST)
dock.setCellHorizontalAlignment(self.collapse, HasAlignment.ALIGN_RIGHT)
dock.setCellVerticalAlignment(self.collapse, HasAlignment.ALIGN_TOP)
dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
dock.setCellWidth(self.caption, "100%")
dock.setWidth("100%")
dock.setHeight("100%")
self.panel.setWidget(0, 0, dock)
self.panel.setHeight("100%")
self.panel.setWidth("100%")
self.panel.setBorderWidth(0)
self.panel.setCellPadding(0)
self.panel.setCellSpacing(0)
self.panel.getCellFormatter().setHeight(1, 0, "100%")
self.panel.getCellFormatter().setWidth(1, 0, "100%")
self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP)
SimplePanel.setWidget(self, self.panel)
self.setStyleName("gwt-DialogBox")
self.caption.setStyleName("Caption")
self.collapse.setStyleName("Close")
dock.setStyleName("Header")
#self.caption.addMouseListener(self)
self.collapsed = False
self.collapsed_width = "15px"
self.uncollapsed_width = "100%"
def setInitialWidth(self, width):
self.uncollapsed_width = width
SimplePanel.setWidth(self, width)
self.sink.setCollapserWidth(self, width)
def setHeight(self, height):
SimplePanel.setHeight(self, height)
def onClick(self, sender):
if self.collapsed == False:
self.collapse.setUrl("./tree_closed.gif")
self.collapsed = True
self.caption.setVisible(False)
if self.child:
self.child.setVisible(False)
self.setWidth(self.collapsed_width)
self.sink.setCollapserWidth(self, self.collapsed_width)
else:
self.collapse.setUrl("./images/cancel.png")
self.collapsed = False
self.caption.setVisible(True)
if self.child:
self.child.setVisible(True)
self.setWidth(self.uncollapsed_width)
self.sink.setCollapserWidth(self, self.uncollapsed_width)
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def remove(self, widget):
if self.child != widget:
return False
self.panel.remove(widget)
return True
def doAttachChildren(self):
SimplePanel.doAttachChildren(self)
self.caption.onAttach()
def doDetachChildren(self):
SimplePanel.doDetachChildren(self)
self.caption.onDetach()
def setWidget(self, widget):
if self.child is not None:
self.panel.remove(self.child)
if widget is not None:
#.........这里部分代码省略.........
示例13: WebPageEdit
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
class WebPageEdit(Composite):
def __init__(self, sink):
Composite.__init__(self)
self.remote = sink.remote
panel = VerticalPanel(Width="100%", Spacing=8)
self.view = Button("View", self)
self.newpage = Button("New", self)
self.todoId = None
self.todoTextName = TextBox()
self.todoTextName.addKeyboardListener(self)
self.todoTextArea = RichTextEditor(basePath="/fckeditor/")
self.todoTextArea.setWidth("100%")
self.todoTextArea.addSaveListener(self)
self.todoList = ListBox()
self.todoList.setVisibleItemCount(7)
self.todoList.setWidth("200px")
self.todoList.addClickListener(self)
self.fDialogButton = Button("Upload Files", self)
self.status = HTML()
panel.add(HTML("Status:"))
panel.add(self.status)
panel.add(self.fDialogButton)
panel.add(Label("Create New Page (doesn't save current one!):"))
panel.add(self.newpage)
panel.add(Label("Add/Edit New Page:"))
panel.add(self.todoTextName)
panel.add(Label("Click to Load and Edit (doesn't save current one!):"))
panel.add(self.todoList)
panel.add(self.view)
panel.add(Label("New Page HTML. Click 'save' icon to save. (pagename is editable as well)"))
panel.add(self.todoTextArea)
self.setWidget(panel)
self.remote.getPages(self)
def onKeyUp(self, sender, keyCode, modifiers):
pass
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
"""
This functon handles the onKeyPress event, and will add the item in the text box to the list when the user presses the enter key. In the future, this method will also handle the auto complete feature.
"""
pass
def onSave(self, editor):
self.status.setText("")
name = self.todoTextName.getText()
if not name:
self.status.setText("Please enter a name for the page")
return
item = {"name": name, "text": self.todoTextArea.getHTML()}
if self.todoId is None:
rid = self.remote.addPage(item, self)
else:
item["id"] = self.todoId
rid = self.remote.updatePage(item, self)
if rid < 0:
self.status.setHTML("Server Error or Invalid Response")
return
def onClick(self, sender):
if sender == self.newpage:
self.todoId = None
self.todoTextName.setText("")
self.todoTextArea.setHTML("")
return
elif sender == self.view:
name = self.todoTextName.getText()
html = self.todoTextArea.getHTML()
if not html:
return
p = HTMLDialog(name, html)
p.setPopupPosition(10, 10)
p.setWidth(Window.getClientWidth() - 40)
p.setHeight(Window.getClientHeight() - 40)
p.show()
return
elif sender == self.fDialogButton:
Window.open(fileedit_url, "fileupload", "width=800,height=600")
return
dlg = FileDialog(fileedit_url)
left = self.fDialogButton.getAbsoluteLeft() + 10
top = self.fDialogButton.getAbsoluteTop() + 10
dlg.setPopupPosition(left, top)
dlg.show()
id = self.remote.getPage(sender.getValue(sender.getSelectedIndex()), self)
#.........这里部分代码省略.........
示例14: DialogBox
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import setText [as 别名]
#.........这里部分代码省略.........
if self.centered:
self.centerBox()
def show(self):
super(DialogBox, self).show()
if self.centered:
self.centerBox()
@classmethod
def _getProps(self):
return PopupPanel._getProps() + self._props
def onEventPreview(self, event):
# preventDefault on mousedown events, outside of the
# dialog, to stop text-selection on dragging
type = DOM.eventGetType(event)
if type == 'mousedown':
target = DOM.eventGetTarget(event)
elem = self.caption.getElement()
event_targets_popup = target and DOM.isOrHasChild(elem, target)
if event_targets_popup:
DOM.eventPreventDefault(event)
return PopupPanel.onEventPreview(self, event)
def getHTML(self):
return self.caption.getHTML()
def getText(self):
return self.caption.getText()
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def onMouseDown(self, sender, x, y):
self.dragging = True
GlassWidget.show(self.caption)
self.dragStartX = x
self.dragStartY = y
def onMouseEnter(self, sender):
pass
def onMouseLeave(self, sender):
pass
def onMouseMove(self, sender, x, y):
if not self.dragging:
return
absX = x + self.getAbsoluteLeft()
absY = y + self.getAbsoluteTop()
self.setPopupPosition(absX - self.dragStartX,
absY - self.dragStartY)
def onMouseUp(self, sender, x, y):
self.endDragging()
def onMouseGlassEnter(self, sender):
pass
def onMouseGlassLeave(self, sender):
self.endDragging()
def endDragging(self):