def __init__(self, parent=None):
    super(Server, self).__init__(parent)
    statusLabel = QtWidgets.QLabel()
    quitButton = QtWidgets.QPushButton('Quit')
    quitButton.setAutoDefault(False)
    self.tcpServer = QtNetwork.QTcpServer(self)
    if (not self.tcpServer.listen()):
        QtWidgets.QMessageBox.critical(self, 'Fortune Server', ('Unable to start the server: %s.' % self.tcpServer.errorString()))
        self.close()
        return
    statusLabel.setText(('The server is running on port %d.\nRun the Fortune Client example now.' % self.tcpServer.serverPort()))
    self.fortunes = ("You've been leading a dog's life. Stay off the furniture.", "You've got to think about tomorrow.", 'You will be surprised by a loud noise.', 'You will feel hungry again in another hour.', 'You might have mail.', 'You cannot kill time without injuring eternity.', 'Computers are not intelligent. They only think they are.')
    quitButton.clicked.connect(self.close)
    self.tcpServer.newConnection.connect(self.sendFortune)
    buttonLayout = QtWidgets.QHBoxLayout()
    buttonLayout.addStretch(1)
    buttonLayout.addWidget(quitButton)
    buttonLayout.addStretch(1)
    mainLayout = QtWidgets.QVBoxLayout()
    mainLayout.addWidget(statusLabel)
    mainLayout.addLayout(buttonLayout)
    self.setLayout(mainLayout)
    self.setWindowTitle('Fortune Server')
def __init__(self, parent=None):
    super(Server, self).__init__(parent)
    statusLabel = QtWidgets.QLabel()
    quitButton = QtWidgets.QPushButton('Quit')
    quitButton.setAutoDefault(False)
    self.tcpServer = QtNetwork.QTcpServer(self)
    if (not self.tcpServer.listen()):
        QtWidgets.QMessageBox.critical(self, 'Fortune Server', ('Unable to start the server: %s.' % self.tcpServer.errorString()))
        self.close()
        return
    statusLabel.setText(('The server is running on port %d.\nRun the Fortune Client example now.' % self.tcpServer.serverPort()))
    self.fortunes = ("You've been leading a dog's life. Stay off the furniture.", "You've got to think about tomorrow.", 'You will be surprised by a loud noise.', 'You will feel hungry again in another hour.', 'You might have mail.', 'You cannot kill time without injuring eternity.', 'Computers are not intelligent. They only think they are.')
    quitButton.clicked.connect(self.close)
    self.tcpServer.newConnection.connect(self.sendFortune)
    buttonLayout = QtWidgets.QHBoxLayout()
    buttonLayout.addStretch(1)
    buttonLayout.addWidget(quitButton)
    buttonLayout.addStretch(1)
    mainLayout = QtWidgets.QVBoxLayout()
    mainLayout.addWidget(statusLabel)
    mainLayout.addLayout(buttonLayout)
    self.setLayout(mainLayout)
    self.setWindowTitle('Fortune Server')