<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> '''<STR_LIT>''' <EOL> import sys <EOL> import demo <EOL> import pi3d <EOL> import numpy as np <EOL> from PyQt4 import QtGui <EOL> from PyQt4 import QtCore <EOL> W , H = <NUM_LIT> , <NUM_LIT> <EOL> FPS = <NUM_LIT:20> <EOL> class QtWindow ( QtGui . QWidget ) : <EOL> def __init__ ( self ) : <EOL> super ( QtWindow , self ) . __init__ ( ) <EOL> '''<STR_LIT>''' <EOL> self . DISPLAY = pi3d . Display . create ( w = W , h = H , layer = - <NUM_LIT> ) <EOL> shader = pi3d . Shader ( '<STR_LIT>' ) <EOL> tex = pi3d . Texture ( '<STR_LIT>' ) <EOL> self . cube = pi3d . Cuboid ( z = <NUM_LIT:2> ) <EOL> self . cube . set_draw_details ( shader , [ tex ] ) <EOL> self . cube . show_flag = True <EOL> self . cube . last_x = None <EOL> self . cube . last_y = None <EOL> self . initUI ( ) <EOL> def initUI ( self ) : <EOL> button1 = QtGui . QPushButton ( '<STR_LIT>' ) <EOL> button1 . clicked . connect ( self . rotX ) <EOL> button2 = QtGui . QPushButton ( '<STR_LIT>' ) <EOL> button2 . clicked . connect ( self . rotY ) <EOL> button3 = QtGui . QPushButton ( '<STR_LIT>' ) <EOL> button3 . clicked . connect ( self . rotZ ) <EOL> message = QtGui . QLabel ( '<STR_LIT>' ) <EOL> vbox = QtGui . QVBoxLayout ( ) <EOL> vbox . addWidget ( button1 ) <EOL> vbox . addWidget ( button2 ) <EOL> vbox . addWidget ( button3 ) <EOL> vbox . addWidget ( message ) <EOL> vbox . addStretch ( <NUM_LIT:1> ) <EOL> self . img = QtGui . QLabel ( '<STR_LIT:image>' ) <EOL> a = np . zeros ( ( H , W , <NUM_LIT:4> ) , dtype = np . uint8 ) <EOL> im = QtGui . QImage ( a , W , H , QtGui . QImage . Format_RGB888 ) <EOL> self . img . setPixmap ( QtGui . QPixmap . fromImage ( im ) ) <EOL> hbox = QtGui . QHBoxLayout ( ) <EOL> hbox . addLayout ( vbox ) <EOL> hbox . addWidget ( self . img ) <EOL> hbox . addStretch ( <NUM_LIT:1> ) <EOL> self . setLayout ( hbox ) <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> self . show ( ) <EOL> def pi3d_loop ( self ) : <EOL> self . DISPLAY . loop_running ( ) <EOL> if self . cube . show_flag : <EOL> self . cube . draw ( ) <EOL> im = QtGui . QImage ( pi3d . screenshot ( ) , W , H , QtGui . QImage . Format_RGB888 ) <EOL> self . img . setPixmap ( QtGui . QPixmap . fromImage ( im ) ) <EOL> self . cube . show_flag = False <EOL> def rotX ( self ) : <EOL> self . cube . rotateIncX ( <NUM_LIT> ) <EOL> self . cube . show_flag = True <EOL> def rotY ( self ) : <EOL> self . cube . rotateIncY ( <NUM_LIT> ) <EOL> self . cube . show_flag = True <EOL> def rotZ ( self ) : <EOL> self . cube . rotateIncZ ( <NUM_LIT> ) <EOL> self . cube . show_flag = True <EOL> def mousePressEvent ( self , QMouseEvent ) : <EOL> cursor = QtGui . QCursor ( ) <EOL> self . cube . last_x = cursor . pos ( ) . x ( ) <EOL> self . cube . last_y = cursor . pos ( ) . y ( ) <EOL> def mouseMoveEvent ( self , QMouseEvent ) : <EOL> cursor = QtGui . QCursor ( ) <EOL> x = cursor . pos ( ) . x ( ) <EOL> y = cursor . pos ( ) . y ( ) <EOL> self . cube . rotateIncY ( self . cube . last_x - x ) <EOL> self . cube . rotateIncX ( self . cube . last_y - y ) <EOL> self . cube . last_x = x <EOL> self . cube . last_y = y <EOL> self . cube . show_flag = True <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> win = QtWindow ( ) <EOL> timer = QtCore . QTimer ( ) <EOL> timer . timeout . connect ( win . pi3d_loop ) <EOL> msfps = int ( <NUM_LIT:1000> / FPS ) <EOL> timer . start ( msfps ) <EOL> sys . exit ( app . exec_ ( ) ) </s>
