def __init__(self, port, serverHost=None, serverPort=11111): self.tcpServer = QtNetwork.QTcpServer() if not self.tcpServer.listen(QtNetwork.QHostAddress.Any, port): print 'Could not list on port %d' % port return self.tcpServer.newConnection.connect(self.acceptClient) self.timer = QtCore.QTimer() self.timer.setSingleShot(True) self.timer.timeout.connect(self.render) if serverHost: pvsimple.Connect(serverHost, serverPort) self.createPipeline() self.setupManipulators() self.widget = \ QVTKRenderWindowInteractor.QVTKRenderWindowInteractor(\ rw=self.renderView.GetRenderWindow(), iren=self.renderView.GetInteractor()) self.widget.Initialize() self.widget.Start() self.widget.show() pvsimple.Render(self.renderView)
def __init__(self, x, y, width, height, rpm, scene_server_port): """ Args: x (float): x coordinate of the scene's origin (in world coordinate system, meters). y (float): dtto. width (float): Width of the scene. height (float): dtto rpm (int): Resolution per meter (pixels per meter of width/height). """ super(UICore, self).__init__() self.x = x self.y = y self.width = width self.height = height self.port = scene_server_port w = self.width * rpm h = self.height / self.width * w self.scene = QtGui.QGraphicsScene(0, 0, int(w), int(h)) self.scene.rpm = rpm self.scene.setBackgroundBrush(QtCore.Qt.black) # self.scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex) # should # be good for dynamic scenes self.bottom_label = LabelItem(self.scene, 0.30, 0.07, self.width - 0.2, 0.03) self.selected_object_ids = [] self.selected_object_types = [] self.view = customGraphicsView(self.scene) self.view.setRenderHint(QtGui.QPainter.Antialiasing) self.view.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate) self.view.setStyleSheet("QGraphicsView { border-style: none; }") self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(port=self.port): rospy.logerr('Failed to start scene TCP server on port ' + str(self.port)) self.tcpServer.newConnection.connect(self.new_connection) self.connections = [] self.scene_timer = QtCore.QTimer() self.connect(self.scene_timer, QtCore.SIGNAL('timeout()'), self.send_to_clients_evt) self.scene_timer.start(1.0 / 15 * 1000) self.sound_info_srv = rospy.ServiceProxy("/art/interface/sound/info", Empty) self.sound_warning_srv = rospy.ServiceProxy( "/art/interface/sound/warning", Empty) rospy.loginfo("Waiting for sound services...") self.sound_info_srv.wait_for_service() self.sound_warning_srv.wait_for_service()
def newServer(self): self.server = QtNetwork.QTcpServer() QtCore.QObject.connect(self.server, QtCore.SIGNAL('newConnection()'), self.newConnect) if self.server.listen(port = 8765): self.label1.setText('Server active') else: self.label1.setText('Error')
def __init__(self, parent): QtCore.QObject.__init__(self, parent) self.host2ip = {} self.ip2host = {} self.last_calc = time.time() self.pilotsHistory = {} self.timer = QtCore.QTimer(self) self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.on_timer) self.dnsLookupThread = DnsLookupThread(self) self.connect(self.dnsLookupThread, QtCore.SIGNAL("domain_found"), self.on_domain_found) #def run(self): self.dnsLookupThread.start() self.timer.start(1000) self.telnetString = {} self.telnetTimer = {} self.telnetSocket = {} self.lastUpdate = None self.server = QtNetwork.QTcpServer(self) self.connect(self.server, QtCore.SIGNAL("newConnection()"), self.on_websocket_connection) self.server.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any), 5050) self.clientSockets = {} self.increment = 0
def __init__(self, main, port=1787): logger.info('Initialize tcp server at port %s...' % port) super(qpServer, self).__init__() self.main = main self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(QtNetwork.QHostAddress.LocalHost, port): logger.warning("Unable to start the server: %s." % self.tcpServer.errorString()) return self.tcpServer.newConnection.connect(self.on_new_connection)
def __init__(self, remote_port, local_port, parent=None): """ Constructor """ QtCore.QObject.__init__(self, parent) self.remote_port = remote_port self.local_port = local_port self.remote_server = QtNetwork.QTcpServer(self) self.local_server = QtNetwork.QTcpServer(self) self.merger = SocketMerger(self) self.remote_socket = None self.local_socket = None self.remote_server.newConnection.connect(self.remoteConnection, QtCore.Qt.QueuedConnection) self.local_server.newConnection.connect(self.localConnection, QtCore.Qt.QueuedConnection) self.merger.disconnected.connect(self.run, QtCore.Qt.QueuedConnection) pass
def __init__(self, x, y, width, height, rpm, scene_server_port): super(ExampleGui, self).__init__() self.x = x self.y = y self.width = width self.height = height self.port = scene_server_port w = self.width * rpm h = self.height / self.width * w self.scene = QtGui.QGraphicsScene(0, 0, int(w), int(h)) self.scene.rpm = rpm self.scene.setBackgroundBrush(QtCore.Qt.black) self.view = customGraphicsView(self.scene) self.view.setRenderHint(QtGui.QPainter.Antialiasing) self.view.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate) self.view.setStyleSheet("QGraphicsView { border-style: none; }") self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(port=self.port): rospy.logerr( 'Failed to start scene TCP server on port ' + str(self.port)) self.tcpServer.newConnection.connect(self.new_connection) self.connections = [] self.scene_timer = QtCore.QTimer() self.connect( self.scene_timer, QtCore.SIGNAL('timeout()'), self.send_to_clients_evt) self.scene_timer.start(1.0 / 15 * 1000) self.projectors = [ProjectorHelper("n2")] rospy.loginfo("Waiting for projector nodes...") for proj in self.projectors: proj.wait_until_available() if not proj.is_calibrated(): rospy.loginfo("Starting calibration of projector: " + proj.proj_id) proj.calibrate(self.calibrated_cb) else: rospy.loginfo("Projector " + proj.proj_id + " already calibrated.") self.text = QtGui.QGraphicsTextItem("Hello world!", None, self.scene) self.text.setFont(QtGui.QFont('Arial', 48)) self.text.setDefaultTextColor(QtCore.Qt.white) rospy.loginfo("Ready")
def start(self): self.messageEmited.emit("NGQ Manager", "Initialization" + "...", QtGui.QSystemTrayIcon.Information, 100) self.tcpServer = QtNetwork.QTcpServer() self.tcpServer.listen(QtNetwork.QHostAddress(self.__host), self.__port) self.tcpServer.newConnection.connect(self.__newConnectionHandle) self.configure() self.ngqListChanged.connect(self.__chooseWaitingTasksForProject) self.__putToWaitingTasks(partial(self.executeArgs, self.__argString), None, self.__initializationTime)
def __init__(self, port): super(Broadcaster, self).__init__() self.__clients = [] self.__tcpServer = QtNetwork.QTcpServer() if not self.__tcpServer.listen(QtNetwork.QHostAddress.LocalHost, port): raise Exception('Could not initialize socket server.') else: pass #print 'Server listening on %s' % port self.__tcpServer.newConnection.connect(self.registerClient)
def main(): try: import FreeCAD except ValueError: print( 'FreeCAD library not found. Please check the FREECADPATH variable in this script is correct' ) sys.exit(1) simapp = QtGui.QApplication(sys.argv) simappwindow = QtGui.QMainWindow() simappwindow.setWindowTitle("EQ Simulator") s = None s = Simulator.Simulator() s.Build() manualsettingswidget = DockManualSetting(s) simulationwidget = DockSimulation(s, manualsettingswidget) simappwindow.addDockWidget(QtCore.Qt.BottomDockWidgetArea, manualsettingswidget) simappwindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, simulationwidget) # FreeCAD integration: see http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Embedding_FreeCADGui/fr # Utilisation d'un module tiers (en l'occurence Quarter ?) #FreeCADGui.setupWithoutGUI() widget3D = QtGui.QWidget() widget3D.setMinimumSize(712, 400) qw = QuarterWidget(widget3D) qw.setMinimumSize(712, 400) qw.setSceneGraph(s.scene) #Http server #server=BaseHTTPServer.HTTPServer(('', 8000), HTTPHandler) #server.serve_forever() #TCP Server server = QtNetwork.QTcpServer() server.setMaxPendingConnections(1) server.currentClient = None server.newConnection.connect( lambda: acceptClient(server, simulationwidget.process_config)) server.listen(QtNetwork.QHostAddress.Any, 64101) #s.Embed(widget3D) simappwindow.setCentralWidget(widget3D) simappwindow.show() #SoGui.mainloop() simapp.exec_()
def __init__(self, parent): QtCore.QObject.__init__(self, parent) self.connections = [] self.threads = [] self.count = 0 self.server = QtNetwork.QTcpServer(self) #FIXME #tcp_address = QtNetwork.QHostAddress.Any tcp_address = QtNetwork.QHostAddress("192.168.0.146") tcp_port = 1137 self.connect(self.server, QtCore.SIGNAL("newConnection()"), self.socket_connected) self.server.listen(tcp_address, tcp_port) parent.txtSocket.setPlainText( "RiiFS Python Server is now ready for connections on 1137")
def __init__(self): QtCore.QObject.__init__(self) self.tcpServer = QtNetwork.QTcpServer(self) self.clientConnection = None self.leftovers = "" self.readlength = 0 self.connect(self.tcpServer, QtCore.SIGNAL("newConnection()"), self.newConnection) global server server = self self.tm = TaskManager(self) self.timer = QtCore.QTimer() self.status = None self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.refresh)
def __init__(self, ui, parameters): super(ScenePublisherPlugin, self).__init__(ui) self.port = 1234 # TODO read from param self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(port=self.port): rospy.logerr('Failed to start scene TCP server on port ' + str(self.port)) self.tcpServer.newConnection.connect(self.new_connection) self.connections = [] self.scene_timer = QtCore.QTimer() self.connect(self.scene_timer, QtCore.SIGNAL('timeout()'), self.send_to_clients_evt) self.scene_timer.start(1.0 / 15 * 1000)
def configureNetwork(self): #self.blockSize = 0 self.socket = QtNetwork.QTcpServer() self.socket.name = 'ThinkGear Server' if self.DEBUG: print "<---- [%s] Initializing server on %s:%i" % \ (self.socket.name, self.server_interface, self.server_port) if ((self.server_interface == '') or \ (self.server_interface == '*')): address = QtNetwork.QHostAddress.Any else: #address=self.server_interface address = QtNetwork.QHostAddress(self.server_interface) result = self.socket.listen(address, self.server_port) if not result: try: QtGui.QMessageBox.information( \ self.parent, \ self.socket.name, \ "Unable to start the server on %s:%i" % \ (self.server_interface, self.server_port)) except: pass if self.DEBUG: print "ERROR [%s] Unable to start the server:" % self.socket.name, print self.socket.errorString() #self.parent.stopThinkGearConnectServer() #self.parent.pushButtonThinkGearConnect.nextCheckState() #self.parent.pushButtonThinkGearConnect.toggle() #self.parent.pushButtonThinkGearConnect.test.emit(QtCore.SIGNAL("clicked()")) self.socket.close() return self.socket.newConnection.connect(self.processConnection)
def __init__(self, parent=None): global server_start_port QtCore.QObject.__init__(self, parent) # Create a channel with a unique id self.id = str(uuid.uuid1()) self.port = server_start_port self.pdu_number = 0 server_start_port += 1 self.create_udp_socket() self.tcp_server = QtNetwork.QTcpServer(self) # mapping from (channel_id) to a list of (client_id, tcp_socket) self.channels = {} # mapping from (QHostAddress -> address) to (str -> client_id) self.users = {} # mapping from (QHostAddress -> address) to (QTimer -> timer) self.users_timers = {} if not self.tcp_server.listen(QtNetwork.QHostAddress.Any, self.port): log.error("Unable to start the server: %s." % self.tcp_server.errorString()) # Hint: IP: 0.0.0.0 means ANY address = self.tcp_server.serverAddress().toString() port = self.tcp_server.serverPort() log.debug("Server is running with address %s and port %s" % (address, port)) # do something, when we are connected self.tcp_server.newConnection.connect(self.handle_connection) # setup the regular_pdu_timer for the regular pdu self.regular_pdu_timer = QtCore.QTimer() self.regular_pdu_timer.timeout.connect(self.send_regular_pdu) self.regular_pdu_timer.start(self.REGULAR_PDU_WAITING_TIME) self.tcp_sockets = []
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self.tcpServer = QtNetwork.QTcpServer() self.tcpClient = QtNetwork.QTcpSocket() self.bytesToWrite = 0 self.bytesWritten = 0 self.bytesReceived = 0 self.clientProgressBar = QtGui.QProgressBar() self.clientStatusLabel = QtGui.QLabel("Client ready") self.serverProgressBar = QtGui.QProgressBar() self.serverStatusLabel = QtGui.QLabel("Server ready") self.startButton = QtGui.QPushButton("&Start") self.quitButton = QtGui.QPushButton("&Quit") buttonBox = QtGui.QDialogButtonBox() buttonBox.addButton(self.startButton, QtGui.QDialogButtonBox.ActionRole) buttonBox.addButton(self.quitButton, QtGui.QDialogButtonBox.RejectRole) self.startButton.clicked.connect(self.start) self.quitButton.clicked.connect(self.close) self.tcpServer.newConnection.connect(self.acceptConnection) self.tcpClient.connected.connect(self.startTransfer) self.tcpClient.bytesWritten.connect(self.updateClientProgress) self.tcpClient.error.connect(self.displayError) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.clientProgressBar) mainLayout.addWidget(self.clientStatusLabel) mainLayout.addWidget(self.serverProgressBar) mainLayout.addWidget(self.serverStatusLabel) mainLayout.addStretch(1) mainLayout.addSpacing(10) mainLayout.addWidget(buttonBox) self.setLayout(mainLayout) self.setWindowTitle("Loopback")
def __init__(self, parent=None): super(Server, self).__init__(parent) statusLabel = QtGui.QLabel() quitButton = QtGui.QPushButton("Quit") quitButton.setAutoDefault(False) self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(): QtGui.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 = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(quitButton) buttonLayout.addStretch(1) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(statusLabel) mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.setWindowTitle("Fortune Server")
def __init__(self, dbConnectionName, parent=None): super(CEQViewer, self).__init__(parent) self._db = QtSql.QSqlDatabase.database(dbConnectionName) try: from PyQt4 import QtNetwork self._notifyTCPServer = QtNetwork.QTcpServer(self) except: self._notifyTCPServer = None if self._notifyTCPServer: self._notifyTCPServer.newConnection.connect( self.onNewNotifyConnection) self._notifiers = {} # словарь QTCPSocket объектов self._notifierReadyReadMapper = QtCore.QSignalMapper() self._notifierReadyReadMapper.mapped.connect(self.onNotifyReadyRead) self._notifierDisconnectedMapper = QtCore.QSignalMapper() self._notifierDisconnectedMapper.mapped.connect( self.onNotifierDisconnected) self._notifyREPattern = re.compile(ur'queueTypeId=(\d+);') self._newNotifierIdx = 0 self._viewedEQTypeModel = CEQViewedTypeModel(self._db, self) self._updateModelsTimerId = None self._updateTimeout = 1.0 self._viewerWindow = None self._rowCount = 1 self._columnCount = 1 self._maxTicketCount = 6 self._notifyPort = 0
def __init__(self, *args): super(RadMon, self).__init__(*args) self.ui = Ui_simwin() self.ui.setupUi(self) self.sendT = QtCore.QTimer(self) self.sendT.setSingleShot(False) self.sendT.timeout.connect(self.tick) self.servSock = QtNetwork.QTcpServer(self) self.socks = set() self.servSock.newConnection.connect(self.newConn) self.failcnt = 60 self.nextaddr = 0 self.hvpdata = -1 self.rate = 0 self.alrmlow = False self.alrmhigh = False self.alrmdose = False self.alrm3 = False self.alarmrateoflow = False # dose rate overflow self.alarmdoseoflow = False # integrated dose overflow (total range) self.alarmbucketoflow = False # int. dose bucket overflow self.EE = eeprom() self.ui.eeprom.setModel(self.EE) self.updateLevels() self.ui.vlevel1.editingFinished.connect(self.updateLevels) self.ui.vlevel2.editingFinished.connect(self.updateLevels) self.ui.vlevel3.editingFinished.connect(self.updateLevels) self.ui.btnInj.clicked.connect(self.sendByte) self.servSock.listen(QtNetwork.QHostAddress.LocalHost, 4001) self.sendT.start(1000)
def __init__(self, parent=None): super(ServerTCP, self).__init__(parent) #IP adress, PORT, HOST try: self.ip = [ (s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)] ][0][1] except: self.ip = IP self.port = PORT self.host = QtNetwork.QHostAddress(self.ip) #TCP Server self.server = QtNetwork.QTcpServer(self) self.server.newConnection.connect(self.on_new_connection) if not self.server.listen(address=self.host, port=self.port): QtGui.QMessageBox.critical( self, "Server", "Unable to start server. Maybe it's already running") self.close() return #Process self.process = QtCore.QProcess() self.process.finished.connect(self.try_process) self.wasKill = False self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels) self.process.readyRead.connect(self.display_output) #Transfer self.processSync = QtCore.QProcess() self.processSync.finished.connect(self.try_sync) #dealing with the klusta environment env = QtCore.QProcess.systemEnvironment() itemToReplace = [item for item in env if item.startswith('PATH=')] for item in itemToReplace: newitem = item.replace('/anaconda/bin:', '/anaconda/envs/klusta/bin:') env.remove(item) env.append(newitem) env.append("CONDA_DEFAULT_ENV=klusta") self.process.setEnvironment(env) #console self.console = ConsoleView(self) #model and clients self.clientDict = {} self.model = ExperimentModelServer(self) self.model.expStateChanged.connect(self.update_one_client) self.model.expDone.connect(self.one_exp_done) self.model.expFail.connect(self.one_exp_fail) #view self.tableView = QtGui.QTableView(self) self.tableView.setModel(self.model) self.tableView.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) #Experiments self.root = QtCore.QDir(SERVER_PATH) self.experimentDict = {} self._layout() self.show()
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent, QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) self.setWindowIcon( QtGui.QIcon(os.path.join("Resources", "images", "Icon"))) self.setWindowTitle("Rematch") screen = QtGui.QDesktopWidget().screenGeometry() self.setFixedSize(450, 300) size = self.geometry() self.move((screen.width() - size.width()) / 2, ( screen.height() - size.height()) / 2) self.lastWindowGeometry = self.geometry() self.settingsDialog = SettingsDialog(self) self.settingsDialog.settingsUpdated.connect(self.updateSettings) mainWidget = QtGui.QWidget(self) mainWidget.setGeometry(0, 0, 450, 300) mainWidget.setObjectName("main") mainWidget.setStyleSheet(""" QWidget#main { background: #ffffff; border: 1px solid #00B6F3; border-radius: 0px; } """) mainLayout = QtGui.QVBoxLayout() mainLayout.setSpacing(0) mainLayout.setMargin(0) mainWidget.setLayout(mainLayout) frame = FrameLabel(self) frame.settingsButton.clicked.connect(self.settingsDialog.exec_) mainLayout.addWidget(frame) self.timer = QtCore.QTimer() self.timer.setSingleShot(False) self.timer.setInterval(1000) self.timer.timeout.connect(self.increaseElapsedTime) hbox = QtGui.QHBoxLayout() hbox.setMargin(5) hbox.setSpacing(5) mainLayout.addLayout(hbox) hbox.addStretch(1) self.pauseButton = QtGui.QToolButton() self.pauseButton.setToolTip("Pause Time") self.pauseButton.setStyleSheet(StyleSheet.playPauseButtonStyle) self.pauseButton.setAutoRaise(True) self.pauseButton.setIconSize(QtCore.QSize(30, 30)) self.pauseButton.setMinimumWidth(45) self.pauseButton.setMinimumHeight(45) self.pauseButton.setIcon(QtGui.QIcon("Resources\\images\\pause")) hbox.addWidget(self.pauseButton) self.pauseButton.clicked.connect(self.stop) self.pauseButton.hide() self.playButton = QtGui.QToolButton() self.playButton.setToolTip("Start\Continue Time") self.playButton.setStyleSheet(StyleSheet.playPauseButtonStyle) self.playButton.setAutoRaise(True) self.playButton.setIconSize(QtCore.QSize(30, 30)) self.playButton.setMinimumWidth(45) self.playButton.setMinimumHeight(45) self.playButton.setIcon(QtGui.QIcon("Resources\\images\\player_play")) self.playButton.clicked.connect(self.play) hbox.addWidget(self.playButton) hbox.addStretch(1) hbox = QtGui.QHBoxLayout() hbox.setMargin(10) mainLayout.addLayout(hbox) self.teamAScoreLabel = QtGui.QLabel() self.teamAScoreLabel.setStyleSheet(StyleSheet.scoreLabelStyle) hbox.addWidget(self.teamAScoreLabel) hbox.addStretch(1) self.scoreABox = QtGui.QLineEdit('0') self.scoreABox.setReadOnly(True) self.scoreABox.setStyleSheet(StyleSheet.scoreBoxStyle) self.scoreABox.setMinimumHeight(45) self.scoreABox.setMinimumWidth(95) self.scoreABox.textChanged.connect(self.updateInstruction) hbox.addWidget(self.scoreABox) self.increaseAbutton = QtGui.QToolButton() self.increaseAbutton.setToolTip("Score") self.increaseAbutton.setIcon( QtGui.QIcon("Resources\\images\\go-up-black")) self.increaseAbutton.setStyleSheet(StyleSheet.increaseButtonStyle) self.increaseAbutton.clicked.connect(self.increaseA) hbox.addWidget(self.increaseAbutton) hbox = QtGui.QHBoxLayout() hbox.setMargin(10) mainLayout.addLayout(hbox) self.teamBScoreLabel = QtGui.QLabel() self.teamBScoreLabel.setStyleSheet(StyleSheet.scoreLabelStyle) hbox.addWidget(self.teamBScoreLabel) hbox.addStretch(1) self.scoreBBox = QtGui.QLineEdit('0') self.scoreBBox.setReadOnly(True) self.scoreBBox.setStyleSheet(StyleSheet.scoreBoxStyle) self.scoreBBox.setMinimumHeight(45) self.scoreBBox.setMinimumWidth(95) self.scoreBBox.textChanged.connect(self.updateInstruction) hbox.addWidget(self.scoreBBox) self.increaseBbutton = QtGui.QToolButton() self.increaseBbutton.setToolTip("Score") self.increaseBbutton.setStyleSheet(StyleSheet.increaseButtonStyle) self.increaseBbutton.setIcon( QtGui.QIcon("Resources\\images\\go-up-black")) self.increaseBbutton.clicked.connect(self.increaseB) hbox.addWidget(self.increaseBbutton) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) hbox.addStretch(1) self.timeElapsedLabel = QtGui.QLabel('00:00') self.timeElapsedLabel.setStyleSheet(StyleSheet.timeElapsedStyle) hbox.addWidget(self.timeElapsedLabel) hbox.addStretch(1) mainLayout.addStretch(1) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.resetButton = QtGui.QPushButton("Reset") self.resetButton.setStyleSheet(StyleSheet.resetButtonStyle) self.resetButton.clicked.connect(self.reset) hbox.addWidget(self.resetButton) self.movieButton = QtGui.QPushButton("Movie") self.movieButton.setStyleSheet(StyleSheet.breakButtonStyle) self.movieButton.clicked.connect(self.showMovie) hbox.addWidget(self.movieButton) self.newButton = QtGui.QPushButton("New") self.newButton.setStyleSheet(StyleSheet.newButtonStyle) self.newButton.clicked.connect(self.newMatch) hbox.addWidget(self.newButton) hbox = QtGui.QHBoxLayout() hbox.setMargin(5) hbox.setSpacing(5) mainLayout.addLayout(hbox) label = QtGui.QLabel() label.setScaledContents(True) label.setMaximumWidth(25) label.setMinimumWidth(25) label.setMaximumHeight(25) label.setMinimumHeight(25) label.setPixmap(QtGui.QPixmap("Resources\\images\\network-wireless")) hbox.addWidget(label) self.addressLabel = QtGui.QLabel("Boadcasting on port:") hbox.addWidget(self.addressLabel) self.addressLabel = QtGui.QLabel() hbox.addWidget(self.addressLabel) self.timeElapsed = 0 self.animation = 0 self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(): QtGui.QMessageBox.critical(self, "Rematch", "Unable to start the server: {0}.".format(self.tcpServer.errorString())) self.close() self.tcpServer.newConnection.connect(self.sendInstruction) self.addressLabel.setText(str(self.tcpServer.serverPort())) hbox.addStretch(1) self.settingsList = self.settingsDialog.settingsList self.updateInstruction()
def __init__(self, controller, port): self.socket = QtNetwork.QTcpServer() self.controller = controller self.socket.newConnection.connect(self.on_socket_message) self.socket.listen(QtNetwork.QHostAddress.LocalHost, port)
def start_server(self): self.connections = [] s = qn.QTcpServer(self) s.listen(qn.QHostAddress.LocalHost) self.connect(s, qc.SIGNAL('newConnection()'), self.handle_accept) self.server = s
def __init__(self, x, y, width, height, rpm, scene_server_port): super(MyGui, self).__init__() self.x = x self.y = y self.width = width self.height = height self.port = scene_server_port w = self.width * rpm h = self.height / self.width * w self.scene = QtGui.QGraphicsScene(0, 0, int(w), int(h)) self.scene.rpm = rpm self.scene.setBackgroundBrush(QtCore.Qt.black) self.view = customGraphicsView(self.scene) self.view.setRenderHint(QtGui.QPainter.Antialiasing) self.view.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate) self.view.setStyleSheet("QGraphicsView { border-style: none; }") self.touch_calib_srv = rospy.Service( '/art/interface/projected_gui/touch_calibration', TouchCalibrationPoints, self.touch_calibration_points_cb) self.touched_sub = None self.projectors_calibrated_pub = rospy.Publisher( '/art/interface/projected_gui/app/projectors_calibrated', Bool, queue_size=10, latch=True) self.calibrating_touch = False self.touch_calibration_points = None QtCore.QObject.connect(self, QtCore.SIGNAL('touch_calibration_points_evt'), self.touch_calibration_evt) self.point_item = None touch_calibrated = rospy.wait_for_message( "/art/interface/touchtable/calibrated", Bool).data self.tcpServer = QtNetwork.QTcpServer(self) if not self.tcpServer.listen(port=self.port): rospy.logerr('Failed to start scene TCP server on port ' + str(self.port)) self.tcpServer.newConnection.connect(self.new_connection) self.connections = [] self.scene_timer = QtCore.QTimer() self.connect(self.scene_timer, QtCore.SIGNAL('timeout()'), self.send_to_clients_evt) self.scene_timer.start(1.0 / 15 * 1000) self.projectors = [ProjectorHelper("localhost")] rospy.loginfo("Waiting for projector nodes...") for proj in self.projectors: proj.wait_until_available() if not proj.is_calibrated(): rospy.loginfo("Starting calibration of projector: " + proj.proj_id) b = Bool() b.data = False self.projectors_calibrated_pub.publish(b) proj.calibrate(self.calibrated_cb) else: rospy.loginfo("Projector " + proj.proj_id + " already calibrated.") if not touch_calibrated: rospy.wait_for_service('/art/interface/touchtable/calibrate') rospy.loginfo('Get /art/interface/touchtable/calibrate service') self.calibrate_table_srv_client = rospy.ServiceProxy( '/art/interface/touchtable/calibrate', EmptySrv) req = EmptyRequest() self.calibrate_table_srv_client.call(req) rospy.loginfo("Ready")