-
Notifications
You must be signed in to change notification settings - Fork 0
/
appointment.py
171 lines (141 loc) · 5.02 KB
/
appointment.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""A medical appointment GUI.
@author Hank Adler
@version 0.1.0
@license MIT
"""
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
self.init()
def init(self):
self.setWindowTitle("Medical Appointment")
self.setFixedSize(450, 400)
self.add_widgets()
self.show()
def add_widgets(self):
# Defines fonts.
f1 = QFont('Consolas', 12)
f1.setBold(True)
f2 = QFont('Consolas', 10)
f3 = QFont('Consolas', 8)
self.setFont(f2)
# Sets layout.
layout = QFormLayout()
layout.setLabelAlignment(Qt.AlignRight)
self.setLayout(layout)
# Adds title row.
title_label = QLabel('Appointment Submission')
title_label.setFont(f1)
title_label.setContentsMargins(10, 10, 10, 10)
title_label.setAlignment(Qt.AlignCenter)
layout.addRow(title_label)
# Adds Name row.
name_label = QLabel('Name:')
name_label.setFont(f2)
name_edit = QLineEdit()
name_edit.setFont(f3)
name_edit.setPlaceholderText('First Last')
layout.addRow(name_label, name_edit)
# Adds Address row.
address_label = QLabel('Address:')
address_label.setFont(f2)
address_edit = QLineEdit()
address_edit.setFont(f3)
layout.addRow(address_label, address_edit)
# Adds Phone row.
phone_label = QLabel('Phone:')
phone_label.setFont(f2)
phone_edit = QLineEdit()
phone_edit.setFont(f3)
phone_edit.setInputMask('000-000-0000;')
layout.addRow(phone_label, phone_edit)
# Adds Age, Height, Weight row.
age_label = QLabel(' Age:')
age_label.setFont(f2)
age_spinbox = QSpinBox()
age_spinbox.setFont(f3)
age_spinbox.setRange(0, 130)
height_label = QLabel(' Height:')
height_label.setFont(f2)
height_edit = QLineEdit()
height_edit.setFont(f3)
height_edit.setPlaceholderText('ft')
weight_label = QLabel(' Weight:')
weight_label.setFont(f2)
weight_edit = QLineEdit()
weight_edit.setFont(f3)
weight_edit.setPlaceholderText('lbs')
age_hbox = QHBoxLayout()
age_hbox.addWidget(age_label)
age_hbox.addWidget(age_spinbox)
age_hbox.addWidget(height_label)
age_hbox.addWidget(height_edit)
age_hbox.addWidget(weight_label)
age_hbox.addWidget(weight_edit)
layout.addRow(age_hbox)
# Adds Gender row.
gender_label = QLabel('Gender:')
gender_label.setFont(f2)
gender_combobox = QComboBox()
gender_combobox.setFixedWidth(80)
gender_combobox.addItems(['Male', 'Female'])
layout.addRow(gender_label, gender_combobox)
# Adds Past Surgeries row.
past_surgeries_label = QLabel('Past Surgeries:')
past_surgeries_label.setFont(f2)
past_surgeries_edit = QTextEdit()
past_surgeries_edit.setFont(f3)
past_surgeries_edit.setPlaceholderText('Separate by ;')
layout.addRow('', past_surgeries_label)
layout.addRow('', past_surgeries_edit)
# Adds Blood Type row.
blood_type_label = QLabel('Blood Type:')
blood_type_label.setFont(f2)
blood_type_combobox = QComboBox()
blood_type_combobox.addItems(['A', 'AB', 'B', 'O'])
blood_type_combobox.setFixedWidth(80)
layout.addRow(blood_type_label, blood_type_combobox)
# Adds Appointment Time row.
time_label = QLabel('Time:')
time_label.setFont(f2)
time_label.setAlignment(Qt.AlignRight)
hour_spinbox = QSpinBox()
hour_spinbox.setFont(f3)
hour_spinbox.setRange(1, 12)
hour_spinbox.setValue(8)
hour_spinbox.setFixedWidth(60)
minutes_combobox = QComboBox()
minutes_combobox.setFont(f3)
minutes_combobox.addItems([':00', ':30'])
minutes_combobox.setFixedWidth(60)
ampm_combobox = QComboBox()
ampm_combobox.setFont(f3)
ampm_combobox.addItems(['AM', 'PM'])
ampm_combobox.setFixedWidth(60)
time_hbox = QHBoxLayout()
time_hbox.addWidget(hour_spinbox)
time_hbox.addWidget(minutes_combobox)
time_hbox.addWidget(ampm_combobox)
layout.addRow(time_label, time_hbox)
# Adds Submit row.
submit_button = QPushButton('Submit')
submit_button.setFont(f2)
submit_button.setFixedWidth(80)
submit_button.clicked.connect(self._on_submit)
submit_hbox = QHBoxLayout()
submit_hbox.setAlignment(Qt.AlignCenter)
submit_hbox.addWidget(submit_button)
layout.addRow(submit_hbox)
def _on_submit(self):
print('\tSubmitted.')
self.close()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec_())