forked from NganeEmmanuel/TransMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.py
More file actions
49 lines (40 loc) · 1.44 KB
/
widget.py
File metadata and controls
49 lines (40 loc) · 1.44 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
# This Python file uses the following encoding: utf-8
import os
import sys
from pathlib import Path
from PySide6.QtCore import QFile, Slot
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QApplication, QWidget, QPushButton, QLineEdit
from Database import dbInit
from Service import loginService
class Widget(QWidget):
def __init__(self):
super(Widget, self).__init__()
dbInit.create_tables()
self.load_ui()
def load_ui(self):
loader = QUiLoader()
path = os.fspath(Path(__file__).resolve().parent / "form.ui")
ui_file = QFile(path)
ui_file.open(QFile.ReadOnly)
loader.load(ui_file, self)
ui_file.close()
# Access the QPushButton using its object name
self.loginBtn = self.findChild(QPushButton, "loginBtn")
self.username = self.findChild(QLineEdit, "username")
self.password = self.findChild(QLineEdit, "password")
# Connect the clicked signal of the button to a function
self.loginBtn.clicked.connect(self.login)
@Slot()
def login(self):
username = self.username.text()
password = self.password.text()
# This function will be called when the button is clicked
loginService.login(username, password)
if __name__ == "__main__":
app = QApplication([])
widget = Widget()
widget.setFixedHeight(471)
widget.setFixedWidth(761)
widget.show()
sys.exit(app.exec_())