本文整理汇总了Python中pyjamas.ui.Grid.Grid.setWidget方法的典型用法代码示例。如果您正苦于以下问题:Python Grid.setWidget方法的具体用法?Python Grid.setWidget怎么用?Python Grid.setWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Grid.Grid
的用法示例。
在下文中一共展示了Grid.setWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_panel
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
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
示例2: TickeryTab
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
class TickeryTab(VerticalPanel):
process = None # Define in subclass.
def __init__(self, topPanel, **kwargs):
VerticalPanel.__init__(self,
HorizontalAlignment=HasAlignment.ALIGN_LEFT,
StyleName='tickery-tab',
**kwargs)
self.topPanel = topPanel # don't add this yet!
self.topGrid = Grid(1, 2, StyleName='tickery-tab-top-grid',
HorizontalAlignment=HasAlignment.ALIGN_LEFT)
self.add(self.topGrid)
self.autoActivate = False
def addTopPanel(self):
parent = self.topPanel.getParent()
if parent:
parent.remove(self.topPanel)
self.topGrid.setWidget(0, 0, self.topPanel)
formatter = self.topGrid.getCellFormatter()
formatter.setAlignment(0, 0, 'left', 'top')
formatter.setAlignment(0, 1, 'left', 'top')
formatter.setWidth(0, 1, '100%')
def onTimer(self, timerid):
self.setInputFocus()
if self.autoActivate:
self.autoActivate = False
self.process()
示例3: GridWidget
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
class GridWidget(AbsolutePanel):
def __init__(self):
AbsolutePanel.__init__(self)
self.page=0
self.min_page=1
self.max_page=10
self.addb=Button("Next >", self)
self.subb=Button("< Prev", self)
self.clearb=Button("Clear", self)
self.g=Grid()
self.g.resize(5, 5)
self.g.setWidget(0, 0, HTML("<b>Grid Test</b>"))
self.g.setBorderWidth(2)
self.g.setCellPadding(4)
self.g.setCellSpacing(1)
self.updatePageDisplay()
self.add(self.subb)
self.add(self.addb)
self.add(self.clearb)
self.add(self.g)
def onClick(self, sender):
if sender == self.clearb:
print "clear"
self.g.clear()
return
elif sender==self.addb:
self.page+=1
elif sender==self.subb:
self.page-=1
self.updatePageDisplay()
def updatePageDisplay(self):
if self.page<self.min_page: self.page=self.min_page
elif self.page>self.max_page: self.page=self.max_page
total_pages=(self.max_page-self.min_page) + 1
self.g.setHTML(0, 4, "<b>page %d of %d</b>" % (self.page, total_pages))
if self.page>=self.max_page:
self.addb.setEnabled(False)
else:
self.addb.setEnabled(True)
if self.page<=self.min_page:
self.subb.setEnabled(False)
else:
self.subb.setEnabled(True)
for y in range(1, 5):
for x in range(5):
self.g.setText(y, x, "%d (%d,%d)" % (self.page, x, y))
示例4: AccountListSink
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
class AccountListSink(VerticalPanel):
def __init__(self, hendler = None):
VerticalPanel.__init__(self,
#HorizontalAlignment=HasAlignment.ALIGN_CENTER,
#VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
Width="100%",
#Height="100%",
Spacing=5)
self.remote = DataService(['getaccounts'])
self.grid = Grid(1, 3,
BorderWidth=1,
CellPadding=4,
CellSpacing=1,
StyleName="grid")
self.grid.setText(0, 0, u"Number")
self.grid.setText(0, 1, u"Type")
self.grid.setText(0, 2, u"Balance")
formatter = self.grid.getRowFormatter()
formatter.setStyleName(0, "grid-header")
self.add(Label(u"Accounts"))
self.add(self.grid)
def updateGrid(self, accounts):
rows = len(accounts)
if rows > 0:
self.grid.resize(rows+1, 3)
for row in range(rows):
link = PseudoLink(accounts[row]['number'],
self.onClick,
ID=accounts[row]['number'])
self.grid.setWidget(row+1, 0, link)
self.grid.setText(row+1, 1, accounts[row]['type'])
self.grid.setText(row+1, 2, accounts[row]['balance'])
def onShow(self):
self.remote.getaccounts(self)
def onClick(self, sender):
Window.alert(sender.getID())
def onRemoteResponse(self, response, request_info):
'''
Called when a response is received from a RPC.
'''
if request_info.method == 'getaccounts':
#TODO
self.updateGrid(response)
else:
Window.alert('Unrecognized JSONRPC method.')
def onRemoteError(self, code, message, request_info):
Window.alert(message)
示例5: start_game
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def start_game(self):
dim = self.level
grid = Grid(dim,dim)
grid.setStyleName("grid")
for i in range(dim):
for j in range(dim):
gc = GridCell(i,j)
grid.setWidget(i,j,gc)
self.add(grid)
示例6: RightPanel
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
class RightPanel(DockPanel):
def __init__(self):
DockPanel.__init__(self)
self.grids = {}
self.g = Grid()
self.g.setCellSpacing("0px")
self.g.setCellPadding("8px")
self.title = HTML(" ")
self.title.setStyleName("rightpanel-title")
self.add(self.title, DockPanel.NORTH)
self.setCellWidth(self.title, "100%")
self.setCellHorizontalAlignment(self.title,
HasHorizontalAlignment.ALIGN_LEFT)
self.add(self.g, DockPanel.CENTER)
def setTitle(self, title):
self.title.setHTML(title)
def clear_items(self):
for i in range(len(self.grids)):
g = self.grids[i]
if hasattr(g, "clear_items"):
g.clear_items()
self.grids = {}
self.g.resize(0, 0)
def setup_panels(self, datasets):
self.grids = {}
self.data = {}
self.names = {}
self.loaded = {}
size = len(datasets)
self.g.resize(size, 1)
#for i in range(size):
# item = datasets[i]
# fname = item[0]
# self.grids[i] = RightGrid(fname)
# self.g.setWidget(i, 0, self.grids[i])
def add_html(self, html, name, index):
self.data[index] = html
self.names[index] = name
self.grids[index] = HTML(html)
self.g.setWidget(index, 0, self.grids[index])
def add_items(self, items, name, index):
self.data[index] = items
self.names[index] = name
self.grids[index] = RightGrid("")
self.grids[index].set_items(items)
self.g.setWidget(index, 0, self.grids[index])
示例7: start_game
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def start_game(self, level=None):
if level is not None:
self.level = level
dim = self.level
grid = Grid(dim,dim)
grid.setStyleName("grid")
for i in range(dim):
for j in range(dim):
gc = GridCell(i,j)
grid.setWidget(i,j,gc)
self.add(grid)
示例8: createResultGrid
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
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
示例9: OddGridWidget
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
class OddGridWidget(DockPanel):
def __init__(self, **kwargs):
DockPanel.__init__(self, **kwargs)
self.grid = Grid(StyleName="datagrid")
self.sp = ScrollPanel(self.grid, Width="100%", Height="100%")
self.header = Grid(Height="50px")
self.add(self.header, DockPanel.NORTH)
self.add(self.sp, DockPanel.CENTER)
cf = self.setCellHeight(self.header, "50px")
cf = self.setCellHeight(self.sp, "100%")
self.sortcol = 0
def setData(self, data):
self.data = data
self.redraw()
def sortfn(self, row1, row2):
return cmp(row1[self.sortcol], row2[self.sortcol])
def redraw(self):
self.data.sort(self.sortfn)
rows = len(self.data)
cols = 0
if rows > 0:
cols = len(self.data[0])
self.grid.resize(rows, cols)
self.header.resize(1, cols)
cf = self.grid.getCellFormatter()
for (nrow, row) in enumerate(self.data):
for (ncol, item) in enumerate(row):
self.grid.setHTML(nrow, ncol, str(item))
cf.setWidth(nrow, ncol, "200px")
cf = self.header.getCellFormatter()
self.sortbuttons = []
for ncol in range(cols):
sb = Button("sort col %d" % ncol)
sb.addClickListener(self)
self.header.setWidget(0, ncol, sb)
cf.setWidth(0, ncol, "200px")
self.sortbuttons.append(sb)
def onClick(self, sender):
for (ncol, b) in enumerate(self.sortbuttons):
if sender == b:
self.sortcol = ncol
self.redraw()
示例10: state_to_grid
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def state_to_grid(self, prev_x_board=-1, prev_y_board=-1, prev_x_cell=-1, prev_y_cell=-1):
board = self.state.boards
for y_board in range(3):
for x_board in range(3):
# for this mini-grid, do i make buttons or dashes?
will_make_buttons = self.will_buttons(y_board, x_board)
g=Grid()
g.resize(3, 3)
g.setBorderWidth(2)
g.setCellPadding(9)
g.setCellSpacing(1)
for y_cell in range(3):
for x_cell in range(3):
if board[y_board][x_board][y_cell][x_cell]['cell'] == 0:
if will_make_buttons:
if self.min_player == -1:
b = Button('Play 1 here.', self)
else:
b = Button('Play %d here.' % (self.state.next_piece[2]), self)
b.point = {'x_cell':x_cell, 'y_cell':y_cell, 'y_board': y_board, 'x_board': x_board}
else:
b = HTML('-')
elif board[y_board][x_board][y_cell][x_cell]['cell'] == 1:
if (prev_x_cell == x_cell and
prev_y_cell == y_cell and
prev_y_board == y_board and
prev_x_board == x_board):
b = HTML('<p style="color:red">1</p>')
else:
b = HTML('1')
elif board[y_board][x_board][y_cell][x_cell]['cell'] == 2:
if (prev_x_cell == x_cell and
prev_y_cell == y_cell and
prev_y_board == y_board and
prev_x_board == x_board):
b = HTML('<p style="color:red">2</p>')
else:
b = HTML('2')
g.setWidget(y_cell, x_cell, b)
self.add(g)
self.g.setWidget(y_board, x_board, g)
示例11: init
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def init(self):
'''Initializes the grid on which the game is played.
'''
for y_board in range(3):
for x_board in range(3):
g=Grid()
g.resize(3, 3)
g.setBorderWidth(2)
g.setCellPadding(9)
g.setCellSpacing(1)
for x_cell in range(3):
for y_cell in range(3):
b = Button('Play here.', self)
b.point = {'x_cell':x_cell, 'y_cell':y_cell, 'y_board': y_board, 'x_board': x_board}
g.setWidget(y_cell, x_cell, b)
self.add(g)
self.g.setWidget(y_board, x_board, g)
示例12: __init__
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def __init__(self):
# layed out in a grid with odd rows a different color for
# visual separation
#lucky = Grid(9,10, CellPadding=25, CellSpacing=1, BorderWidth=1)
lucky = Grid()
lucky.resize(9,10)
lucky.setBorderWidth(1)
lucky.setCellPadding(25)
lucky.setCellSpacing(1)
val = 0
for x in range(0,9):
for y in range(0,10):
val += 1
lucky.setText(x,y,val)
grid = Grid(1,3,CellPadding=20,CellSpacing=0)
rf = grid.getRowFormatter()
rf.setStyleName(0, 'oddrow')
# popup timer buttons
ptb = PopupTimerButton(1)
grid.setWidget(0, 0, CaptionPanel('Start the Lucky Number Countdown', ptb, StyleName='left'))
grid.setWidget(0, 1, CaptionPanel('Current Lucky Number',ptb.box))
grid.setWidget(0, 2, lucky)
# add it all to the root panel
RootPanel().add(grid, lucky)
示例13: __init__
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def __init__(self, listener):
VerticalPanel.__init__(self, StyleName = "login")
self.listener = listener
self.remote = DataService(['login'])
form_panel = VerticalPanel(ID = "container", StyleName = "form")
self.error_message = Label(StyleName = "error-message")
grid = Grid(2, 2,
CellPadding=0,
CellSpacing=0,
StyleName = "form-grid")
grid.setWidget(0, 0, Label(JS('gettext("Username:")'),
StyleName = "label"))
self.tb = TextBox(Name="username")
grid.setWidget(0, 1, self.tb)
grid.setWidget(1, 0, Label(JS('gettext("Password:")'),
StyleName = "label"))
self.ptb = PasswordTextBox(Name="password")
grid.setWidget(1, 1, self.ptb)
form_panel.add(Label(JS('gettext("User Login")'), StyleName = "form-title"))
form_panel.add(self.error_message)
form_panel.add(grid)
button_box = HorizontalPanel(Width="100%")
register_button = PseudoLink(JS('gettext("Create an account")'),
self.onRegisterButtonClick)
submit_button = Button(JS('gettext("Login")'),
self.onSubmitButtonClick)
button_box.add(register_button)
button_box.add(submit_button)
button_box.setCellHorizontalAlignment(submit_button,
HasAlignment.ALIGN_RIGHT)
form_panel.add(button_box)
self.add(form_panel)
示例14: __init__
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def __init__(self, topPanel):
TickeryTab.__init__(self, topPanel)
# Get the query string and wanted tab, if any, from URL args.
args = Window.getLocation().getSearchDict()
query = args.get('query')
wantedTab = args.get('tab')
if wantedTab:
wantedTab = wantedTab.lower()
if query and wantedTab == self.tabName.lower():
query = urllib.unquote_plus(query)
self.autoActivate = True
else:
query = self.defaultQuery
self.instructions.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
self.instructions.setStyleName('instructions-popup')
self.popup = InstructionBox(
self.__class__.__name__, self.instructions)
self.popup.setText(self.instructionsTitle)
self.db = Button(HELP_TEXT, StyleName='help-button')
self.db.addClickListener(self)
huhId = HTMLPanel.createUniqueId()
help = HTMLPanel('%s <span id="%s"></span>' %
(SHORT_INSTRUCTIONS[self.tabName], huhId),
StyleName='simple-instructions')
help.add(self.db, huhId)
self.goButton = go.GoButton(self)
self.query = text.TextAreaFocusHighlight(Text=query,
VisibleLines=3,
StyleName='large-query-area')
self.checkResult = HorizontalPanel(Spacing=4)
mainGrid = Grid(2, 2, StyleName='tickery-tab-panel',
HorizontalAlignment=HasAlignment.ALIGN_LEFT)
formatter = mainGrid.getCellFormatter()
mainGrid.setWidget(0, 0, help)
mainGrid.setWidget(1, 0, self.query)
mainGrid.setWidget(1, 1, self.goButton)
formatter.setHorizontalAlignment(0, 0, 'left')
formatter.setHorizontalAlignment(1, 0, 'left')
formatter.setAlignment(1, 1, 'left', 'bottom')
self.topGrid.setWidget(0, 1, mainGrid)
self.add(self.checkResult)
self.results = userlist.UserListPanel(self, topPanel,
HorizontalAlignment=HasAlignment.ALIGN_LEFT)
self.add(self.results)
示例15: onModuleLoad
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidget [as 别名]
def onModuleLoad(self):
self.popupsubtraca = PopupSub(id="sub",datasrc="fsubtracao.pjs")
self.popupsoma = PopupSoma(id="soma",datasrc="fsoma.pjs")
self.popupmultescalar = PopupEscalar(id="escalar",datasrc="fmultescalar.pjs")
self.popupmult = PopupProduto(id="mult",datasrc="fmult.pjs")
self.popupsoma.iniciado = False;
tabpanel = TabPanel()
grid = Grid(4,2)
imgbtnSoma = Image("images/Soma_Matriz_sum_matrix.png",StyleName="gwt-ImageButton")
imgbtnSubtracao = Image("images/subtracao_Matriz_subtract_matrix.png",StyleName="gwt-ImageButton")
imgbtnMultiplicacao = Image("images/multiplicacao_Matriz_product_matrix.png",StyleName="gwt-ImageButton")
imgbtnMultiplicacaoPorEscalar = Image("images/multiplicacao_por_escalar.png",StyleName="gwt-ImageButton")
#eventos
imgbtnSoma.addClickListener(self.onSomaButtonClick)
imgbtnSubtracao.addClickListener(self.onSubtracaoButtonClick)
imgbtnMultiplicacao.addClickListener(self.onMultiplicacaoButtonClick)
imgbtnMultiplicacaoPorEscalar.addClickListener(self.onMulPorEscalarButtonClick)
contents = VerticalPanel()
contents.setSpacing(4)
contents.add(HTML('You can place any contents you like in a dialog box.'))
grid.setWidget(0,0,imgbtnSoma)
grid.setWidget(0,1,imgbtnSubtracao)
grid.setWidget(2,0,imgbtnMultiplicacao)
grid.setWidget(2,1,imgbtnMultiplicacaoPorEscalar)
grid.setStyleName(element)
tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Modulo de introducao a Matrizes</h2>", True)
tabpanel.add(grid,"<h2> Matrizes </h2>", True)
tabpanel.add(HTML("Modulo de introducao a matrizes"),"<h2>Ajuda para usar a ferramenta</h2>", True)
tabpanel.setSize("90%"," 70%")
tabpanel.selectTab(1)
#self.popupsoma.show()
RootPanel("conteudo").add(tabpanel)