本文整理汇总了Python中pyjamas.ui.FlexTable.FlexTable.getCellFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python FlexTable.getCellFormatter方法的具体用法?Python FlexTable.getCellFormatter怎么用?Python FlexTable.getCellFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.FlexTable.FlexTable
的用法示例。
在下文中一共展示了FlexTable.getCellFormatter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
def __init__(self):
Sink.__init__(self)
inner = Grid(10, 5, Width="100%", BorderWidth="1")
outer = FlexTable(Width="100%", BorderWidth="1")
outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
outer.getFlexCellFormatter().setColSpan(0, 0, 2)
outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)
outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
outer.setWidget(1, 1, inner)
outer.getCellFormatter().setColSpan(1, 1, 2)
for i in range(10):
for j in range(5):
inner.setText(i, j, "%d" % i + ",%d" % j)
self.initWidget(outer)
示例2: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
#.........这里部分代码省略.........
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()
painelhorizontal.add(
HTML(
"<canvas id='%s' datasrc='%s' width='%s' height='%s' style='image-rendering: optimizespeed !important; '></canvas>"
% ("soma", datasource, "1000px", "500px")
)
)
ftInterativo = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")
gridinterativa = Grid(4, 4)
gridinterativa.setWidget(
0,
0,
HTML(
"<b>M1(</b><input type='text' class='gwt-TextBox' id='linha1' style='width: 25px; height:20px;' maxLength='1'><b> , </b>"
示例3: MailList
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [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
#.........这里部分代码省略.........
示例4: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
class StockWatcher:
def onModuleLoad(self):
'''
This is the main entry point method.
'''
# Setup JSON RPC
self.remote = DataService()
# Initialize member variables
self.mainPanel = VerticalPanel()
self.stocksFlexTable = FlexTable()
self.addPanel = HorizontalPanel()
self.newSymbolTextBox = TextBox()
self.lastUpdatedLabel = Label()
self.addStockButton = Button('Add', self.addStock)
self.stocks = []
self.stocksTableColumns = ['Symbol', 'Price', 'Change', 'Remove']
# Add styles to elements in the stock list table
self.stocksFlexTable.getRowFormatter().addStyleName(0, 'watchListHeader')
self.stocksFlexTable.addStyleName('watchList')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 1, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 2, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 3, 'watchListRemoveColumn')
# Create table for stock data
for i in range(len(self.stocksTableColumns)):
self.stocksFlexTable.setText(0, i, self.stocksTableColumns[i])
# Assemble Add Stock panel
self.addPanel.add(self.newSymbolTextBox)
self.addPanel.add(self.addStockButton)
self.addPanel.addStyleName('addPanel')
# Assemble Main panel
self.mainPanel.add(self.stocksFlexTable)
self.mainPanel.add(self.addPanel)
self.mainPanel.add(self.lastUpdatedLabel)
# Associate the Main panel with the HTML host page
RootPanel().add(self.mainPanel)
# Move cursor focus to the input box
self.newSymbolTextBox.setFocus(True)
# Setup timer to refresh list automatically
refresh = self.refreshWatchlist
class MyTimer(Timer):
def run(self):
refresh()
refreshTimer = MyTimer()
refreshTimer.scheduleRepeating(5000)
# Listen for keyboard events in the input box
self_addStock = self.addStock
class StockTextBox_KeyboardHandler():
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KEY_ENTER:
self_addStock()
def onKeyDown(self, sender, keycode, modifiers): return
def onKeyUp(self, sender, keycode, modifiers): return
self.newSymbolTextBox.addKeyboardListener(StockTextBox_KeyboardHandler())
# Load the stocks
self.remote.getStocks(self)
def addStock(self, sender, symbol=None):
'''
Add stock to FlexTable. Executed when the user clicks the addStockButton
or presses enter in the newSymbolTextBox
'''
if symbol is None:
# Get the symbol
symbol = self.newSymbolTextBox.getText().upper().trim()
self.newSymbolTextBox.setText('')
# Don't add the stock if it's already in the table
if symbol in self.stocks:
return
# Tell the server that we're adding this stock
self.remote.addStock(symbol, self)
self.newSymbolTextBox.setFocus(True)
# Stocks code must be between 1 and 10 chars that are numbers/letters/dots
p = re.compile('^[0-9A-Z\\.]{1,10}$')
if p.match(symbol) == None:
Window.alert('"%s" is not a valid symbol.' % symbol)
self.newSymbolTextBox.selectAll()
return
# Add the stock to the table
row = self.stocksFlexTable.getRowCount()
self.stocks.append(symbol)
self.stocksFlexTable.setText(row, 0, symbol)
self.stocksFlexTable.setWidget(row, 2, Label())
self.stocksFlexTable.getCellFormatter().addStyleName(row, 1, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(row, 2, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(row, 3, 'watchListRemoveColumn')
# Add a button to remove this stock from the table
#.........这里部分代码省略.........
示例5: PopupPagina
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
#.........这里部分代码省略.........
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()
painelhorizontal.add(
HTML(
"<canvas id='%s' datasrc='%s' width='%s' height='%s' style='image-rendering: optimizespeed !important; '></canvas>"
% ("soma", datasource, "1000px", "500px")
)
)
ftInterativo = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")
gridinterativa = Grid(4, 4)
gridinterativa.setWidget(
0,
0,
HTML(
"<b>M1(</b><input type='text' class='gwt-TextBox' id='linha1' style='width: 25px; height:20px;' maxLength='1'><b> , </b>"
示例6: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
class MovieRatings:
def onModuleLoad(self):
# Setup JSON RPC
self.remote = DataService()
### Initialize member variables
self.mainPanel = HorizontalPanel()
self.rightPanel = VerticalPanel()
self.moviesPanel = VerticalPanel()
self.topRatedPanel = VerticalPanel()
self.categoriesPanel = VerticalPanel()
self.moviesFlexTable = FlexTable()
self.topRatedMoviesFlexTable = FlexTable()
self.topCategoryMoviesFlexTable = FlexTable()
self.lessThanFiveLabel = Label('There are less than 5 movies. Add more movies!')
self.moviesListLabel = Label('Movies List')
self.addPanel = VerticalPanel()
self.newMovieCategoryTextBox = TextBox()
self.newMovieNameTextBox = TextBox()
self.newMovieRatingListBox = ListBox(False)
self.addMovieButton = Button('Add', self.addMovieButton_Click)
self.movies = []
self.topRatedMovies = []
self.categories = {}
self.MAX_RATING = 10
### Add Movie Panel
# Add ratings to list box
for i in range(self.MAX_RATING + 1):
self.newMovieRatingListBox.addItem(str(i))
# Add label and textbox to horizontal panel
self.labelPanel = HorizontalPanel()
self.labelPanel.add(Label("Add a movie:"))
self.categoryPanel = HorizontalPanel()
self.categoryPanel.add(Label("Category: "))
self.categoryPanel.add(self.newMovieCategoryTextBox)
self.namePanel = HorizontalPanel()
self.namePanel.add(Label("Movie Name: "))
self.namePanel.add(self.newMovieNameTextBox)
self.ratingPanel = HorizontalPanel()
self.ratingPanel.add(Label("Movie Rating: "))
self.ratingPanel.add(self.newMovieRatingListBox)
self.labelPanel.addStyleName("addLabel")
self.labelPanel.setSpacing(5)
self.categoryPanel.addStyleName("addPanel")
self.categoryPanel.setSpacing(5)
self.namePanel.addStyleName("addPanel")
self.namePanel.setSpacing(5)
self.ratingPanel.addStyleName("addPanel")
self.ratingPanel.setSpacing(5)
self.newMovieCategoryTextBox.addStyleName("addPanel-input")
self.newMovieNameTextBox.addStyleName("addPanel-input")
self.newMovieRatingListBox.addStyleName("addPanel-input")
self.addPanel.add(self.labelPanel)
self.addPanel.add(self.categoryPanel)
self.addPanel.add(self.namePanel)
self.addPanel.add(self.ratingPanel)
self.addPanel.add(self.addMovieButton)
self.addPanel.addStyleName("addPanel")
self.addMovieButton.addStyleName('addButton')
self.addPanel.add(self.addMovieButton)
self.addPanel.addStyleName('addPanel')
### Movies table
self.moviesFlexTable.setText(0, 1, "Category")
self.moviesFlexTable.setText(0, 2, "Title")
self.moviesFlexTable.setText(0, 3, "Rating")
self.moviesFlexTable.addStyleName("movieList")
self.moviesFlexTable.getRowFormatter().addStyleName(0, "listHeader")
self.moviesFlexTable.setCellPadding(6)
self.moviesFlexTable.getCellFormatter().setStyleName(0, 1, "listHeaderColumn")
self.moviesFlexTable.getCellFormatter().setStyleName(0, 2, "listHeaderColumn")
self.moviesListLabel.addStyleName("listLabel")
self.moviesPanel.add(self.moviesListLabel)
self.moviesPanel.add(self.moviesFlexTable)
self.moviesPanel.setStyleName("moviesPanel")
### Top rated movies table
self.topRatedMoviesFlexTable.setText(0, 0, "Category")
self.topRatedMoviesFlexTable.setText(0, 1, "Title")
self.topRatedMoviesFlexTable.setText(0, 2, "Rating")
self.topRatedMoviesFlexTable.addStyleName("topMoviesList")
self.topRatedMoviesFlexTable.getRowFormatter().addStyleName(0, "listHeader")
self.topRatedMoviesFlexTable.setCellPadding(6)
self.topRatedMoviesFlexTable.getCellFormatter().setStyleName(0, 0, "listHeaderColumn")
self.topRatedMoviesFlexTable.getCellFormatter().setStyleName(0, 1, "listHeaderColumn")
self.topRatedLabel = Label("Top 5 Rated Movies")
#.........这里部分代码省略.........
示例7: DialogBoxModal
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [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: DialogBox
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [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()
#.........这里部分代码省略.........
示例9: CollapserPanel
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [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:
#.........这里部分代码省略.........
示例10: RightGrid
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
class RightGrid(DockPanel):
def __init__(self, title):
DockPanel.__init__(self)
self.grid = FlexTable()
title = HTML(title)
self.add(title, DockPanel.NORTH)
self.setCellHorizontalAlignment(title,
HasHorizontalAlignment.ALIGN_LEFT)
self.add(self.grid, DockPanel.CENTER)
self.grid.setBorderWidth("0px")
self.grid.setCellSpacing("0px")
self.grid.setCellPadding("4px")
self.formatCell(0, 0)
self.grid.setHTML(0, 0, " ")
def clear_items(self):
self.index = 0
self.items = {}
def set_items(self, items):
self.items = items
self.index = 0
self.max_rows = 0
self.max_cols = 0
Timer(1, self)
def onTimer(self, t):
count = 0
while count < 10 and self.index < len(self.items):
self._add_items(self.index)
self.index += 1
count += 1
if self.index < len(self.items):
Timer(1, self)
def _add_items(self, i):
item = self.items[i]
command = item[0]
col = item[1]
row = item[2]
data = item[3]
format_row = -1
format_col = -1
if col+1 > self.max_cols:
format_col = self.max_cols
#self.grid.resizeColumns(col+1)
self.max_cols = col+1
if row+1 >= self.max_rows:
format_row = self.max_rows
#self.grid.resizeRows(row+1)
self.max_rows = row+1
if format_row >= 0:
for k in range(format_row, self.max_rows):
self.formatCell(k, 0)
self.formatCell(row, col)
cf = self.grid.getCellFormatter()
if command == 'data':
self.grid.setHTML(row, col, data)
elif command == 'cellstyle':
data = space_split(data)
attr = data[0]
val = data[1]
cf.setStyleAttr(row, col, attr, val)
elif command == 'align':
data = space_split(data)
vert = data[0]
horiz = data[1]
if vert != '-':
cf.setVerticalAlignment(row, col, vert)
if horiz != '-':
cf.setHorizontalAlignment(row, col, horiz)
elif command == 'cellspan':
data = space_split(data)
rowspan = data[0]
colspan = data[1]
if colspan != '-':
cf.setColSpan(row, col, colspan)
if rowspan != '-':
cf.setRowSpan(row, col, rowspan)
def formatCell(self, row, col):
self.grid.prepareCell(row, col)
if col == 0 and row != 0:
self.grid.setHTML(row, col, "%d" % row)
if row != 0 and col != 0:
#self.grid.setHTML(row, col, " ")
fmt = "rightpanel-cellformat"
if col == 0 and row == 0:
fmt = "rightpanel-cellcornerformat"
elif row == 0:
fmt = "rightpanel-celltitleformat"
#.........这里部分代码省略.........
示例11: DialogBox
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [as 别名]
class DialogBox(PopupPanel):
_props = [
("caption", "Caption", "HTML", None),
]
def __init__(self, autoHide=None, modal=True, centered=False,
**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()
rf = self.panel.getRowFormatter()
# Arguments section
self.modal = modal
self.caption = HTML()
self.caption.setStyleName("Caption")
self.caption.addMouseListener(self)
# Make the DialogBox a 3x3 table, like GWT does, with
# empty elements with specific style names. These can be
# used with CSS to, for example, create border around the
# dialog box.
self.generate_gwt15 = kwargs.pop('gwt15', False) and True
if not self.generate_gwt15:
cf.setHeight(1, 0, "100%")
cf.setWidth(1, 0, "100%")
cf.setAlignment(
1, 0,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE,
)
self.panel.setWidget(0, 0, self.caption)
else:
row_labels = ['Top', 'Middle', 'Bottom']
col_labels = ['Left', 'Center', 'Right']
for r in range(3):
rf.setStyleName(r, 'dialog%s' % row_labels[r])
for c in range(3):
cf.setStyleName(r, c, 'dialog%s%s' % (row_labels[r],
col_labels[c]))
sp = SimplePanel()
sp.setStyleName('dialog%s%sInner' % (row_labels[r],
col_labels[c]))
self.panel.setWidget(r, c, sp)
cf.setAlignment(
1, 1,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE,
)
self.dialog_content = SimplePanel()
self.dialog_content.setStyleName('dialogContent')
self.panel.getWidget(0, 1).add(self.caption)
self.panel.getWidget(1, 1).add(self.dialog_content)
# Finalize
kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
PopupPanel.__init__(self, autoHide, modal, **kwargs)
PopupPanel.setWidget(self, self.panel)
self.centered = centered
def onWindowResized(self, width, height):
super(DialogBox, self).onWindowResized(width, height)
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)
#.........这里部分代码省略.........
示例12: AlarmWidget
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getCellFormatter [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')
#.........这里部分代码省略.........