-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (40 loc) · 1.21 KB
/
main.py
File metadata and controls
55 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# coding: utf-8
"""
Tela de integração com server.py e client.py.
Permite disparar N servidores e N clientes, onde HOST e PORT
é parametrizado.
"""
import sys
from PyQt5 import QtWidgets
import client
import server
import protocol
import gui.main
class MainGUI(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.ui = gui.main.Ui_MainWindow()
self.ui.setupUi(self)
self.ui.client_button.clicked.connect(self.open_client)
self.ui.server_button.clicked.connect(self.open_server)
self.ui.host_text.setText(protocol.HOST)
self.ui.port_text.setText(str(protocol.PORT))
def update_host_port(self):
protocol.HOST = self.ui.host_text.text()
protocol.PORT = int(self.ui.port_text.text())
def open_server(self):
self.update_host_port()
s = server.ServerGUI(parent=self)
s.init_server()
def open_client(self):
self.update_host_port()
c = client.ClientGUI(parent=self)
c.init_client()
@classmethod
def run(cls):
app = QtWidgets.QApplication(sys.argv)
main = cls()
main.show()
sys.exit(app.exec_())
if __name__ == '__main__':
MainGUI.run()