May 2019
Intermediate to advanced
542 pages
13h 37m
English
Back in our MainWindow constructor, we need to finish up our application by creating a UdpChatInterface object and connecting its signals:
username = qtc.QDir.home().dirName() self.interface = UdpChatInterface(username) self.cw.submitted.connect(self.interface.send_message) self.interface.received.connect(self.cw.write_message) self.interface.error.connect( lambda x: qtw.QMessageBox.critical(None, 'Error', x))
Before creating the interface, we're determining the username by grabbing the name of the current user's home directory. This is a bit of a hack, but it works well enough for our purposes here.
Next, we create our interface object and connect the chat window submitted signal to its send_message() slot.
We then connect ...
Read now
Unlock full access