本文整理汇总了Python中cube.Cube.redraw方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.redraw方法的具体用法?Python Cube.redraw怎么用?Python Cube.redraw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.redraw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Cubr
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import redraw [as 别名]
class Cubr(App):
def init(self):
self.resized = False
self.inCam = False
ctrlPaneHeight = 60
ctrlPaneColor = '#222222'
# Canvas for holding buttons
self.controlPane = Tkinter.Canvas(self.root, width = self.width,
height = ctrlPaneHeight, background=ctrlPaneColor)
# Event handlers for window resizing
self.controlPane.bind('<Configure>', self.controlResize)
self.canvas.bind('<Configure>', self.resize)
# Superclass deals with packing canvas
self.controlPane.pack(expand=1, fill=Tkinter.BOTH)
self.newCube()
def newCube(self):
# replaces self.cube with a new Cube() object
if hasattr(self, 'cube'):
self.cube.cleanup()
del self.cube
self.cube = Cube(self.canvas, self.controlPane, self)
def received(self, cube):
# callback handler for the screenGrabber module
# sets self.cube's configuration based on the Streamer cube
self.inCam = False
self.cube.helpState = self.cube.INGAME
if self.cube.debug:
print cube.events
try:
self.cube.setConfig(cube)
except:
# Something went wrong setting the configuration
self.cube.state.setSolved()
def fromCamera(self):
# Create "Starting webcam..." popup while we wait for webcam to turn on
self.canvas.create_rectangle(self.width/2 - 200, self.height/2 - 50,
self.width/2 + 200, self.height/2 + 50,
fill='#123456', outline='#abcdef', width=5)
self.canvas.create_text(self.width/2, self.height/2, fill='#ffffff',
font='Arial 36 bold', text='Starting webcam...')
self.canvas.update()
self.newCube()
self.inCam = True
# Hand over control to the screenGrabber
screenGrabber.cubeFromCam(app=self, callback=self.received)
def timerFired(self):
# cube.timer wrapper -- only calls if we are not in screenGrabber
if not self.inCam:
self.cube.timer()
def debug(self):
# toggle whether debug is on or off. this feature is disabled in release builds.
self.cube.debug = not self.cube.debug
self.cube.redraw()
def resize(self, event):
# Event binding for canvas resizing
self.width = event.width
self.height = event.height
self.resized = True
self.cube.width = self.width
self.cube.height = self.height
self.cube.camera.width = self.width
self.cube.camera.height = self.height
def mousePressed(self, event):
# Wrapper for cube.click
self.cube.click(event)
def controlResize(self, event):
# Event binding for controlPane resizing
# Adjust size, and compensate for border
borderX, borderY = -7, -6
self.controlPane.config(width=event.width+borderX,
height=event.height+borderY)
self.cube.configureControls(self.controlPane)
def keyPressed(self, event):
# key event handler
# Adjust viewmode. only available in debug.
if self.cube.debug:
if event.keysym == 'o':
self.cube.camera.fisheye(+1.2)
self.cube.redraw()
elif event.keysym == 'p':
self.cube.camera.fisheye(+0.8)
self.cube.redraw()
amt = self.cube.amt # Delta value for rotation sensitivity
#.........这里部分代码省略.........