forked from The-Pythonologists/The-Pythonologists
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator_debugged.py
More file actions
3311 lines (2772 loc) · 149 KB
/
Calculator_debugged.py
File metadata and controls
3311 lines (2772 loc) · 149 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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This still needs work so im not putting it in the same file as the old calculator
# - Thanosks
import sys
import numexpr as ne
import numpy as np
import math
from PySide6.QtGui import (QAction, QFont, QIcon, QPalette, QColor)
from PySide6.QtCore import (Qt, Slot, QRect)
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QGridLayout, QLineEdit, QPushButton,
QSizePolicy, QMenuBar, QColorDialog, QComboBox)
class Calculator(QMainWindow):
# ** CLASS PROPERTIES **
def _QMainWindow_properties(self):
# -- Assigning our QWidget's properties --
QWidget.setWindowTitle(self, "Calculator")
QWidget.setWindowIcon(self, QIcon('pics/calc1.png'))
QWidget.setGeometry(self, 450, 220, 330, 330)
# --------------------------------------
# ** DECLARATION FUNCTIONS **
def _calculator_modes_declarations(self):
# ** DECLARATION & ALTERING OF THE CALCULATOR ATTRIBUTES **
# It contains all the common attributes across calculator modes
# -- Declaration of count for the correct use of brackets in scientific mode --
self.left_bracket_count = 0
self.right_bracket_count = 0
# -- Boolean attributes --
self.bool_dont_del = False # To prevent the deletion of display_box's contents in some occasions
self.bool_waiting_for_operand = False # Set to False so it doesn't display a symbol that's pressed on its first run
self.bool_equal_last_pressed = False # To check whether the last symbol pressed was a '=' sign
self.bool_plus_last_pressed = False # To check whether the last symbol pressed was a '+' sign
self.bool_minus_last_pressed = False # To check whether the last symbol pressed was a '-' sign
self.bool_times_last_pressed = False # To check whether the last symbol pressed was a '*' sign
self.bool_division_last_pressed = False # To check whether the last symbol pressed was a '/' sign
self.bool_modular_last_pressed = False # To check whether the last symbol pressed was a 'Mod' sign
# ------------------------
# -- String attributes --
self.string_display_box = '' # Contains the contents of the 'display_box'
self.string_symbol_box = '' # Contains the contents of the 'symbol_box'
self.string_display_box_SCI = '' # Contains the contents of the 'display_box_SCI'
self.string_symbol_box_SCI = '' # Contains the contents of the 'symbol_box_SCI'
self.string_display_box_TIME = '' # Contains the contents of the 'display_box_TIME'
self.string_symbol_box_TIME = '' # Contains the contents of the 'symbol_box_TIME'
self.string_display_box_DATA = '' # Contains the contents of the 'display_box_DATA'
self.string_symbol_box_DATA = '' # Contains the contents of the 'symbol_box_DATA'
self.string_display_box_TEMP = '' # Contains the contents of the 'display_box_TEMP'
self.string_symbol_box_TEMP = '' # Contains the contents of the 'symbol_box_TEMP'
self.string_display_box_LEN = '' # Contains the contents of the 'display_box_LEN'
self.string_symbol_box_LEN = '' # Contains the contents of the 'symbol_box_LEN'
self.string_display_box_MASS = '' # Contains the contents of the 'display_box_MASS'
self.string_symbol_box_MASS = '' # Contains the contents of the 'symbol_box_MASS'
self.string_display_box_SPEED = '' # Contains the contents of the 'display_box_SPEED'
self.string_symbol_box_SPEED = '' # Contains the contents of the 'symbol_box_SPEED'
self.string_display_box_AGE = '' # Contains the contents of the 'display_box_AGE'
self.string_display_box_AGE_2 = '' # Contains the contents of the 'display_box_AGE_2'
self.string_symbol_box_AGE = '' # Contains the contents of the 'symbol_box_AGE'
self.string_display_box_DISC = '' # Contains the contents of the 'display_box_DISC'
self.string_display_box_DISC_2 = '' # Contains the contents of the 'display_box_DISC_2'
self.string_symbol_box_DISC = '' # Contains the contents of the 'symbol_box_DISC'
self.string_display_box_BMI = '' # Contains the contents of the 'display_box_BMI'
self.string_display_box_BMI_2 = '' # Contains the contents of the 'display_box_BMI_2'
self.string_symbol_box_BMI = '' # Contains the contents of the 'symbol_box_BMI'
self.string_display_box_DATE = '' # Contains the contents of the 'display_box_DATE'
self.string_display_box_DATE_2 = '' # Contains the contents of the 'display_box_DATE_2'
self.string_symbol_box_DATE = '' # Contains the contents of the 'symbol_box_DATE'
self.string_result = '' # Contains the contents of the complete string
self.string_last_operand_used = '' # Contains the contents of the last operand used (excluding = operand)
self.string_last_number_used = '' # Contains the contents of the last number used
self.string_calculated_invoked = '' # Contains the contents of the function '_calculated_invoked'
# -----------------------
# -- QLineEdit attributes --
self.display_box = QLineEdit('')
self.symbol_box = QLineEdit('')
self.symbol_box_SCI = QLineEdit('')
self.display_box_SCI = QLineEdit('')
self.display_box_TIME = QLineEdit('Enter your value here.')
self.symbol_box_TIME = QLineEdit('')
self.display_box_DATA = QLineEdit('Enter your value here.')
self.symbol_box_DATA = QLineEdit('')
self.display_box_TEMP = QLineEdit('Enter your value here.')
self.symbol_box_TEMP = QLineEdit('')
self.display_box_LEN = QLineEdit('Enter your value here.')
self.symbol_box_LEN = QLineEdit('')
self.display_box_MASS = QLineEdit('Enter your value here.')
self.symbol_box_MASS = QLineEdit('')
self.display_box_SPEED = QLineEdit('Enter your value here.')
self.symbol_box_SPEED = QLineEdit('')
self.display_box_AGE = QLineEdit('Enter your birth year.')
self.display_box_AGE_2 = QLineEdit('Enter the current year.')
self.symbol_box_AGE = QLineEdit('')
self.display_box_DISC = QLineEdit('Enter the original price.')
self.display_box_DISC_2 = QLineEdit('Enter the discount.')
self.symbol_box_DISC = QLineEdit('')
self.display_box_BMI = QLineEdit('Enter your weight here.')
self.display_box_BMI_2 = QLineEdit('Enter your height here.')
self.symbol_box_BMI = QLineEdit('')
self.display_box_DATE = QLineEdit('Enter the first value here.')
self.display_box_DATE_2 = QLineEdit('Enter the second value here.')
self.symbol_box_DATE = QLineEdit('')
# --------------------------
# -- QPushButton attributes --
# * Algebraic buttons
self.button_exponent = QPushButton('x²')
self.button_raise = QPushButton('xⁿ')
self.button_absolute = QPushButton('|x|')
self.button_sqrt = QPushButton('√')
self.button_log = QPushButton('log')
self.button_ln = QPushButton('ln')
self.button_pi = QPushButton('π')
self.button_factorial = QPushButton('n!')
# * Trigonometric buttons
self.button_sin = QPushButton('sin')
self.button_cos = QPushButton('cos')
self.button_tan = QPushButton('tan')
# * Operand buttons
self.button_equal = QPushButton('=')
self.button_plus = QPushButton('+')
self.button_minus = QPushButton('-')
self.button_times = QPushButton('*')
self.button_division = QPushButton('/')
self.button_modular = QPushButton('Mod')
self.button_percent = QPushButton('%')
# * Symbol buttons
self.button_clear_entry = QPushButton('CE')
self.button_clear = QPushButton('C')
self.button_backspace = QPushButton('⌫')
self.button_inverse = QPushButton('+/-')
self.button_dot = QPushButton('.')
self.button_left_bracket = QPushButton('(')
self.button_right_bracket = QPushButton(')')
# * Discount buttons
self.button_CalculateDiscount = QPushButton("Calculate Discount")
# * Temperature buttons
self.button_FirstTemp = QComboBox()
self.button_FirstTemp.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstTemp.addItem("Kelvin")
self.button_FirstTemp.addItem("Celsius")
self.button_FirstTemp.addItem("Fahrenheit")
self.button_FirstTemp.setCurrentIndex(0)
self.button_SecondTemp = QComboBox()
self.button_SecondTemp.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondTemp.addItem("Kelvin")
self.button_SecondTemp.addItem("Celsius")
self.button_SecondTemp.addItem("Fahrenheit")
self.button_SecondTemp.setCurrentIndex(0)
self.button_CalculateTemp = QPushButton("Calculate Temperature")
# * Data buttons
self.button_FirstData = QComboBox()
self.button_FirstData.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstData.addItem("Bits")
self.button_FirstData.addItem("Bytes")
self.button_FirstData.addItem("KiloBytes")
self.button_FirstData.addItem("MegaBytes")
self.button_FirstData.addItem("GigaBytes")
self.button_FirstData.addItem("TeraBytes")
self.button_FirstData.addItem("PetaBytes")
self.button_FirstData.setCurrentIndex(0)
self.button_SecondData = QComboBox()
self.button_SecondData.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondData.addItem("Bits")
self.button_SecondData.addItem("Bytes")
self.button_SecondData.addItem("KiloBytes")
self.button_SecondData.addItem("MegaBytes")
self.button_SecondData.addItem("GigaBytes")
self.button_SecondData.addItem("TeraBytes")
self.button_SecondData.addItem("PetaBytes")
self.button_SecondData.setCurrentIndex(0)
self.button_CalculateData = QPushButton("Calculate Data")
# * Age buttons
self.button_CalculateAge = QPushButton("Calculate Age")
# * Time buttons
self.button_FirstTime = QComboBox()
self.button_FirstTime.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstTime.addItem("Seconds")
self.button_FirstTime.addItem("Minutes")
self.button_FirstTime.addItem("Hours")
self.button_FirstTime.addItem("Days")
self.button_FirstTime.addItem("Months")
self.button_FirstTime.addItem("Years")
self.button_FirstTime.setCurrentIndex(0)
self.button_SecondTime = QComboBox()
self.button_SecondTime.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondTime.addItem("Seconds")
self.button_SecondTime.addItem("Minutes")
self.button_SecondTime.addItem("Hours")
self.button_SecondTime.addItem("Days")
self.button_SecondTime.addItem("Months")
self.button_SecondTime.addItem("Years")
self.button_SecondTime.setCurrentIndex(0)
self.button_CalculateTime = QPushButton("Calculate Time")
# * BMI buttons
self.button_FirstBMI = QComboBox()
self.button_FirstBMI.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstBMI.addItem("KGs/Meters")
self.button_FirstBMI.addItem("Pounds/Inches")
self.button_FirstBMI.setCurrentIndex(0)
self.button_CalculateBMI = QPushButton("Calculate BMI")
# * Date buttons
self.button_CalculateDATE = QPushButton("Calculate Date")
# * Length buttons
self.button_FirstLength = QComboBox()
self.button_FirstLength.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstLength.addItem("Meters")
self.button_FirstLength.addItem("Feet")
self.button_FirstLength.addItem("Kilometers")
self.button_FirstLength.addItem("Miles")
self.button_FirstLength.addItem("Inches")
self.button_FirstLength.addItem("Yards")
self.button_FirstLength.addItem("Nautical Miles")
self.button_FirstLength.setCurrentIndex(0)
self.button_SecondLength = QComboBox()
self.button_SecondLength.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondLength.addItem("Meters")
self.button_SecondLength.addItem("Feet")
self.button_SecondLength.addItem("Kilometers")
self.button_SecondLength.addItem("Miles")
self.button_SecondLength.addItem("Inches")
self.button_SecondLength.addItem("Yards")
self.button_SecondLength.addItem("Nautical Miles")
self.button_SecondLength.setCurrentIndex(0)
self.button_CalculateLength = QPushButton("Calculate Length")
# * Mass buttons
self.button_FirstMass = QComboBox()
self.button_FirstMass.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstMass.addItem("Kilograms")
self.button_FirstMass.addItem("Pounds")
self.button_FirstMass.addItem("Ounces")
self.button_FirstMass.addItem("Carats")
self.button_FirstMass.addItem("Grams")
self.button_FirstMass.setCurrentIndex(0)
self.button_SecondMass = QComboBox()
self.button_SecondMass.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondMass.addItem("Kilograms")
self.button_SecondMass.addItem("Pounds")
self.button_SecondMass.addItem("Ounces")
self.button_SecondMass.addItem("Carats")
self.button_SecondMass.addItem("Grams")
self.button_SecondMass.setCurrentIndex(0)
self.button_CalculateMass = QPushButton("Calculate Mass")
# * Speed buttons
self.button_FirstSpeed = QComboBox()
self.button_FirstSpeed.setGeometry(QRect(10, 10, 10, 10))
self.button_FirstSpeed.addItem("Kilometers/h")
self.button_FirstSpeed.addItem("Miles/h")
self.button_FirstSpeed.addItem("Meters/s")
self.button_FirstSpeed.addItem("Feet/s")
self.button_FirstSpeed.addItem("Machs")
self.button_FirstSpeed.addItem("Knots")
self.button_FirstSpeed.setCurrentIndex(0)
self.button_SecondSpeed = QComboBox()
self.button_SecondSpeed.setGeometry(QRect(10, 10, 10, 10))
self.button_SecondSpeed.addItem("Kilometers/h")
self.button_SecondSpeed.addItem("Miles/h")
self.button_SecondSpeed.addItem("Meters/s")
self.button_SecondSpeed.addItem("Feet/s")
self.button_SecondSpeed.addItem("Machs")
self.button_SecondSpeed.addItem("Knots")
self.button_SecondSpeed.setCurrentIndex(0)
self.button_CalculateSpeed = QPushButton("Calculate Speed")
# ----------------------------
# FOR THE STANDARD CALCULATOR MODE
def _QLineEdit_standard_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box = QFont()
font_symbol_box = QFont()
# ---------------------------------------------------------
self.Dark_Theme()
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'display_box' attribute
font_display_box.setPointSize(font_display_box.pointSize() + 10)
# For the QLineEdit 'symbol_box' attribute
font_symbol_box.setPointSize(font_symbol_box.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
self.display_box.setReadOnly(False)
self.display_box.setAlignment(Qt.AlignRight)
self.display_box.setMaxLength(1000)
self.display_box.setFont(font_display_box)
self.symbol_box.setReadOnly(True)
self.symbol_box.setAlignment(Qt.AlignRight)
self.symbol_box.setMaxLength(250)
self.symbol_box.setFont(font_symbol_box)
# -------------------------------------------------------------
def _QGridLayout_standard_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_standard.setContentsMargins(10, 12, 10, 10)
self.layout_grid_standard.setSpacing(1.8)
# --------------------------------------------
def _QGridLayout_standard(self):
# -- Calculator Standard QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_standard.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the first row of the grid
self.layout_grid_standard.addWidget(self.symbol_box, 1, 1, 1, 4)
# Regards the second row of the grid
self.layout_grid_standard.addWidget(self.display_box, 2, 1, 1, 4)
# Regards the third row of the grid
self.layout_grid_standard.addWidget(self.button_clear_entry, 3, 1)
self.layout_grid_standard.addWidget(self.button_clear, 3, 2)
self.layout_grid_standard.addWidget(self.button_backspace, 3, 3)
self.layout_grid_standard.addWidget(self.button_division, 3, 4)
# Regards the fourth row of the grid
self.layout_grid_standard.addWidget(self.button_times, 4, 4)
# Regards the fifth row of the grid
self.layout_grid_standard.addWidget(self.button_minus, 5, 4)
# Regards the sixth row of the grid
self.layout_grid_standard.addWidget(self.button_plus, 6, 4)
# Regards the seventh row of the grid
self.layout_grid_standard.addWidget(self.button_inverse, 7, 1)
self.layout_grid_standard.addWidget(self.button_dot, 7, 3)
self.layout_grid_standard.addWidget(self.button_equal, 7, 4)
# ------------------------------
def _QPushButton_standard_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Operand buttons
self.button_equal.setFont(font_symbol)
self.button_plus.setFont(font_symbol)
self.button_minus.setFont(font_symbol)
self.button_times.setFont(font_symbol)
self.button_division.setFont(font_symbol)
# * Symbol buttons
self.button_clear_entry.setFont(font_extra)
self.button_clear.setFont(font_extra)
self.button_backspace.setFont(font_extra)
self.button_inverse.setFont(font_extra)
self.button_dot.setFont(font_symbol)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Operand buttons
self.button_equal.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_plus.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_minus.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_times.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_division.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
# * Symbol buttons
self.button_clear_entry.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_clear.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_backspace.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_inverse.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_dot.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
# -----------------------------------------------------------
def _Make_Num_Buttons(self, mode='st'):
names = ('7', '8', '9', '4', '5', '6', '1', '2', '3', '0')
k = 0
if mode == 'sc':
k = 1
j = 4 + (k * 2)
i = 1 + k
for n, name in enumerate(names):
self.button = QPushButton(name, self)
self.button.clicked.connect(self.NumButton_call(name))
self.button.setFont(self.font_button)
self.button.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
if name != '0':
if mode == 'sc':
self.layout_grid_scientific.addWidget(self.button, j, i)
else:
self.layout_grid_standard.addWidget(self.button, j, i)
i = i + 1
if i == 4 + k:
j = j + 1
i = 1 + k
else:
if mode == 'sc':
self.layout_grid_scientific.addWidget(self.button, 9, 3)
else:
self.layout_grid_standard.addWidget(self.button, 7, 2)
# FOR THE TEMPERATURE CALCULATOR MODE
def _QLineEdit_temperature_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_TEMP = QFont()
font_symbol_box_TEMP = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_TEMP' attribute
font_display_box_TEMP.setPointSize(font_display_box_TEMP.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_TEMP' attribute
font_symbol_box_TEMP.setPointSize(font_symbol_box_TEMP.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
self.display_box_TEMP.setReadOnly(False)
self.display_box_TEMP.setAlignment(Qt.AlignRight)
self.display_box_TEMP.setMaxLength(25)
self.display_box_TEMP.setFont(font_display_box_TEMP)
self.symbol_box_TEMP.setFont(font_symbol_box_TEMP)
self.symbol_box_TEMP.setMaxLength(25)
self.symbol_box_TEMP.setAlignment(Qt.AlignRight)
self.symbol_box_TEMP.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_temperature_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_temperature.setContentsMargins(10, 12, 10, 10)
self.layout_grid_temperature.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_temperature_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Temperature buttons
self.button_FirstTemp.setFont(self.font_button)
self.button_SecondTemp.setFont(self.font_button)
self.button_CalculateTemp.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Temperature buttons
self.button_FirstTemp.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_SecondTemp.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_CalculateTemp.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
# -----------------------------------------------------------
def _QGridLayout_temperature(self):
# -- Our 'Temperature' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_temperature.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the first row of the grid
self.layout_grid_temperature.addWidget(self.display_box_TEMP, 1, 1, 1, 4)
# Regards the second row of the grid
self.layout_grid_temperature.addWidget(self.symbol_box_TEMP, 2, 1, 1, 4)
# Regards the fourth row of the grid
self.layout_grid_temperature.addWidget(self.button_FirstTemp, 4, 1)
self.layout_grid_temperature.addWidget(self.button_SecondTemp, 4, 3)
# Regards the sixth row of the grid
self.layout_grid_temperature.addWidget(self.button_CalculateTemp, 6, 2)
# FOR THE DATE CALCULATOR MODE
def _QLineEdit_date_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_DATE = QFont()
font_display_box_DATE_2 = QFont()
font_symbol_box_DATE = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_DATE' attribute
font_display_box_DATE.setPointSize(font_display_box_DATE.pointSize() + 10)
# For the QLineEdit 'font_display_box_DATE_2' attribute
font_display_box_DATE_2.setPointSize(font_display_box_DATE_2.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_DATA' attribute
font_symbol_box_DATE.setPointSize(font_symbol_box_DATE.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- Date
self.display_box_DATE.setReadOnly(False)
self.display_box_DATE.setAlignment(Qt.AlignRight)
self.display_box_DATE.setMaxLength(25)
self.display_box_DATE.setFont(font_display_box_DATE)
self.display_box_DATE_2.setReadOnly(False)
self.display_box_DATE_2.setAlignment(Qt.AlignRight)
self.display_box_DATE_2.setMaxLength(25)
self.display_box_DATE_2.setFont(font_display_box_DATE_2)
self.symbol_box_DATE.setFont(font_symbol_box_DATE)
self.symbol_box_DATE.setMaxLength(25)
self.symbol_box_DATE.setAlignment(Qt.AlignRight)
self.symbol_box_DATE.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_date_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_date.setContentsMargins(10, 12, 10, 10)
self.layout_grid_date.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_date_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Date buttons
self.button_CalculateDATE.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Date buttons
self.button_CalculateDATE.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def _QGridLayout_date(self):
# -- Our 'Date' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_date.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the third row of the grid
self.layout_grid_date.addWidget(self.button_CalculateDATE, 5, 1)
# Regards the fourth row of the grid
self.layout_grid_date.addWidget(self.display_box_DATE, 3, 1, 1, 4)
# Regards the fifth row of the grid
self.layout_grid_date.addWidget(self.display_box_DATE_2, 4, 1, 1, 4)
# Regards the sixth row of the grid
self.layout_grid_date.addWidget(self.symbol_box_DATE, 6, 1, 1, 4)
# FOR THE AGE CALCULATOR MODE
def _QLineEdit_age_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_AGE = QFont()
font_display_box_AGE_2 = QFont()
font_symbol_box_AGE = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_AGE' attribute
font_display_box_AGE.setPointSize(font_display_box_AGE.pointSize() + 10)
# For the QLineEdit 'font_display_box_AGE_2' attribute
font_display_box_AGE_2.setPointSize(font_display_box_AGE_2.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_AGE' attribute
font_symbol_box_AGE.setPointSize(font_symbol_box_AGE.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- Age
self.display_box_AGE.setReadOnly(False)
self.display_box_AGE.setAlignment(Qt.AlignRight)
self.display_box_AGE.setMaxLength(25)
self.display_box_AGE.setFont(font_display_box_AGE)
self.display_box_AGE_2.setReadOnly(False)
self.display_box_AGE_2.setAlignment(Qt.AlignRight)
self.display_box_AGE_2.setMaxLength(25)
self.display_box_AGE_2.setFont(font_display_box_AGE_2)
self.symbol_box_AGE.setFont(font_symbol_box_AGE)
self.symbol_box_AGE.setMaxLength(25)
self.symbol_box_AGE.setAlignment(Qt.AlignRight)
self.symbol_box_AGE.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_age_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_age.setContentsMargins(10, 12, 10, 10)
self.layout_grid_age.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_age_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Age buttons
self.button_CalculateAge.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Age buttons
self.button_CalculateAge.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def _QGridLayout_age(self):
# -- Our 'Age' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_age.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the third row of the grid
self.layout_grid_age.addWidget(self.button_CalculateAge, 5, 1)
# Regards the fourth row of the grid
self.layout_grid_age.addWidget(self.display_box_AGE_2, 3, 1, 1, 4)
# Regards the fifth row of the grid
self.layout_grid_age.addWidget(self.display_box_AGE, 4, 1, 1, 4)
# Regards the sixth row of the grid
self.layout_grid_age.addWidget(self.symbol_box_AGE, 6, 1, 1, 4)
# FOR THE TIME CALCULATOR MODE
def _QLineEdit_time_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_TIME = QFont()
font_symbol_box_TIME = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_TIME' attribute
font_display_box_TIME.setPointSize(font_display_box_TIME.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_TIME' attribute
font_symbol_box_TIME.setPointSize(font_symbol_box_TIME.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- Time
self.display_box_TIME.setReadOnly(False)
self.display_box_TIME.setAlignment(Qt.AlignRight)
self.display_box_TIME.setMaxLength(25)
self.display_box_TIME.setFont(font_display_box_TIME)
self.symbol_box_TIME.setFont(font_symbol_box_TIME)
self.symbol_box_TIME.setMaxLength(25)
self.symbol_box_TIME.setAlignment(Qt.AlignRight)
self.symbol_box_TIME.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_time_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_time.setContentsMargins(10, 12, 10, 10)
self.layout_grid_time.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_time_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Time buttons
self.button_FirstTime.setFont(self.font_button)
self.button_SecondTime.setFont(self.font_button)
self.button_CalculateTime.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Time buttons
self.button_FirstTime.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_SecondTime.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_CalculateTime.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def _QGridLayout_time(self):
# -- Our 'Discount' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_time.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the first row of the grid
self.layout_grid_time.addWidget(self.display_box_TIME, 1, 1, 1, 4)
# Regards the second row of the grid
self.layout_grid_time.addWidget(self.symbol_box_TIME, 2, 1, 1, 4)
# Regards the fourth row of the grid
self.layout_grid_time.addWidget(self.button_FirstTime, 4, 1)
self.layout_grid_time.addWidget(self.button_SecondTime, 4, 3)
# Regards the sixth row of the grid
self.layout_grid_time.addWidget(self.button_CalculateTime, 6, 2)
# FOR THE BMI CALCULATOR MODE
def _QLineEdit_bmi_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_BMI = QFont()
font_display_box_BMI_2 = QFont()
font_symbol_box_BMI = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_BMI' attribute
font_display_box_BMI.setPointSize(font_display_box_BMI.pointSize() + 10)
# For the QLineEdit 'font_display_box_BMI_2' attribute
font_display_box_BMI_2.setPointSize(font_display_box_BMI_2.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_TIME' attribute
font_symbol_box_BMI.setPointSize(font_symbol_box_BMI.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- BMI
self.display_box_BMI.setReadOnly(False)
self.display_box_BMI.setAlignment(Qt.AlignRight)
self.display_box_BMI.setMaxLength(25)
self.display_box_BMI.setFont(font_display_box_BMI)
self.display_box_BMI_2.setReadOnly(False)
self.display_box_BMI_2.setAlignment(Qt.AlignRight)
self.display_box_BMI_2.setMaxLength(25)
self.display_box_BMI_2.setFont(font_display_box_BMI_2)
self.symbol_box_BMI.setFont(font_symbol_box_BMI)
self.symbol_box_BMI.setMaxLength(100)
self.symbol_box_BMI.setAlignment(Qt.AlignRight)
self.symbol_box_BMI.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_bmi_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_bmi.setContentsMargins(10, 12, 10, 10)
self.layout_grid_bmi.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_bmi_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * BMI buttons
self.button_FirstBMI.setFont(self.font_button)
self.button_CalculateBMI.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * BMI buttons
self.button_CalculateBMI.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_FirstBMI.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def _QGridLayout_bmi(self):
# -- Our 'BMI' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_bmi.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the first row of the grid
self.layout_grid_bmi.addWidget(self.display_box_BMI, 1, 1, 1, 4)
# Regards the second row of the grid
self.layout_grid_bmi.addWidget(self.display_box_BMI_2, 2, 1, 1, 4)
# Regards the third row of the grid
self.layout_grid_bmi.addWidget(self.button_FirstBMI, 3, 1)
self.layout_grid_bmi.addWidget(self.button_CalculateBMI, 3, 2)
# Regards the fourth row of the grid
self.layout_grid_bmi.addWidget(self.symbol_box_BMI, 4, 1, 1, 4)
# FOR THE LENGTH CALCULATOR MODE
def _QLineEdit_length_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_LEN = QFont()
font_symbol_box_LEN = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_LEN' attribute
font_display_box_LEN.setPointSize(font_display_box_LEN.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_LEN' attribute
font_symbol_box_LEN.setPointSize(font_symbol_box_LEN.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- Length
self.display_box_LEN.setReadOnly(False)
self.display_box_LEN.setAlignment(Qt.AlignRight)
self.display_box_LEN.setMaxLength(25)
self.display_box_LEN.setFont(font_display_box_LEN)
self.symbol_box_LEN.setFont(font_symbol_box_LEN)
self.symbol_box_LEN.setMaxLength(25)
self.symbol_box_LEN.setAlignment(Qt.AlignRight)
self.symbol_box_LEN.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_length_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_length.setContentsMargins(10, 12, 10, 10)
self.layout_grid_length.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_length_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes
self.font_button.setPointSize(self.font_button.pointSize() + 6)
# For the QPushButton 'symbol(s)' attributes
font_symbol.setPointSize(font_symbol.pointSize() + 6)
font_extra.setPointSize(font_extra.pointSize() + 2)
# ---------------------------------------------------
# * Length buttons
self.button_CalculateLength.setFont(self.font_button)
self.button_FirstLength.setFont(self.font_button)
self.button_SecondLength.setFont(self.font_button)
# ------------------------------------------------------------------
# -- Assigning a size policy to our QPushButton attributes --
# * Length buttons
self.button_CalculateLength.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_FirstLength.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
self.button_SecondLength.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def _QGridLayout_length(self):
# -- Our 'Length' QGridLayout --
# Adding our widgets (QLineEdit, QPushButton etc) to our QGridLayout
# Regards the QMenuBar and it's constant throughout the class
self.layout_grid_length.addWidget(self.menu_bar, 0, 1, 1, 4)
# Regards the first row of the grid
self.layout_grid_length.addWidget(self.display_box_LEN, 1, 1, 1, 4)
# Regards the second row of the grid
self.layout_grid_length.addWidget(self.symbol_box_LEN, 2, 1, 1, 4)
# Regards the fourth row of the grid
self.layout_grid_length.addWidget(self.button_FirstLength, 4, 1)
self.layout_grid_length.addWidget(self.button_SecondLength, 4, 3)
# Regards the sixth row of the grid
self.layout_grid_length.addWidget(self.button_CalculateLength, 6, 2)
# FOR THE MASS CALCULATOR MODE
def _QLineEdit_mass_properties(self):
# -- Creating QFont attributes for the QLineEdit attributes
font_display_box_MASS = QFont()
font_symbol_box_MASS = QFont()
# ---------------------------------------------------------
# -- Creating and setting the properties for the Color Palette
self.palette = QPalette()
self.palette.setColor(QPalette.Window, QColor(53, 53, 53))
self.palette.setColor(QPalette.Base, QColor(25, 25, 25))
self.palette.setColor(QPalette.Text, Qt.white)
self.palette.setColor(QPalette.Button, QColor(53, 53, 53))
self.palette.setColor(QPalette.ButtonText, Qt.white)
self.palette.setColor(QPalette.Highlight, QColor(25, 25, 25))
self.palette.setColor(QPalette.HighlightedText, Qt.gray)
self.setPalette(self.palette)
# -------------------------------------------------------------
# -- Assigning the QFont attributes to the corresponding QLineEdit attributes
# For the QLineEdit 'font_display_box_MASS' attribute
font_display_box_MASS.setPointSize(font_display_box_MASS.pointSize() + 10)
# For the QLineEdit 'font_symbol_box_MASS' attribute
font_symbol_box_MASS.setPointSize(font_symbol_box_MASS.pointSize() + 1)
# ---------------------------------------------------------------------------
# -- Changing some QLineEdit attributes through their functions
# -- Mass
self.display_box_MASS.setReadOnly(False)
self.display_box_MASS.setAlignment(Qt.AlignRight)
self.display_box_MASS.setMaxLength(25)
self.display_box_MASS.setFont(font_display_box_MASS)
self.symbol_box_MASS.setFont(font_symbol_box_MASS)
self.symbol_box_MASS.setMaxLength(25)
self.symbol_box_MASS.setAlignment(Qt.AlignRight)
self.symbol_box_MASS.setReadOnly(True)
# -------------------------------------------------------------
def _QGridLayout_mass_properties(self):
# -- Assigning our QGridLayout's properties --
self.layout_grid_mass.setContentsMargins(10, 12, 10, 10)
self.layout_grid_mass.setSpacing(1.8)
# --------------------------------------------
def _QPushButton_mass_properties(self):
# -- QFont attributes for the QPushButton attributes --
# To change QPushButton's & QLineEdit's attributes font
self.font_button = QFont()
font_symbol = QFont()
font_extra = QFont()
# For the QPushButton 'button(s)' attributes