generated from BYUIDSS/blank_project_repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
clearview.py
263 lines (194 loc) · 8.48 KB
/
clearview.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# -----------------------
# Author: Clearview Project Team
# Date: 2024-06-01
# Purpose: This file is the main file for the Clearview project. It will be used to run the Clearview project.
# -----------------------
# -----------------------
# Import Libraries
# -----------------------
import os
import mysql.connector
from color import * # done
from frame_size import * # done
from new_window_screen import * # done
from fastener import * # done
import measurement
from measurement import * # done, but has yellow underlines
from mesh import * #
from mirage import *
from mirage_3500 import *
from mirage_color import *
from mirage_mesh import *
from nws_measurement import *
from rainier_act import *
from rainier_color import *
from window import *
try:
import streamlit as st
except ImportError or ModuleNotFoundError:
os.system('pip install streamlit')
import streamlit as st
# -----------------------
# Database Connection
# -----------------------
# Clearview Database Connection
clearview = mysql.connector.connect(
host="localhost",
user="clearview",
password="CView24",
database='clearview'
)
# Clearview Cursor
cvcursor = clearview.cursor()
# -----------------------
# Class Initialization
# -----------------------
color = color(cvcursor, clearview)
frame_size = frame_size(cvcursor, clearview)
new_window_screen = new_window_screen(cvcursor, clearview)
fastener = fastener(cvcursor,clearview)
measurement = measurement(cvcursor,clearview)
mesh = mesh(cvcursor,clearview)
mirage = mirage(cvcursor,clearview)
mirage_3500 = mirage_3500(cvcursor,clearview)
mirage_color = mirage_color(cvcursor,clearview)
nws_measurement = nws_measurement(cvcursor,clearview)
rainier_act = rainier_act(cvcursor,clearview)
rainier_color = rainier_color(cvcursor,clearview)
window = window(cvcursor,clearview)
# -----------------------
# Main Program
# -----------------------
# drop down for color options for insert, update, and delete
color_options = st.selectbox('Please select an option for the Color Table: ',
('Choose an option','View', 'Insert', 'Update', 'Delete'))
if color_options == 'Insert':
color_choice = st.text_input('Please enter a color: ')
color_button = st.button('Insert Color', key=1)
if color_button:
color.insert_color(color_choice)
st.write('successful')
elif color_options == 'View':
st.write(color.display_color())
elif color_options == 'Update':
st.write(color.display_color())
color_id = st.text_input('Please enter the color id: ')
color_choice = st.text_input('Please enter a color: ')
color_button = st.button('Update Color', key=2)
if color_button:
color.update_color(color_id, color_choice)
st.write('successful')
elif color_options == 'Delete':
st.write(color.display_color())
color_id = st.text_input('Please enter the color id: ')
color_button = st.button('Delete Color', key=3)
if color_button:
color.delete_color(color_id)
st.write('successful')
# Frame_size options
frame_size_options = st.selectbox('Please select an option for the Frame Size Table: ',
('Choose an option', 'View', 'Insert', 'Update', 'Delete'))
if frame_size_options == 'View':
st.write(frame_size.display_frame_size())
elif frame_size_options == 'Insert':
frame_size_choice = st.text_input('Please enter a Frame Size (e.g. 1/16): ')
frame_button = st.button('Insert Frame Size', key=1)
if frame_button:
frame_size.insert_frame_size(frame_size_choice)
st.write('Frame Size Successfully Inserted')
elif frame_size_options == 'Update':
st.write(frame_size.display_frame_size())
frame_size_id = st.text_input('Please enter the Frame Size id: ')
frame_size_choice = st.text_input('Please enter a New Frame Size: ')
frame_button = st.button('Update Frame Size', key=2)
if frame_button:
frame_size.update_frame_size(frame_size_id, frame_size_choice)
st.write('Update Successful')
elif frame_size_options == 'Delete':
st.write(frame_size.display_frame_size())
frame_size_id = st.text_input('Please enter the frame size id: ')
frame_button = st.button('Delete Frame Size', key=3)
if frame_button:
frame_size.delete_frame_size(frame_size_id)
st.write('Delete Successful')
# Section: New_Window_Screen
# INSERT, UPDATE, and DELETE options drop down for new_window_screen
nws_options = st.selectbox('Please select an option for the New Window Screen Table: ', ('Choose an option','View', 'Insert', 'Update', 'Delete'))
if nws_options == 'Insert':
width_inch = st.text_input('Please enter a new width in inches: ')
height_inch = st.text_input('Please enter a new height in inches: ')
nws_insert_button = st.button('Insert New Window Screen', key=1)
if nws_insert_button:
new_window_screen.insert_new_window_screen(width_inch, height_inch)
st.write('Success!')
elif nws_options == 'View':
st.write(new_window_screen.display_new_window_screen())
elif nws_options == 'Update':
st.write(new_window_screen.display_new_window_screen())
nws_id = st.text_input('Please enter the new window screen id: ')
width_inch = st.text_input('Please enter a new width in inches: ')
height_inch = st.text_input('Please enter a new height in inches: ')
nws_update_button = st.button('Update New Window Screen', key=2)
if nws_update_button:
new_window_screen.update_new_window_screen(nws_id, width_inch, height_inch)
st.write('Update Successful!')
elif nws_options == 'Delete':
st.write(new_window_screen.display_new_window_screen())
nws_id = st.text_input('Please enter the window screen id: ')
nws_delete_button = st.button('Delete Window Screen', key=3)
if nws_delete_button:
new_window_screen.delete_new_window_screen(nws_id)
st.write('Successful deletion!')
# #######################################
# fastener options
fastener_options = st.selectbox('Please select an option for the Fastener Table: ',('Choose an option','View', 'Insert', 'Update', 'Delete'))
if fastener_options == 'Insert':
fastener_type = st.text_input('Please enter a fastener type: ')
fastener_button = st.button('Insert Fastener', key=1)
if fastener_button:
fastener.insert_fastener(fastener_type)
st.write('Successful')
elif fastener_options == 'View':
st.write(fastener.display_fastener())
elif fastener_options == 'Update':
st.write(fastener.display_fastener())
fastener_id = st.text_input('Please enter the fastener''s id: ')
fastener_choice = st.text_input('Please enter a fastener type: ')
f_update_button = st.button('Update Fastener', key=2)
if f_update_button:
fastener.update_fastener(fastener_id, fastener_choice)
st.write('Successful')
elif fastener_options == 'Delete':
st.write(fastener.display_fastener())
fastener_id = st.text_input('Please enter the fastener''s id: ')
f_delete_button = st.button('Delete Fastener', key=3)
if f_delete_button:
fastener.delete_fastener(fastener_id)
st.write('Successful Deletion')
# ##########################
# measurement table UI
measurement_options = st.selectbox('Please select an option for the Measurement Table: ',
('Choose an option','View', 'Insert', 'Update', 'Delete'))
if measurement_options == 'Insert':
measurement_choice = st.text_input('Please enter a measurement: ')
m_insert_button = st.button('Insert Measurement', key=1)
if m_insert_button:
measurement.insert_measurement(measurement_choice)
st.write('Successful')
elif measurement_options == 'View':
st.write(measurement.display_measurement())
elif measurement_options == 'Update':
st.write(measurement.display_measurement())
measurement_id = st.text_input('Please enter the measurement id: ')
measurement_choice = st.text_input('Please enter a measurement: ')
measurement_button = st.button('Update Measurement', key=2)
if measurement_button:
measurement.update_measurement(measurement_id, measurement_choice)
st.write('Successful Update')
elif measurement_options == 'Delete':
st.write(measurement.display_measurement())
measurement_id = st.text_input('Please enter the color id: ')
m_delete_button = st.button('Delete Measurement', key=3)
if m_delete_button:
measurement.delete_measurement(measurement_id)
st.write('Successful Deletion')