Skip to content

Commit 0950079

Browse files
ComputerTech312James Trotter
authored andcommitted
Modified code from PyQt5 to PyQt6 and cleaned up the code.
1 parent e1b2015 commit 0950079

File tree

5 files changed

+10
-156
lines changed

5 files changed

+10
-156
lines changed

irc_client.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
from PyQt5.QtWidgets import QApplication
1+
from PyQt6.QtWidgets import QApplication, QDialog
22
from src.irc.irc_client import IRCClient
33
from src.gui.connect_dialog import ConnectDialog
44
from src.gui.main_window import MainWindow
55
import sys
6-
from PyQt5.QtWidgets import QApplication, QDialog
76

87
if __name__ == '__main__':
98
app = QApplication(sys.argv)
109

1110
dialog = ConnectDialog()
12-
if dialog.exec() == QDialog.Accepted:
11+
if dialog.exec() == QDialog.DialogCode.Accepted:
1312
host, port, nick, realname, channel = dialog.get_values()
1413
client = IRCClient(host, port, nick, realname, channel)
1514
client.connect_to_host()

src/gui/connect_dialog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLineEdit, QDialogButtonBox, QLabel
1+
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLineEdit, QDialogButtonBox, QLabel, QApplication
22

33
class ConnectDialog(QDialog):
44
def __init__(self, parent=None):
@@ -35,10 +35,10 @@ def __init__(self, parent=None):
3535
self.channel_label = QLabel("Channel:", self)
3636
self.layout.addWidget(self.channel_label)
3737
self.channel_input = QLineEdit(self)
38-
self.channel_input.setText("#elitechat")
38+
self.channel_input.setText("#pyechat")
3939
self.layout.addWidget(self.channel_input)
4040

41-
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
41+
self.buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel, self)
4242
self.buttons.accepted.connect(self.accept)
4343
self.buttons.rejected.connect(self.reject)
4444
self.layout.addWidget(self.buttons)

src/gui/main_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from PyQt5.QtCore import pyqtSlot
2-
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTextEdit, QLineEdit, QTabWidget
1+
from PyQt6.QtCore import pyqtSlot
2+
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QTextEdit, QLineEdit, QTabWidget
33

44
class MainWindow(QWidget):
55
def __init__(self, client):

src/irc/irc_client.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
1-
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot
2-
from PyQt5.QtNetwork import QTcpSocket
3-
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QLineEdit, QDialogButtonBox, QDialog, QLabel
4-
5-
class ConnectDialog(QDialog):
6-
def __init__(self, parent=None):
7-
super().__init__(parent)
8-
9-
self.setWindowTitle("Connect to IRC Server")
10-
11-
self.layout = QVBoxLayout(self)
12-
13-
self.host_label = QLabel("Host:", self)
14-
self.layout.addWidget(self.host_label)
15-
self.host_input = QLineEdit(self)
16-
self.host_input.setText("irc.rizon.net")
17-
self.layout.addWidget(self.host_input)
18-
19-
self.port_label = QLabel("Port:", self)
20-
self.layout.addWidget(self.port_label)
21-
self.port_input = QLineEdit(self)
22-
self.port_input.setText("6667")
23-
self.layout.addWidget(self.port_input)
24-
25-
self.nick_label = QLabel("Nickname:", self)
26-
self.layout.addWidget(self.nick_label)
27-
self.nick_input = QLineEdit(self)
28-
self.nick_input.setText("pyechat")
29-
self.layout.addWidget(self.nick_input)
30-
31-
self.realname_label = QLabel("Real name:", self)
32-
self.layout.addWidget(self.realname_label)
33-
self.realname_input = QLineEdit(self)
34-
self.realname_input.setText("Pyechat: https://pyechat.github.io")
35-
self.layout.addWidget(self.realname_input)
36-
37-
self.channel_label = QLabel("Channel:", self)
38-
self.layout.addWidget(self.channel_label)
39-
self.channel_input = QLineEdit(self)
40-
self.channel_input.setText("#pyechat")
41-
self.layout.addWidget(self.channel_input)
42-
43-
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
44-
self.buttons.accepted.connect(self.accept)
45-
self.buttons.rejected.connect(self.reject)
46-
self.layout.addWidget(self.buttons)
47-
48-
def get_values(self):
49-
return self.host_input.text(), int(self.port_input.text()), self.nick_input.text(), self.realname_input.text(), self.channel_input.text()
50-
51-
def closeEvent(self, event):
52-
QApplication.quit()
1+
from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot
2+
from PyQt6.QtNetwork import QTcpSocket
3+
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QLineEdit, QDialogButtonBox, QDialog, QLabel
534

545
class IRCClient(QObject):
556
received_message = pyqtSignal(str)

0 commit comments

Comments
 (0)