-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform_layout.py
More file actions
63 lines (48 loc) · 1.99 KB
/
form_layout.py
File metadata and controls
63 lines (48 loc) · 1.99 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
56
57
58
59
60
61
62
63
import sys
from PyQt6.QtWidgets import (
QApplication,
QLineEdit,
QWidget,
QLabel,
QPushButton,
QFormLayout,
)
from PyQt6.QtCore import Qt, pyqtSlot
class AplikasiKita(QWidget):
def __init__(self) -> None:
super().__init__()
self.inisialisasi_interface()
def inisialisasi_interface(self) -> None:
self.setWindowTitle("contoh aplikasi kita")
self.setGeometry(300, 300, 400, 250)
self.layout_form: QFormLayout = QFormLayout()
self.setLayout(self.layout_form)
self.label_nama: QLabel = QLabel("Nama Lengkap:", self)
self.input_nama: QLineEdit = QLineEdit(self)
self.input_nama.setPlaceholderText("contohnya `arfy slowy`")
self.label_email: QLabel = QLabel("Email:", self)
self.input_email: QLineEdit = QLineEdit(self)
self.tombol_kirim: QPushButton = QPushButton("daftar kan dirikamu", self)
self.tombol_kirim.clicked.connect(self.tombol_kirim_proses)
self.layout_form.addRow(self.label_nama, self.input_nama)
self.layout_form.addRow(self.label_email, self.input_email)
self.layout_form.addRow(self.tombol_kirim)
self.layout_form.setLabelAlignment(Qt.AlignmentFlag.AlignRight)
self.layout_form.setFormAlignment(Qt.AlignmentFlag.AlignCenter)
self.layout_form.setHorizontalSpacing(20)
self.layout_form.setContentsMargins(30, 30, 30, 30)
@pyqtSlot()
def tombol_kirim_proses(self) -> None:
nama: str = self.input_nama.text().strip()
email: str = self.input_email.text().strip()
if not nama or not email:
print("tolong isi semua field yang tersedia")
else:
print(f"nama: {nama}")
print(f"email: {email}")
if __name__ == "__main__":
aplikasi: QApplication = QApplication(sys.argv)
jendela: AplikasiKita = AplikasiKita()
jendela.show()
sys.exit(aplikasi.exec())