本文整理汇总了Python中surface.Surface.resize方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.resize方法的具体用法?Python Surface.resize怎么用?Python Surface.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resize
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import resize [as 别名]
def resize(self, width, height):
Surface.resize(self, width, height)
self.surface.resize(width, height)
try:
self.surface._display.textbox.resize()
except (TypeError, AttributeError): #pyjs-O:TypeError/-S:AttributeError
pass
try:
self.surface._display.textarea.resize()
except (TypeError, AttributeError): #pyjs-O:TypeError/-S:AttributeError
pass
示例2: Canvas
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import resize [as 别名]
class Canvas(Surface, MouseWheelHandler):
def __init__(self, size, buffered):
Surface.__init__(self, size)
MouseWheelHandler.__init__(self, True)
if isinstance(buffered, bool):
self._bufferedimage = buffered
else:
self._bufferedimage = True
try:
if self.impl.canvasContext:
self._isCanvas = True
except:
self._isCanvas = False
self._bufferedimage = False
if self._bufferedimage:
self.surface = Surface(size)
else:
self.surface = self
self.resize(size[0], size[1])
self.images = {}
self.image_list = []
self.function = None
self.time_wait = 0
self.time = Time()
self.event = pyjsdl.event
self.addMouseListener(self)
self.addMouseWheelListener(self)
self.addKeyboardListener(self)
self.sinkEvents(Event.ONMOUSEDOWN | Event.ONMOUSEUP| Event.ONMOUSEMOVE | Event.ONMOUSEOUT | Event.ONMOUSEWHEEL | Event.ONKEYDOWN | Event.ONKEYPRESS | Event.ONKEYUP)
self.modKey = pyjsdl.event.modKey
self.specialKey = pyjsdl.event.specialKey
self._rect_list = []
self._rect_list.append(Rect(0,0,0,0))
self._rect_len = 1
self._rect_num = 0
self._rect_temp = Rect(0,0,0,0)
_animationFrame = self._initAnimationFrame()
if _animationFrame:
self.time_hold_min = 0
else:
self.time_hold_min = 1
self.time_hold = self.time_hold_min
def _initAnimationFrame(self):
JS("""
$wnd['requestAnimationFrame'] = $wnd['requestAnimationFrame'] ||
$wnd['mozRequestAnimationFrame'] ||
$wnd['webkitRequestAnimationFrame'] ||
$wnd['oRequestAnimationFrame'];
""")
if JS("""$wnd['requestAnimationFrame'] != undefined"""):
_animationFrame = True
else:
JS("""$wnd['requestAnimationFrame'] = function(cb){cb()};""")
_animationFrame = False
return _animationFrame
def onMouseMove(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
event.pos = (x, y)
self.event.mouseMove['x'], self.event.mouseMove['y'] = x, y
self.event._updateQueue(event)
def onMouseDown(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
event.pos = (x, y)
self.event.mousePress[event.button] = True
self.event._updateQueue(event)
def onMouseUp(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
event.pos = (x, y)
self.event.mousePress[event.button] = False
self.event._updateQueue(event)
def onMouseLeave(self, sender):
self.event.mousePress[0], self.event.mousePress[1], self.event.mousePress[2] = False, False, False
self.event.mouseMove['x'], self.event.mouseMove['y'] = -1, -1
self.event.mouseMoveRel['x'], self.event.mouseMoveRel['y'] = None, None
for keycode in self.modKey:
if self.event.keyPress[keycode]:
self.event.keyPress[keycode] = False
def onMouseWheel(self, sender, velocity):
event = DOM.eventGetCurrentEvent()
if event.type == 'mousewheel':
#TODO: update for changes in mousewheel implementation
if hasattr(event, 'wheelDeltaX'):
self.onMouseWheel = self._onMouseWheel
self._onMouseWheel(sender, velocity)
else:
self.onMouseWheel = self._onMouseWheelY
DOM.eventGetMouseWheelVelocityY = eventGetMouseWheelVelocityY
self._onMouseWheelY(sender, eventGetMouseWheelVelocityY(event))
else: #DOMMouseScroll
self.onMouseWheel = self._onMouseScroll
self._onMouseScroll(sender, velocity)
def _onMouseWheel(self, sender, velocity):
#.........这里部分代码省略.........