本文整理汇总了Python中pyui.desktop.getRenderer函数的典型用法代码示例。如果您正苦于以下问题:Python getRenderer函数的具体用法?Python getRenderer怎么用?Python getRenderer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getRenderer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
def init():
pyui.init(width, height, "p3d", fullscreen=0, title="CodeWorld")
getRenderer().setBackMethod(render)
getDesktop().registerHandler(pyui.locals.KEYDOWN, keyDown)
pygame.key.set_repeat(500, 30)
initGL()
示例2: destroy
def destroy(self):
if self.handle:
getRenderer().destroyWindow(self.handle)
self._panel = None
self.handle = 0
self.drawList = []
Base.destroy(self)
示例3: __init__
def __init__(self, title, text, DialogType): #DialogType 0: Ok - Cancel || 1: Ok
size = getRenderer().getTextSize(title)
Dialog.__init__(self, title = title)
self.setLayout(pyui.layouts.BorderLayoutManager())
self.textLabel = pyui.widgets.Label(text)
self.textLabel.setText(text)
self.buttonPanel = pyui.widgets.Panel()
self.buttonPanel.setLayout(pyui.layouts.BorderLayoutManager())
if DialogType == 0:
self.okButton = pyui.widgets.Button("OK", self._pyuiOK)
self.okButton.resize(self.innerWidth/2, self.okButton.height)
self.cancelButton = pyui.widgets.Button("Cancel", self._pyuiCancel)
self.cancelButton.resize(self.innerWidth/2, self.cancelButton.height)
self.buttonPanel.addChild(self.okButton, locals.WEST)
self.buttonPanel.addChild(self.cancelButton, locals.EAST)
self.buttonPanel.pack()
if DialogType == 1:
self.okButton = pyui.widgets.Button("OK", self._pyuiOK)
self.buttonPanel.addChild(self.okButton, locals.SOUTH)
self.buttonPanel.pack()
self.addChild(self.textLabel, locals.CENTER)
self.addChild(self.buttonPanel, locals.SOUTH)
self.pack()
示例4: resize
def resize(self, w, h):
pyui.widgets.Base.resize(self, w,h)
self.vscroll.resize(getTheme().getScrollerSize(), h)
self.vscroll.moveto(w-getTheme().getScrollerSize(), 0)
self.textWidth = self.width - self.vscroll.width
self.numVisible = self.height / getRenderer().getTextSize("x")[1]
self.rewrap = 1
示例5: scrollToCursor
def scrollToCursor(self):
(x,y,w,h) = self.windowRect
font_width, font_heigth = getRenderer().getTextSize( ' ', self.font )
grid_width, grid_height = self.getGrid()
caretPos = self.caretPos + ( 7 * self.text.count( '\t', 0, self.caretPos ) )
text = self.text.expandtabs( 8 )
row = text.count( '\n', 0, caretPos )
if row > 0: col = caretPos - text.rfind( '\n', 0, caretPos ) -1
else: col = caretPos
adj = (caretPos == len( text ) or text[caretPos] == '\n') and 1 or 0
if col - adj < self.scroll[0]:
self.scroll = max( col - adj, 0 ), self.scroll[1]
elif col > self.scroll[0] + grid_width:
self.scroll = col - grid_width, self.scroll[1]
if row < self.scroll[1]:
self.scroll = self.scroll[0], row
elif row >= self.scroll[1] + grid_height:
self.scroll = self.scroll[0], row - grid_height + 1
self.updateScrollBars()
示例6: clear
def clear(self):
self.lines = []
self.displayLines = []
self.numVisible = self.height / getRenderer().getTextSize("x")[1]
self.numItems = 0
self.topItem = 0
self.rewrap = 0
示例7: findMousePos
def findMousePos(self, pos):
# put hit position in window relative coords
x = pos[0] - self.rect[0] - 2
y = pos[1] - self.rect[1] - 5
font_width, font_heigth = getRenderer().getTextSize( ' ', self.font )
col = max( math.floor( (float(x) / float(font_width)) ) + self.scroll[0], 0 )
row = max( math.floor( (float(y) / float(font_heigth)) ) + self.scroll[1], 0 )
r, c, i = 0, 0, 0
while r != row:
try: i = self.text.index( '\n', i ) + 1
except: break
r += 1
while c < col:
if i >= len( self.text) or self.text[i] == '\n':
break
elif self.text[i] == '\t':
if ( c + 4 > col ): break
c += 8
else:
c += 1
i += 1
return min( max( i, 0 ), len( self.text ) )
示例8: __init__
def __init__( self, text = '' ):
pyui.widgets.Base.__init__(self)
self.text = text
self.caretPos = 0
self.selectPos = 0
self.dragging = 0
self.readonly = 0
self.font = getRenderer().createFont("courier", 12, 0)
self.scroll = 0, 0
self.vscroll = pyui.widgets.VScroll()
self.addChild( self.vscroll )
self.hscroll = pyui.widgets.HScroll()
self.addChild( self.hscroll )
self.registerEvent(pyui.locals.SCROLLPOS, self._pyuiScrollPos)
self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)
self.registerEvent(pyui.locals.KEYUP, self._pyuiKeyUp)
self.registerEvent(pyui.locals.CHAR, self._pyuiChar)
self.registerEvent(pyui.locals.LMOUSEBUTTONDOWN, self._pyuiMouseDown)
self.registerEvent(pyui.locals.LMOUSEBUTTONUP, self._pyuiMouseUp)
self.registerEvent(pyui.locals.MOUSEMOVE, self._pyuiMouseMotion)
self.registerEvent(pyui.locals.CLICKED, self._pyuiClicked)
self.resize( 100, 100 )
示例9: __init__
def __init__(self, x, y, handler, game):
pyui.widgets.Button.__init__(self,"", handler)
self.registerEvent(RMOUSEBUTTONDOWN, self.onMined)
self.x = x
self.y = y
self.game = game
self.reset()
self.grey = getRenderer().packColor( 150, 150, 50 )
示例10: __init__
def __init__(self, x, y, w, h, topmost = 0):
self._panel = Panel()
Base.__init__(self)
self.topMost = topmost
self._panel.moveto(0,0)
# the content panel is added as a child through Base::addChild to avoid recursively adding it to itself
Base.addChild(self, self._panel)
self._panel.setWindow(self)
self.drawCommands = []
# these are drawing callbacks to draw _after_ all the widgets are drawn
self.drawLastCallbacks = []
if self.__dict__.has_key("title"):
self.handle = getRenderer().createWindow(self.title)
else:
self.handle = getRenderer().createWindow("")
self.moveto(x, y)
self.resize(w, h)
getDesktop().addWindow(self)
示例11: __init__
def __init__(self, handler, text, subMenu):
self.handler = handler
self.text = text
(width, height) = getRenderer().getTextSize(text, getTheme().defaultFont)
self.width = width
self.subMenu = subMenu
self.icon = None
self.rect = (0,0,0,0)
self.canActivate = handler or subMenu
示例12: _pyuiMouseMotion
def _pyuiMouseMotion(self, event):
if self.moving:
mouseX = event.pos[0] - self.posX
mouseY = event.pos[1] - self.posY
self.frameMove( mouseX - self.startX, mouseY - self.startY)
getRenderer().moveWindow(self.handle, self.posX, self.posY)
return 1
if self.resizing:
mouseX = event.pos[0] - self.posX
mouseY = event.pos[1] - self.posY
if mouseX < 64:
mouseX = 64
if mouseY < 64:
mouseY = 64
self.frameResize( self.width + mouseX - self.startX, self.height + mouseY - self.startY)
(self.startX, self.startY) = (mouseX, mouseY)
return 1
# set the proper cursor
regionId = self.hitFrameRegion(event.pos)
if regionId == pyui.locals.HIT_FRAME_RESIZE_BOTTOM_RIGHT:
self.resizingCursor=1
self.theme.setResizeCursor()
elif self.resizingCursor:
self.resizingCursor=0
self.theme.setArrowCursor()
if regionId == pyui.locals.HIT_FRAME_MOVE:
self.movingCursor = 1
self.theme.setMovingCursor()
elif self.movingCursor:
self.movingCursor = 0
self.theme.setArrowCursor()
if not self.hit(event.pos):
if self.resizingCursor and not self.resizing:
self.resizingCursor=0
self.theme.setArrowCursor()
if self.movingCursor and not self.moving:
self.movingCursor=0
self.theme.setArrowCursor()
return 0
else:
return 1
示例13: drawMenuBarItem
def drawMenuBarItem(self, rect, title, selected):
title = " " + title + " "
(w,h) = getRenderer().getTextSize(title, self.defaultFont)
if selected:
getRenderer().drawRect(self.bgColor3, (rect[0], rect[1], w, rect[3]))
getRenderer().drawText(title, (rect[0], rect[1]), self.fgColor, self.defaultFont)
else:
getRenderer().drawText(title, (rect[0], rect[1]), self.fgColor, self.defaultFont)
return (rect[0], rect[1], w, rect[3])
示例14: drawListBoxItem
def drawListBoxItem(self, rect, title, selected, color):
if selected:
getRenderer().drawRect(self.bgColor3, (rect[0] +2, rect[1] - 1, rect[2]- 1 - 3, rect[3] ))
getRenderer().drawText(title, (rect[0]+2, rect[1]), self.fgColor, self.defaultFont)
else:
getRenderer().drawText(title, (rect[0]+2, rect[1]), color, self.defaultFont)
return rect
示例15: __init__
def __init__(self):
pyui.widgets.Base.__init__(self)
#self.bgColor = (0,0,49, 255)
self.lines = []
self.displayLines = []
self.numVisible = self.height / getRenderer().getTextSize("x")[1]
self.numItems = 0
self.topItem = 0
self.rewrap = 0
self.textWidth = 0
self.vscroll = pyui.widgets.VScroll()
self.addChild(self.vscroll)
self.registerEvent(locals.SCROLLPOS, self._pyuiScrollPos)