本文整理汇总了Python中pyjamas.ui.PopupPanel.PopupPanel.hide方法的典型用法代码示例。如果您正苦于以下问题:Python PopupPanel.hide方法的具体用法?Python PopupPanel.hide怎么用?Python PopupPanel.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.PopupPanel.PopupPanel
的用法示例。
在下文中一共展示了PopupPanel.hide方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PopupPanelDemo
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
class PopupPanelDemo(SimplePanel):
def __init__(self):
SimplePanel.__init__(self)
vPanel = VerticalPanel(Spacing=4)
self._btn = Button("Click Me", getattr(self, "showPopup"))
vPanel.add(HTML("Click on the button below to display the popup."))
vPanel.add(self._btn)
self.add(vPanel)
def showPopup(self, event):
contents = HTML("Hello, World!")
contents.addClickListener(getattr(self, "onClick"))
self._popup = PopupPanel(autoHide=True)
self._popup.add(contents)
self._popup.setStyleName("showcase-popup")
left = self._btn.getAbsoluteLeft() + 10
top = self._btn.getAbsoluteTop() + 10
self._popup.setPopupPosition(left, top)
self._popup.show()
def onClick(self, sender=None):
self._popup.hide()
示例2: hide
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
def hide(self, autoClosed=False):
if not self.showing:
return
if self.identifier in modal_popups:
del modal_popups[self.identifier]
PopupPanel.hide(self)
示例3: hide
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
def hide(self, autoClosed=False):
self.tooltip_show_timer.cancel()
PopupPanel.hide(self, autoClosed)
示例4: AutoCompleteTextBox
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
class AutoCompleteTextBox(TextBox):
def __init__(self, **kwargs):
self.choicesPopup = PopupPanel(True, False)
self.choices = ListBox()
self.items = SimpleAutoCompletionItems()
self.popupAdded = False
self.visible = False
self.choices.addClickListener(self)
self.choices.addChangeListener(self)
self.choicesPopup.add(self.choices)
self.choicesPopup.addStyleName("AutoCompleteChoices")
self.choices.setStyleName("list")
if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-AutoCompleteTextBox"
TextBox.__init__(self, **kwargs)
self.addKeyboardListener(self)
def setCompletionItems(self, items):
if not hasattr(items, 'getCompletionItems'):
items = SimpleAutoCompletionItems(items)
self.items = items
def getCompletionItems(self):
return self.items
def onKeyDown(self, arg0, arg1, arg2):
pass
def onKeyPress(self, arg0, arg1, arg2):
pass
def onKeyUp(self, arg0, arg1, arg2):
if arg1 == KeyboardListener.KEY_DOWN:
selectedIndex = self.choices.getSelectedIndex()
selectedIndex += 1
if selectedIndex >= self.choices.getItemCount():
selectedIndex = 0
self.choices.setSelectedIndex(selectedIndex)
return
if arg1 == KeyboardListener.KEY_UP:
selectedIndex = self.choices.getSelectedIndex()
selectedIndex -= 1
if selectedIndex < 0:
selectedIndex = self.choices.getItemCount() - 1
self.choices.setSelectedIndex(selectedIndex)
return
if arg1 == KeyboardListener.KEY_ENTER:
if self.visible:
self.complete()
return
if arg1 == KeyboardListener.KEY_ESCAPE:
self.choices.clear()
self.choicesPopup.hide()
self.visible = False
return
text = self.getText()
matches = []
if len(text) > 0:
matches = self.items.getCompletionItems(text)
if len(matches) > 0:
self.choices.clear()
for i in range(len(matches)):
self.choices.addItem(matches[i])
if len(matches) == 1 and matches[0] == text:
self.choicesPopup.hide()
else:
self.choices.setSelectedIndex(0)
self.choices.setVisibleItemCount(len(matches) + 1)
if not self.popupAdded:
RootPanel().add(self.choicesPopup)
self.popupAdded = True
self.choicesPopup.show()
self.visible = True
self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
self.choices.setWidth("%dpx" % self.getOffsetWidth())
else:
self.visible = False
self.choicesPopup.hide()
def onChange(self, arg0):
self.complete()
def onClick(self, arg0):
self.complete()
def complete(self):
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
class MenuCmd:
def __init__(self, menu, command):
self.menu = menu
self.command = command
def execute(self):
if self.command in ('Beginner', 'Intermediate', 'Expert', 'Custom'):
body = doc().getElementsByTagName('body').item(0)
body.setAttribute('id', self.command)
modes = {'New': [(0, 0), 0],
'Beginner': [(8, 8), 1],
'Intermediate': [(16, 16), 2],
'Expert': [(16, 32), 3]}
level = modes.get(self.command)
if level:
if level[1]:
self.menu.game.level = level[1]
self.menu.game.next_game(level[0])
elif self.command == 'Custom':
self.menu.game.level = 4
self.show_custom()
elif self.command == 'Instructions':
pass
elif self.command == 'About':
self.show_about()
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()
for each in (rows, columns, bombs, buttons):
contents.add(each)
rows.add(Label('Rows:'))
self.row = TextBox()
rows.add(self.row)
columns.add(Label('Columns:'))
self.column = TextBox()
columns.add(self.column)
bombs.add(Label('Bombs:'))
self.bomb = TextBox()
bombs.add(self.bomb)
buttons.add(Button("OK", getattr(self, 'new_game')))
buttons.add(Button("Cancel", getattr(self, 'close_dialog')))
left = (Window.getClientWidth() - 201) / 2
top = (Window.getClientHeight() - 190) / 2
self.dialog.setPopupPosition(left, top)
self.dialog.show()
def new_game(self, event):
try:
row = int(self.row.getText())
except:
Window.alert('Invalid number in rows')
return
try:
column = int(self.column.getText())
except:
Window.alert('Invalid number in columns')
return
try:
bomb = int(self.bomb.getText())
except:
bomb = 0
if bomb >= (row * column):
Window.alert("Number of bombs should not be greater than " \
"rows x columns.")
else:
self.menu.game.next_game((row, column), bomb)
self.close_dialog()
def close_dialog(self, event):
self.dialog.hide()
def show_about(self):
self.dialog = PopupPanel(StyleName='about', autoHide=True)
contents = HTMLPanel('', StyleName='contents')
self.dialog.setWidget(contents)
html = '<p class="pyjamas">MineSweeper written in Python with ' \
'<a href="http://pyjs.org" target="_blank">Pyjamas</a><p>' \
'<p class="comments">Send comments to ' \
'<a href="mailto:[email protected]">' \
'[email protected]</a>.<p>'
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from pyjamas.ui.PopupPanel import PopupPanel [as 别名]
# 或者: from pyjamas.ui.PopupPanel.PopupPanel import hide [as 别名]
class MenuCmd:
def __init__(self, menu, command):
self.menu = menu
self.command = command
def execute(self):
if self.command == 'New':
self.menu.game.restart()
if self.command in ('Beginner', 'Intermediate', 'Expert', 'Custom'):
body = doc().getElementsByTagName('body').item(0)
body.setAttribute('id', self.command)
levels = {'Beginner': [1, ( 8, 8)],
'Intermediate': [2, (16, 16)],
'Expert': [3, (16, 32)],
'Custom': [4]}
level_rc = levels[self.command]
self.menu.game.level = level_rc[0]
if level_rc[0] == 4:
self.show_custom()
else:
self.menu.game.next_game(*level_rc[1])
elif self.command == 'Instructions':
pass
elif self.command == 'About':
self.show_about()
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()
def new_game(self, sender):
try:
row = int(self.row.getText())
column = int(self.column.getText())
if not (2 <= row <= 50 and 2 <= column <= 50):
raise
except:
Window.alert('Valid numbers in row and column field are 2 - 50.')
return
bomb = self.bomb.getText()
if bomb:
try:
bomb = int(bomb)
if not (1 <= bomb <= row*column-2):
raise
except:
Window.alert('Valid numbers in bomb field are 1 to row*column-2.')
return
else:
bomb = self.menu.game.calculate_no_of_bomb(row, column)
self.menu.game.next_game(row, column, bomb)
self.close_dialog(sender)
def close_dialog(self, sender):
self.dialog.hide()
def show_about(self):
self.dialog = PopupPanel(StyleName='about', autoHide=True)
contents = HTMLPanel('', StyleName='contents')
self.dialog.setWidget(contents)
html = '<p class="pyjamas">MineSweeper written in Python with ' \
'<a href="http://pyjs.org" target="_blank">Pyjamas</a><p>' \
'<p class="comments">Send comments to ' \
'<a href="mailto:[email protected]">' \
'[email protected]</a>.<p>'
contents.setHTML(html)
left = (Window.getClientWidth() - 294) / 2
#.........这里部分代码省略.........