Advertisement
unknown009

test

Oct 6th, 2015
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1.  
  2. from PyQt4.QtGui import *
  3. from PyQt4.QtCore import *
  4. from PyQt4 import QtGui
  5. from PyQt4 import QtCore
  6. from socket import *
  7. import thread,sys,select,string
  8.  
  9. HOST = '192.168.0.0'
  10. PORT = 5001
  11. BUFSIZE = 1024
  12. ADDR = (HOST, PORT)
  13.  
  14. tcpCliSock = socket(AF_INET, SOCK_STREAM)
  15. tcpCliSock.connect(ADDR)
  16.  
  17. class MainWindow(QtGui.QMainWindow):
  18. def __init__(self, parent=None):
  19. super(MainWindow, self).__init__(parent)
  20. self.thread = listener()
  21. self.thread.start()
  22.  
  23.  
  24. roomLabel = QtGui.QLabel('room')
  25.  
  26. self.browser = QtGui.QTextBrowser()
  27. self.browser.backwardAvailable
  28.  
  29. self.textEdit = QtGui.QTextEdit()
  30. self.textEdit.setMaximumSize(QtCore.QSize(400,60))
  31. #4 edit line
  32. self.connect(self.browser, QtCore.SIGNAL("returnPressed()"),self.callback)
  33.  
  34. SendButton = QtGui.QPushButton('Send')
  35. SendButton.setMaximumSize(QtCore.QSize(400,60))
  36. SendButton.clicked.connect(self.callback)
  37.  
  38.  
  39.  
  40.  
  41. layoutINlayout = QtGui.QHBoxLayout()
  42. layoutINlayout.addWidget(self.textEdit)
  43. layoutINlayout.addWidget(SendButton)
  44.  
  45.  
  46. widget = QtGui.QWidget()
  47. self.setCentralWidget(widget)
  48.  
  49. self.layout = QtGui.QVBoxLayout()
  50. self.layout.addWidget(self.browser)
  51.  
  52. mainwindow = QtGui.QVBoxLayout()
  53. mainwindow.addLayout (self.layout )
  54. mainwindow.addLayout (layoutINlayout )
  55.  
  56. widget.setLayout(mainwindow)
  57. self.setWindowFlags(QtCore.Qt.WindowTitleHint )
  58.  
  59. def callback(self, event):
  60.  
  61. message = self.textEdit.toPlainText()
  62. tcpCliSock.send(message)
  63. self.browser.setText(message)
  64.  
  65.  
  66.  
  67. class listener(QThread):
  68. def __init__(self):
  69. QThread.__init__(self)
  70. self.exiting = False
  71.  
  72. def __del__(self):
  73. self.exiting = True
  74. self.wait()
  75.  
  76.  
  77. def add(self, data):
  78. window.browser.setText(data)
  79.  
  80. def run(self):
  81.  
  82.  
  83. print 'Connected to remote host. Start sending messages'
  84.  
  85. while 1:
  86. data = tcpCliSock.recv(BUFSIZE)
  87. if data:
  88. self.add(data)
  89. if __name__ == '__main__':
  90.  
  91. app = QtGui.QApplication(sys.argv)
  92. app.setStyle('chat')
  93.  
  94.  
  95. window = MainWindow()
  96. window.setWindowTitle("pro IJ cracker v2")
  97. window.setWindowIcon(QtGui.QIcon("img/go.png"))
  98. window.show()
  99. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement