本文整理汇总了Python中pyjamas.ui.FlexTable.FlexTable.setText方法的典型用法代码示例。如果您正苦于以下问题:Python FlexTable.setText方法的具体用法?Python FlexTable.setText怎么用?Python FlexTable.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.FlexTable.FlexTable
的用法示例。
在下文中一共展示了FlexTable.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flextable
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
def flextable(data):
table = FlexTable()
rows = len(data)
columns = len(data[0])
datalist = flatten(data)
columnlist = flatten([range(columns) for x in range(rows)])
rowlist = flatten([[x for y in range(columns)]
for x in range(rows)])
tablelist = zip(rowlist,columnlist,datalist)
for x in tablelist:
table.setText(x[0],x[1],x[2])
table.setBorderWidth(2)
return table
示例2: UploadProblemTab
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class UploadProblemTab(EntityTab):
def __init__(self,app):
EntityTab.__init__(self, app)
self.form = FormPanel()
self.form.setEncoding("multipart/form-data")
self.form.setMethod("post")
self.table = FlexTable()
self.table.setText(0,0,"Problem archive")
self.file = FileUpload()
self.file.setName("file");
self.table.setWidget(0,1,self.file)
self.form.setWidget(self.table)
self.button = Button("Submit",self)
self.table.setWidget(1,1, self.button)
self.msg = HTML("<b>Uploading</b>")
self.msg.setVisible(False)
self.cookie = Hidden()
self.cookie.setName("cookie")
self.table.setWidget(2,0, self.cookie)
self.table.setWidget(2,1, self.msg)
self.form.setWidget(self.table)
self.form.setAction("../upload.py/problem")
self.add("Upload new problem")
def onSubmitComplete(self,event):
self.msg.setVisible(False)
def onSubmit(self,evt):
self.msg.setVisible(True)
def onClick(self,evt):
if self.app.cookie == None:
self.app.login()
else:
self.cookie.setValue(self.app.cookie)
self.form.submit()
def getRoot(self):
return self.form
示例3: LoginDialgoBox
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class LoginDialgoBox(DialogBox,RPCBase):
def __init__(self, app):
DialogBox.__init__(self)
self.app = app
self.table=FlexTable()
self.table.setText(0, 0, "Please enter username and password")
self.table.getFlexCellFormatter().setColSpan(0, 0, 2)
self.table.setText(1, 0, "Username")
self.handle = TextBox()
h = getCookie('handle')
self.handle.setText(h)
self.table.setWidget(1, 1, self.handle)
self.table.setText(2, 0, "Password")
self.pwd = PasswordTextBox()
self.table.setWidget(2, 1, self.pwd)
self.table.setHTML(3,0,"")
self.table.getFlexCellFormatter().setColSpan(3, 0, 2)
h = HorizontalPanel()
self.table.setWidget(4,0, h)
self.table.getFlexCellFormatter().setColSpan(4, 0, 2)
h.add(Button("Ok", getattr(self, "onOk")))
h.add(Button("Cancel", getattr(self, "onClose")))
h.setSpacing(4)
self.setHTML("<b>Login</b>")
self.setWidget(self.table)
left = (Window.getClientWidth() - 200) / 2
top = (Window.getClientHeight() - 100) / 2
self.setPopupPosition(left,top)
def onRemoteResponse(self, response, request_info):
if response == "invalid_cookie":
self.show()
elif response == None or len(response) < 3:
self.table.setHTML(3,0,"<b>Invalid username or password</b>")
else:
self.app.cookie = response[0]
setCookie('cookie',response[0],1000*60*60*24)
self.hide()
self.app.logininit(response[1],response[2])
def onClose(self,env):
Window.getLocation().setHref("http://www.google.com")
def onOk(self, env):
global gw
setCookie('handle',self.handle.getText(),24*60*60*1000)
x = self.pwd.getText()
x = pwhash(x)
gw.login(self.handle.getText(), x, self)
def login(self):
global gw
if not self.app.cookie:
self.show()
else:
gw.validateCookie(self.app.cookie, self)
示例4: FlexTableDemo
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class FlexTableDemo(SimplePanel):
def __init__(self):
SimplePanel.__init__(self)
self._table = FlexTable(BorderWidth=1, Width="100%")
cellFormatter = self._table.getFlexCellFormatter()
rowFormatter = self._table.getRowFormatter()
self._table.setHTML(0, 0, "<b>Mammals</b>")
self._table.setText(1, 0, "Cow")
self._table.setText(1, 1, "Rat")
self._table.setText(1, 2, "Dog")
cellFormatter.setColSpan(0, 0, 3)
cellFormatter.setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER)
self._table.setWidget(2, 0, Button("Hide", getattr(self, "hideRows")))
self._table.setText(2, 1, "1,1")
self._table.setText(2, 2, "2,1")
self._table.setText(3, 0, "1,2")
self._table.setText(3, 1, "2,2")
cellFormatter.setRowSpan(2, 0, 2)
cellFormatter.setVerticalAlignment(2, 0, HasAlignment.ALIGN_MIDDLE)
self._table.setWidget(4, 0, Button("Show", getattr(self, "showRows")))
cellFormatter.setColSpan(4, 0, 3)
rowFormatter.setVisible(4, False)
self.add(self._table)
def hideRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, False)
rowFormatter.setVisible(3, False)
rowFormatter.setVisible(4, True)
def showRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, True)
rowFormatter.setVisible(3, True)
rowFormatter.setVisible(4, False)
示例5: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class CourseProfile:
def onModuleLoad(self):
self.mainPanel = VerticalPanel()
self.courseTable = FlexTable()
self.courseTable.setText(0, 0, 'Course Title: ')
self.courseTable.setText(1, 0, 'Course Description: ')
self.courseTable.setText(2, 0, 'Enroll: ')
self.courseTable.setText(3, 0, 'Friends: ')
self.mainPanel.add(self.courseTable)
RootPanel().add(self.mainPanel)
self.remote.getCourse(self)
def onRemoteResponse(self, response, request_info):
Window.alert(response)
row = self.ratingsTable.getRowCount()
name = response['name']
description = response['description']
enrolled = response['enrolled']
Window.alert(name)
## if enrolled:
## self.courseTable.add(2, 1, 'Enrolled!')
##
## else:
## def enrollClick(event):
## return
##
## self.courseTable.add(2, 1, Button('Enroll', enrollClick)
if name.isalpha() and description.isalpha():
self.courseTable.add(0, 1, name)
self.courseTable.add(1, 1, description)
def onRemoteError(self, code, message, request_info):
Window.alert(str(code) + "||" + str(message) + "||" + str(request_info))
示例6: MailList
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable 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
#.........这里部分代码省略.........
示例7: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [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
#.........这里部分代码省略.........
示例8: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [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")
#.........这里部分代码省略.........
示例9: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class PageVerify:
# setup JSON RPC
facebook_user = {}
users = []
new_user = {}
get_data = {}
app_info = {}
verification_key = None
verification_status = False
def onModuleLoad(self):
self.remote = DataService()
# do JSON RPC calls
self.remote.get_facebook_user(self)
self.remote.get_app_info(self, "verify")
# labels and banners
self.html_verify_banner = HTML("<h1>Verify your NetID</h1>")
self.html_confirm_banner = HTML("<h1>Confirming your NetID...</h1>")
self.lbl_verify_text = Label("Please verify your account.")
self.lbl_confirm_text = Label("Confirming Acount...")
self.lbl_confirm_result = Label()
# textboxes
self.tb_verify_netid = TextBox()
# hook up keyboard events
send_confirmation_email = self.send_confirmation_email
class Add_KeyboardHandler():
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KEY_ENTER:
send_confirmation_email()
def onKeyDown(self, sender, keycode, modifiers): return
def onKeyUp(self, sender, keycode, modifiers): return
self.kbh = Add_KeyboardHandler()
self.tb_verify_netid.addKeyboardListener(self.kbh)
# buttons
self.btn_verify = Button("Verify!", self.send_confirmation_email)
# NetID information form
self.table_verify_netid = FlexTable()
self.table_verify_netid.setText(0, 0, "NetID:")
self.table_verify_netid.setWidget(0, 1, self.tb_verify_netid)
self.table_verify_netid.setWidget(1, 1, self.btn_verify)
# panels
self.main_panel = VerticalPanel()
# check get information, if present, verify, if not request form
self.location = Window.getLocation().getHref()
self.tmp = self.location.split('?')
self.tmp = self.tmp[len(self.tmp) - 1].split("&")
for e in self.tmp:
get_var = e.split("=")
if len(get_var) == 2:
PageVerify.get_data[get_var[0]] = get_var[1]
if "vk" in PageVerify.get_data:
# we have request from verification email
self.main_panel.add(self.html_confirm_banner)
self.main_panel.add(self.lbl_confirm_text)
self.main_panel.add(self.lbl_confirm_result)
self.verify_user()
else:
self.main_panel.add(self.html_verify_banner)
self.main_panel.add(self.lbl_verify_text)
self.main_panel.add(self.table_verify_netid)
self.main_panel.addStyleName("verify_panel")
# add everything to root panel
RootPanel("page_verify").add(self.main_panel)
def send_confirmation_email(self, sender, netid = None):
""" given a valid NetID, send a confirmation email
with a link (using encrypted key) to validate
the user's NetID
"""
if netid == None:
netid = self.tb_verify_netid.getText()
# create a new user with netid and facebook id
self.remote.create_user(self, PageVerify.facebook_user['facebook_id'], netid, PageVerify.facebook_user['full_name'])
# create cryptogram based on email name
self.remote.encrypt(self, netid)
# subject line
subject = "Hello from Textbook Connect!"
class EmailTimer(Timer):
def __init__(self, context):
Timer.__init__(self)
self.max_tries = 10
self.tries = 0
self.context = context
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
def __init__(self, chart):
""" DialogBox CSS Style self.settings used with this example for reference:
Note: These simplified CSS styles make the dialog's title bar behave a
little quirkily in IE6 when dragging. For more sophisticated CSS that
fixes this problem (and also provides a more professional look) see the
CSS tab of the DialogBox example in the GWT <a href="xxx"> Showcase of
Features</a> (I just didn't want to copy 5 pages of obscure DialogBox
CSS into what is after all a Client-side GChart example).
.gwt-DialogBox .Caption {
font-size: 18
color: #eef
background: #00f repeat-x 0px -2003px
padding: 4px 4px 4px 8px
cursor: default
border-bottom: 2px solid #008
border-top: 3px solid #448
.gwt-DialogBox .dialogContent {
border: 1px solid #008
background: #ddd
padding: 3px
"""
DialogBox.__init__(self, autoHide=True, modal=True)
self.chart = chart
self.isFirstTime = True
mainPanel = VerticalPanel()
propertyForm = FlexTable()
commandBar = DockPanel()
sliceSwitcher = HorizontalPanel()
self.prevSlice = Button("<Prev Slice", self)
self.nextSlice = Button("Next Slice>", self)
self.closeButton = Button("Close", self)
self.chart.colorSelector.addChangeListener(self)
self.chart.sliceSizeSelector.addChangeListener(self)
self.chart.shadingSelector.addChangeListener(self)
#self.prevSlice.addClickListener(self)
#self.nextSlice.addClickListener(self)
#self.closeButton.addClickListener(self)
# slice properties table (slice color, shading and size)
propertyForm.setSize(3, 2)
propertyForm.setText( 0, 0, "Color:")
propertyForm.setWidget(0, 1, self.chart.colorSelector)
propertyForm.setText( 1, 0, "Shading Pattern:")
propertyForm.setWidget(1, 1, self.chart.shadingSelector)
propertyForm.setText( 2, 0, "Slice Size:")
propertyForm.setWidget(2, 1, self.chart.sliceSizeSelector)
# add additional properties here, if desired
# buttons for changing the selected slice from the form
sliceSwitcher.add(self.prevSlice)
sliceSwitcher.add(self.nextSlice)
commandBar.add(sliceSwitcher, DockPanel.WEST)
commandBar.add(self.closeButton, DockPanel.EAST)
commandBar.setCellHorizontalAlignment(self.closeButton,
HasHorizontalAlignment.ALIGN_RIGHT)
commandBar.setWidth("100%"); # pushes close button to right edge
# create main form and place it in DialogBox
mainPanel.add(propertyForm)
mainPanel.add(commandBar)
self.setWidget(mainPanel); # add the DialogBox' single, defining, widget
示例11: __init__
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class SubmitTab:
def __init__(self,app):
self.app=app
self.form = FormPanel()
self.form.setEncoding("multipart/form-data")
self.form.setMethod("post")
self.msg = HTML("<b>Uploading</b>")
self.table = FlexTable()
self.table.setText(0,0, "Problem")
self.table.setText(1,0, "Language")
self.table.setText(2,0, "Program File")
self.table.setText(3,0, "Program source")
self.problem = ListBox()
self.problem.insertItem("Detect",-1,-1)
self.problem.setName("problem")
self.table.setWidget(0,1,self.problem)
self.lang = ListBox()
self.lang.insertItem("Detect","",-1)
self.lang.insertItem("C/C++","cc",-1)
self.lang.insertItem("Java","Java",-1)
self.lang.insertItem("Python","Python",-1)
self.lang.setName("lang")
self.table.setWidget(1,1,self.lang)
self.cookie = Hidden()
self.cookie.setName("cookie")
self.table.setWidget(5,0,self.cookie)
self.file = FileUpload()
self.file.setName("file");
self.table.setWidget(2,1,self.file)
self.source = TextArea()
self.source.setName("source")
self.source.setWidth("600");
self.source.setHeight("400");
self.source.setText("""//$$problem: 1$$
//$$language: cc$$
#include <unistd.h>
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d\\n",a+b);
return 0;
}""")
self.source.addChangeListener(self.onChange)
self.table.setWidget(3,1,self.source)
self.button = Button("Submit",self)
self.table.setWidget(4,1, self.button)
self.table.setWidget(5,1, self.msg)
self.msg.setVisible(False)
self.form.setWidget(self.table)
self.form.setAction("../upload.py/submit")
self.form.addFormHandler(self)
def onChange(self, src):
if self.source.getText():
self.file = FileUpload()
self.file.setName("file");
self.table.setWidget(2,1,self.file)
def onSubmitComplete(self,event):
self.msg.setVisible(False)
def onSubmit(self,evt):
self.msg.setVisible(True)
def onClick(self,evt):
if self.app.cookie == None:
self.app.login()
else:
self.cookie.setValue(self.app.cookie)
self.form.submit()
def getRoot(self):
return self.form
示例12: StatusTab
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class StatusTab(RPCBase):
def __init__(self,app):
self.app=app
self.vpanel = VerticalPanel()
self.vpanel.setWidth("100%")
self.table = FlexTable()
self.vpanel.add(self.table)
btn = Button('Update',self.update)
self.vpanel.add(btn)
self.id2row = {}
self.table.setHTML(0, 0, "<b>Time</b>")
self.table.setHTML(0, 1, "<b>Problem</b>")
self.table.setHTML(0, 2, "<b>User</b>")
self.table.setHTML(0, 3, "<b>Status</b>")
self.cnt=1
self.time=None
#self.update()
Timer(4000,self)
def onTimer(self, x):
#self.update()
Timer(4000,self)
def update(self,_=None):
global gw
gw.listSubmissions(self.time, self)
def problemLambda(self, pid):
return lambda: ProblemTab(self.app, pid)
def userLambda(self,uid):
return lambda: UserTab(self.app, uid)
def submissionLambda(self,sid):
return lambda: SubmissionTab(self.app, sid)
def onRemoteResponse(self, response, request_info):
#0 (x.id,
#1 x.problem.name,
#2 x.problem_id,
#3 x.submitter.handle,
#4 x.submitter_id,
#5 status(x.code),
#6 x.judgeTime,
#7 x.submitTime )
if response:
for line in response:
if line[0] in self.id2row:
idx =self.cnt- self.id2row[line[0]]
#alert(self.id2row[line[0]] + " " + idx + " " + self.cnt);
#return
else:
idx = 1
self.table.insertRow(1)
self.id2row[line[0]] = self.cnt
self.cnt += 1
#Hyperlink
self.table.setText(idx, 0, line[7])
pl=Hyperlink(line[1])
pl.addClickListener(self.problemLambda(line[2]));
self.table.setWidget(idx, 1, pl)
ul=Hyperlink(line[3])
ul.addClickListener(self.userLambda(line[4]) );
self.table.setWidget(idx, 2, ul)
sl=Hyperlink(line[5])
sl.addClickListener(self.submissionLambda(line[0]))
self.table.setWidget(idx, 3, sl)
if line[6] != 'None': self.time = max(self.time, line[6], line[7])
else: self.time = max(self.time, line[7])
def getRoot(self):
return self.vpanel
示例13: SubmissionTab
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class SubmissionTab(EntityTab):
def __init__(self,app, sid):
global gw
EntityTab.__init__(self, app)
gw.getSubmissionDetails(app.cookie, sid, self)
def trcode(self, c):
if c == 0:
return "Success"
elif c == 1:
return "Exit none-zero"
elif c == 2:
return "Presentation error"
elif c == 3:
return "Time limit exceeded"
elif c == 4:
return "Abnormal termination"
elif c == 5:
return "Runtime error"
elif c == 6:
return "Output limit exceeded"
elif c == 7:
return "Internal error"
elif c == 8:
return "Compilation time exceeded"
elif c == 9:
return "Compile error"
elif c == 10:
return "Entry does not exist"
elif c == 11:
return "Bad command"
elif c == 12:
return "Pending"
elif c == 13:
return "Error untaring archive"
elif c == 14:
return "Wrong output"
elif c == 15:
return "Invalid memory reference"
elif c == 16:
return "Memory limit exceeded"
elif c == 17:
return "Divide by zero"
else:
return "Unknown"
def onRemoteResponse(self, response, request_info):
self.table = FlexTable()
self.table.setText(0,0, "Problem");
self.table.setText(0,1, response['problem']);
self.table.setText(1,0, "Code");
self.table.setText(1,1, self.trcode(response['code'])+ " ("+response['code']+")");
self.table.setText(2,0, "Message");
x = TextArea()
x.setText(response['message'])
x.setWidth(600);
x.setHeight(300);
pyjamas.DOM.setAttribute(x.getElement(), 'readOnly', 'readonly')
pyjamas.DOM.setAttribute(x.getElement(), 'readonly', 'readonly')
self.table.setWidget(2,1,x );
self.table.setText(3,0, "Source");
x = TextArea()
x.setText(response['source'])
x.setWidth(600);
x.setHeight(300);
pyjamas.DOM.setAttribute(x.getElement(), 'readOnly', 'readonly')
pyjamas.DOM.setAttribute(x.getElement(), 'readonly', 'readonly')
self.table.setWidget(3,1, x);
self.add("Submission "+response['id'])
示例14: UserTab
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [as 别名]
class UserTab(EntityTab):
def __init__(self,app, uid):
global gw
EntityTab.__init__(self, app)
self.table = FlexTable()
self.uid = uid
self.load()
def load(self):
global gw
if self.uid == -1:
self.setup(None)
else:
gw.getUserDetails(self.app.cookie, self.uid, self)
def setup(self, x):
edit = self.uid == self.app.uid or self.app.admin
if not x:
x = {'id': -1, 'handle': '', 'name': '' , 'admin': '', 'email': ''}
self.uid = x['id']
self.name = TextBox()
self.name.setText(x['name'])
self.email = TextBox()
self.email.setText(x['email'])
self.password = PasswordTextBox()
self.passwordRepeat = PasswordTextBox()
self.handle = TextBox()
self.admin = CheckBox()
self.admin.setChecked( x['admin'] )
self.admin.setEnabled( self.app.admin )
self.table.setText(0,0, "ID");
self.table.setText(0,1, x['id'])
self.table.setText(1,0, "Handle")
if x['id'] == -1:
self.table.setWidget(1,1, self.handle)
else:
self.table.setText(1,1, x['handle'])
self.table.setText(2,0, "Name");
if edit:
self.table.setWidget(2,1, self.name)
else:
self.table.setText(2,1, x['name'])
self.table.setText(3,0, "Email")
if edit:
self.table.setWidget(3,1, self.email)
else:
self.table.setText(3,1, x['email'])
self.table.setText(4,0, "Admin");
self.table.setWidget(4,1, self.admin)
if edit:
self.table.setText(5,0, "Password");
self.table.setWidget(5,1, self.password)
self.table.setText(6,0, "Password Repeat");
self.table.setWidget(6,1, self.passwordRepeat)
self.saveBtn = Button("Save",self.save)
self.table.setWidget(7,1, self.saveBtn)
if self.app.admin:
self.table.setWidget(8,1, Button("Remove", self.delete))
if self.uid == -1:
self.add('New user')
else:
self.add(x['handle'])
def onUpdate(self, response, request_info):
self.uid = response
self.load()
self.app.usersTab.reload()
def save(self, _):
global gw
pwd=""
if self.password.getText() != "" or self.passwordRepeat.getText() != "":
if self.password.getText() != self.passwordRepeat.getText():
Window.alert("Passwords differ");
return
pwd = pwhash(self.password.getText())
gw.updateUser(self.app.cookie, self.uid, self.handle.getText(), self.name.getText(), pwd, self.admin.isChecked(), self.email.getText(), RPCCall(self.onUpdate))
def onDelete(self, response, request_info):
self.app.usersTab.reload()
self.remove()
def delete(self,_):
global gw
gw.deleteUser(self.app.cookie, self.uid, RPCCall(self.onDelete) )
def onRemoteResponse(self, response, request_info):
self.setup(response)
示例15: AlarmWidget
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setText [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')
#.........这里部分代码省略.........