Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import sys
- import threading
- import time
- from PIL import Image
- from PyQt4 import QtCore, QtGui
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
- import PyQt4.uic
- import PyQt4.Qt as qt
- import ImageQt
- app = QtGui.QApplication([])
- class cam(qt.QThread):
- def __init__(self,srv):
- qt.QThread.__init__(self)
- self.dlg = PyQt4.uic.loadUi("troja1.ui")
- self.pic = QPixmap()
- self.srv = srv
- self.dlg.show()
- def run(self):
- while 1:
- aaa = self.srv[0].recvfrom(9999)[0]
- if aaa:
- slika = Image.fromstring("RGB",(400,300),aaa)
- QtImage1 = ImageQt.ImageQt(slika)
- QtImage2 = QtGui.QImage(QtImage1)
- pixmap = QtGui.QPixmap.fromImage(QtImage2)
- pixmap2 = pixmap.scaled(QSize(400,300),Qt.KeepAspectRatio)
- self.dlg.label.setPixmap(pixmap2)
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- host = socket.gethostname()
- port = 444
- s.bind((host,port))
- s.listen(5)
- addr = s.accept()
- a = cam(addr)
- a.start()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement