本文整理汇总了Python中pyjamas.Window类的典型用法代码示例。如果您正苦于以下问题:Python Window类的具体用法?Python Window怎么用?Python Window使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Window类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createRightPanel
def createRightPanel(self):
span = self.stabPanel = SimplePanel(Height="100%")
tabs = self.tabPanel = TabPanel(Width="100%", Border=1,Height="100%")
adgui = self.adinfoPanel = AdinfoIFACE(self)
tabs.add(adgui.panel, "AstroData Viewer")
calsgui = self.calsPanel = CalsIFACE(self)
tabs.add(calsgui.panel, "Calibrations")
rsgui = RecipeSystemIFACE.ReducePanelIFACE(self)
tabs.add(rsgui.panel, "Execute Reduce")
rogui = RecipeSystemIFACE.ReduceOutputIFACE(self)
tabs.add(rogui.panel, "Reduce Output")
Window.addWindowResizeListener(rogui)
tifs = self.tabIFACEs = [adgui, calsgui, rsgui, rogui]
self.tabIFACEdict = {"adgui": tifs.index(adgui),
"calsgui": tifs.index(calsgui),
"rsgui": tifs.index(rsgui),
"rogui": tifs.index(rogui)}
self.curTabIFACE = tifs[0]
tabs.selectTab(0)
span.add(tabs)
tabs.addTabListener(self, getattr(self, "onTabSelected"))
return span
示例2: jumpsFromGregorian
def jumpsFromGregorian(self, gregorianDate):
"""
- Obtention of Number of seconds ahead or before reference point
- Calculation*:
- Calculation of _Number of Cycle Jumps_ from reference point in number of seconds
"""
Window.alert(gregorianDate)
gregorianDate = datetime.datetime(gregorianDate)
Window.alert(isinstance(gregorianDate, datetime.datetime))
Window.alert(gregorianDate)
jumps = 0
diff = datetime.datetime(gregorianDate) - datetime.datetime(self.referencePoint.START_DATE)
Window.alert(diff.days)
f = diff>0
diff = math.abs(diff)
while diff>0:
jumps = jumps+1
Window.alert(float(self.referencePoint.CREATION_SPEED))
if f:
"""original formula: (1*13/(self.referencePoint.SPEED*13^jumps))"""
diff = diff - (1/(self.referencePoint.CREATION_SPEED*13^(jumps-1)))
else:
"""original formula: (1*13/(self.referencePoint.SPEED/13^jumps))"""
diff = diff - (1/(self.referencePoint.CREATION_SPEED/13^(jumps+1)))
return jumps
示例3: setPopupPosition
def setPopupPosition(self, left, top):
if isinstance(left, basestring):
if left.endswith('%'):
left = int(left[:-1])
left = int(left * Window.getClientWidth() / 100)
elif left.lower().endswith('px'):
left = int(left[:-2])
if isinstance(top, basestring):
if top.lower().endswith('%'):
top = int(top[:-1])
top = int(top * Window.getClientHeight() / 100)
elif top.endswith('px'):
top = int(top[:-2])
left = max(left, 0)
top = max(top, 0)
# Account for the difference between absolute position and the
# body's positioning context.
left -= DOM.getBodyOffsetLeft()
top -= DOM.getBodyOffsetTop()
element = self.getElement()
DOM.setStyleAttribute(element, "left", "%dpx" % left)
DOM.setStyleAttribute(element, "top", "%dpx" % top)
示例4: onTitlesChanged
def onTitlesChanged(self, titles):
browser_title = ''
for title in reversed(titles):
browser_title += title + ' - '
browser_title = browser_title[:-3]
Window.setTitle(browser_title)
示例5: __init__
def __init__(self, parent=None):
Sink.__init__(self, parent)
self.frame = Frame("/summary", Size=("100%",rccutil.getHeight()))
self.initWidget(self.frame)
Window.addWindowResizeListener(self)
示例6: onModuleLoad
def onModuleLoad(self):
dock = DockPanel(Width="100%")
self.header = HTML(Width="100%", Height="220px")
self.footer = HTML(Width="100%")
self.sidebar = HTML(Width="200px", Height="100%", StyleName="sidebar")
self.fTabs = DecoratedTabPanel(Size=("100%", "100%"), StyleName="tabs")
#dp = DecoratorTitledPanel("Tabs", "bluetitle", "bluetitleicon",
# ["bluetop", "bluetop2", "bluemiddle", "bluebottom"])
#dp.add(self.fTabs)
dock.add(self.header, DockPanel.NORTH)
dock.add(self.footer, DockPanel.SOUTH)
dock.add(self.sidebar, DockPanel.EAST)
dock.add(self.fTabs, DockPanel.CENTER)
dock.setCellVerticalAlignment(self.fTabs, HasAlignment.ALIGN_TOP)
#dock.setCellHorizontalAlignment(self.fTabs, HasAlignment.ALIGN_CENTER)
dock.setCellWidth(self.header, "100%")
dock.setCellHeight(self.header, "220px")
dock.setCellWidth(self.footer, "100%")
dock.setCellWidth(self.sidebar, "200px")
RootPanel().add(dock)
self.dock = dock
self.loadPageList()
Window.addWindowResizeListener(self)
DeferredCommand.add(self)
示例7: onError
def onError(self, text):
obj = JSONParser().decode(text)
# Hack for 201 being seen as error
if not obj['ok']:
Window.alert(text)
else:
self.editor.reloadDocument()
示例8: onDrop
def onDrop(self, event):
dt = event.dataTransfer
text = dt.getData('text')
package = json.decode(text)
x = DOM.eventGetClientX(event)
y = DOM.eventGetClientY(event)
scrollY = Window.getScrollTop()
scrollX = Window.getScrollLeft()
offsetX = int(package['offsetX'])
offsetY = int(package['offsetY'])
at = self.getAbsoluteTop()
al = self.getAbsoluteLeft()
posX, posY = x - (al - scrollX), y - (at - scrollY)
w = DragWidget6(package['text'])
self.add(w)
makeDraggable(w)
# firefox seems to be off-by-one in x.
# firefox-specific code?
#w.setStyleAttribute('left', posX - offsetX -1)
w.setStyleAttribute('left', posX - offsetX)
w.setStyleAttribute('top', posY - offsetY)
w.removeStyleName('invisible')
self.addMessage(
"top:%s, left:%s, cy:%s cx:%s, sy:%s sx:%s dropy:%s dropx:%s" % (
at, al, y, x, scrollY, scrollX, posY, posX))
DOM.eventPreventDefault(event)
示例9: onClick
def onClick(self):
if not self.survey.is_cookie_set() and self.mturk_input.accepted == True:
if not self.survey.survey_filledout():
Window.alert("Please fill out the survey")
else:
self.survey.set_cookie()
encoded_answers = []
for i,answer in enumerate(self.survey.get_answers()):
encoded_answers.append(("survey_answer%d" % i,answer))
self.mturk_output.add_data(encoded_answers)
self.mturk_output.add_data(self.sentence_set.get_sentences())
self.mturk_output.add_data(self.sentence_set.get_masks())
self.mturk_output.add_data(self.sentence_set.get_annotations())
self.mturk_output.mturk_form.submit()
else:
self.mturk_output.add_data(self.sentence_set.get_sentences())
self.mturk_output.add_data(self.sentence_set.get_masks())
self.mturk_output.add_data(self.sentence_set.get_annotations())
self.mturk_output.mturk_form.submit()
示例10: onSubmit
def onSubmit(self, event):
# This event is fired just before the form is submitted. We can take
# this opportunity to perform validation.
print "onSubmit", event
if (len(self.tb.getText()) == 0):
Window.alert("The text box must not be empty")
event.setCancelled()
示例11: show_custom
def show_custom(self):
self.dialog = DialogBox(StyleName='custom-dialog')
self.dialog.setHTML('Custom Settings')
contents = VerticalPanel(StyleName='contents')
self.dialog.setWidget(contents)
# contents of contents
rows = HorizontalPanel()
columns = HorizontalPanel()
bombs = HorizontalPanel()
buttons = HorizontalPanel()
ADD(contents, rows, columns, bombs, buttons)
self.row = TextBox()
ADD(rows, Label('Rows:'), self.row)
self.column = TextBox()
ADD(columns, Label('Columns:'), self.column)
self.bomb = TextBox()
ADD(bombs, Label('Bombs:'), self.bomb)
ADD(buttons, Button("OK", getattr(self, 'new_game')), \
Button("Cancel", getattr(self, 'close_dialog')))
left = (Window.getClientWidth() - 201) / 2
top = (Window.getClientHeight() - 190) / 2
self.dialog.setPopupPosition(left, top)
self.dialog.show()
示例12: onClick
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)
if id < 0:
self.status.setHTML("Server Error or Invalid Response")
示例13: __init__
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)
示例14: themesPanel
def themesPanel(self, themes=None):
Window.alert('line:111')
themes = None
if not themes: themes=['0','1', 'cms', 'pypress']
vPanel = VerticalPanel()
for i in range(len(themes)):
"""
a_n = location.getPathName().split('/')[1]
lambda1 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/'+x+'/')+'?theme='+x
lambda2 = lambda x: w_l.pathname.replace('/'+a_n+'/', '/a/')+'?theme='+x
href = {
'cms' : lambda1,
'pypress' : lambda1,
'o' : lambda2,
'1' : lambda2
}.get(themes[i], lambda2)(themes[i])
"""
a=Button('theme '+themes[i],
lambda x: location.setSearchDict({'theme': x.getID()}),
StyleName='link')
a.setID(themes[i])
vPanel.add(a)
return vPanel
示例15: onRemoteResponse
def onRemoteResponse(self, response, request_info):
# Window.alert(dir(request_info))
# Window.alert(request_info.method)
# Window.alert(request_info.handler)
# time.sleep( 3 )
Window.alert("inside MLAlgorithmService: compression is done")
self.callback.loadImage(response)