本文整理汇总了Python中pyjamas.ui.Grid.Grid.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Python Grid.setWidth方法的具体用法?Python Grid.setWidth怎么用?Python Grid.setWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Grid.Grid
的用法示例。
在下文中一共展示了Grid.setWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onModuleLoad
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidth [as 别名]
class GridEdit:
def onModuleLoad(self):
self.input = TextBox()
self.input.setEnabled(False)
self.input.addKeyboardListener(self)
self.g=Grid()
self.g.resize(5, 5)
self.g.setHTML(0, 0, "<b>Grid Edit</b>")
self.g.setBorderWidth(2)
self.g.setCellPadding(4)
self.g.setCellSpacing(1)
self.g.setWidth("500px")
self.g.setHeight("120px")
self.g.addTableListener(self)
self.initGrid()
RootPanel().add(self.input)
RootPanel().add(self.g)
def onKeyDown(self, sender, keycode, modifiers):
pass
def onKeyUp(self, sender, keycode, modifiers):
pass
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KeyboardListener.KEY_ESCAPE:
self.input.setEnabled(False)
elif keycode == KeyboardListener.KEY_ENTER:
self.input.setEnabled(False)
val = self.input.getText()
self.set_grid_value(self.row, self.col, val)
def onCellClicked(self, sender, row, col):
self.row = row
self.col = col
val = self.values[row][col]
self.input.setText(val)
self.input.setEnabled(True)
self.input.setFocus(True)
def set_grid_value(self, row, col, val):
self.values[row][col] = val
if val == "":
val = " "
self.g.setHTML(row, col, val)
def initGrid(self):
self.values = {}
for y in range(5):
self.values[y] = {}
for x in range(5):
self.values[y][x] = ""
for y in range(5):
for x in range(5):
val = self.values[y][x]
self.set_grid_value(y, x, val)
示例2: drawGrid
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidth [as 别名]
def drawGrid(self, month, year):
# draw the grid in the middle of the calendar
daysInMonth = self.getDaysInMonth(month, year)
# first day of the month & year
secs = time.mktime((year, month, 1, 0, 0, 0, 0, 0, -1))
struct = time.localtime(secs)
# 0 - sunday for our needs instead 0 = monday in tm_wday
startPos = (struct.tm_wday + 1) % 7
slots = startPos + daysInMonth - 1
rows = int(slots/7) + 1
grid = Grid(rows+1, 7) # extra row for the days in the week
grid.setWidth("100%")
grid.addTableListener(self)
self.middlePanel.setWidget(grid)
#
# put some content into the grid cells
#
for i in range(7):
grid.setText(0, i, self.getDaysOfWeek()[i])
grid.cellFormatter.addStyleName(0, i, "calendar-header")
#
# draw cells which are empty first
#
day =0
pos = 0
while pos < startPos:
grid.setText(1, pos , " ")
grid.cellFormatter.setStyleAttr(1, pos, "background", "#f3f3f3")
grid.cellFormatter.addStyleName(1, pos, "calendar-blank-cell")
pos += 1
# now for days of the month
row = 1
day = 1
col = startPos
while day <= daysInMonth:
if pos % 7 == 0 and day <> 1:
row += 1
col = pos % 7
grid.setText(row, col, str(day))
if self.currentYear == self.todayYear and \
self.currentMonth == self.todayMonth and day == self.todayDay:
grid.cellFormatter.addStyleName(row, col, "calendar-cell-today")
else:
grid.cellFormatter.addStyleName(row, col, "calendar-day-cell")
day += 1
pos += 1
#
# now blank lines on the last row
#
col += 1
while col < 7:
grid.setText(row, col, " ")
grid.cellFormatter.setStyleAttr(row, col, "background", "#f3f3f3")
grid.cellFormatter.addStyleName(row, col, "calendar-blank-cell")
col += 1
return grid
示例3: PopupPagina
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidth [as 别名]
#.........这里部分代码省略.........
lblinha2.addItem("1", value=1)
lblinha2.addItem("2", value=2)
lblinha2.addItem("3", value=3)
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")
示例4: drawGrid
# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import setWidth [as 别名]
def drawGrid(self, month, year):
# draw the grid in the middle of the calendar
self.checkLinks(month, year)
daysInMonth = self.getDaysInMonth(month, year)
# first day of the month & year
secs = time.mktime((year, month, 1, 0, 0, 0, 0, 0, -1))
struct = time.localtime(secs)
startPos = (struct.tm_wday + self.dayoffset) % 7
slots = startPos + daysInMonth - 1
rows = int(slots/7) + 1
grid = Grid(rows+1, 7, # extra row for the days in the week
StyleName="calendar-grid")
grid.setWidth("100%")
grid.addTableListener(self)
self.middlePanel.setWidget(grid)
cf = grid.getCellFormatter()
#
# put some content into the grid cells
#
for i in range(7):
grid.setText(0, i, self.getDaysOfWeek()[i])
cf.addStyleName(0, i, "calendar-header")
#
# draw cells which are empty first
#
day = 0
pos = 0
while pos < startPos:
self._setCell(grid, 1, pos, BLANKCELL, "calendar-blank-cell")
pos += 1
# now for days of the month
row = 1
day = 1
col = startPos
while day <= daysInMonth:
if pos % 7 == 0 and day != 1:
row += 1
col = pos % 7
if not self._indaterange(self.currentYear, self.currentMonth, day):
self._setCell(grid, row, col, BLANKCELL, "calendar-blank-cell")
day += 1
pos += 1
continue
if self.currentYear == self.todayYear and \
self.currentMonth == self.todayMonth and day == self.todayDay:
style = "calendar-cell-today"
else:
style = "calendar-day-cell"
self._setCell(grid, row, col, str(day), style)
day += 1
pos += 1
#
# now blank lines on the last row
#
col += 1
while col < 7:
self._setCell(grid, row, col, BLANKCELL, "calendar-blank-cell")
col += 1
return grid