Advertisement
akamad007

Main

Mar 22nd, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.94 KB | None | 0 0
  1. '''
  2. Created on Feb 6, 2015
  3.  
  4. @author: akash
  5. '''
  6. import sys
  7. from PyQt4 import QtGui
  8. from cam import camThread
  9.  
  10.  
  11.  
  12.  
  13.  
  14. class Rover(QtGui.QMainWindow):
  15.    
  16.     def __init__(self):
  17.         super(Rover, self).__init__()
  18.        
  19.         self.editText = MyTextEdit(self)
  20.         self.setCentralWidget(self.editText)
  21.         self.initUI()
  22.        
  23.     def initUI(self):      
  24.         pic = QtGui.QWidget(self)
  25.         pic.setGeometry(10, 10, 400, 240)
  26.        
  27.         pic.setStyleSheet("image:url(/home/akash/Downloads/bulls.jpg);background-repeat:repat; ")
  28.         pic.setAttribute(0,1);
  29.         pic.setAttribute(3,1);
  30.        
  31.         startButton = QtGui.QPushButton("Start Cam",self)
  32.         startButton.clicked.connect(self.startCam)
  33.         startButton.setGeometry(100,330,90,60)      
  34.         startButton.setStyleSheet("background:white;color:black; ")
  35.        
  36.         stopButton = QtGui.QPushButton("Stop Cam",self)
  37.         stopButton.clicked.connect(self.stopCam)
  38.         stopButton.setGeometry(240,330,90,60)
  39.         stopButton.setStyleSheet("background:white;color:black; ")
  40.                        
  41.         QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
  42.        
  43.         exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)        
  44.         exitAction.setShortcut('Ctrl+Q')
  45.         exitAction.setStatusTip('Exit application')
  46.         exitAction.triggered.connect(QtGui.qApp.quit)
  47.  
  48.         self.statusBar()
  49.  
  50.         menubar = self.menuBar()
  51.         fileMenu = menubar.addMenu('&File')
  52.         fileMenu.addAction(exitAction)                        
  53.          
  54.         self.setStyleSheet("margin:5px; background:#0079E4; ")
  55.         self.pic = pic
  56.         self.center()
  57.         self.resize(825, 600)
  58.         self.setWindowIcon(QtGui.QIcon('/home/akash/Downloads/bulls1.jpg'))
  59.         self.setWindowTitle('Ub - Rasc-Al')
  60.         self.show()
  61.         self.cam =None
  62.        
  63.     def changeText(self):
  64.         self.edit.setText("Some")
  65.        
  66.     def center(self):        
  67.         qr = self.frameGeometry()
  68.         cp = QtGui.QDesktopWidget().availableGeometry().center()
  69.         qr.moveCenter(cp)
  70.         self.move(qr.topLeft())
  71.          
  72.     def stopCam(self):
  73.         if(self.cam!=None):                            
  74.             self.cam.quit()
  75.             self.cam = None
  76.                
  77.     def startCam(self):
  78.        
  79.         if(self.cam==None):                      
  80.             self.cam = camThread(self.pic.winId())                                
  81.             self.cam.start()
  82.            
  83.         elif(self.cam.isRunning()):            
  84.             pass
  85.  
  86. class MyTextEdit(QtGui.QWidget):
  87.     def __init__(self,parent):
  88.         super(MyTextEdit, self).__init__(parent)                  
  89.         #self.show()
  90.        
  91. def main():
  92.    
  93.     app = QtGui.QApplication(sys.argv)
  94.     ex = Rover()
  95.    
  96.     sys.exit(app.exec_())
  97.  
  98.  
  99.  
  100.  
  101. if __name__ == '__main__':
  102.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement