-
Notifications
You must be signed in to change notification settings - Fork 13
/
AMaDiA.py
1966 lines (1721 loc) · 100 KB
/
AMaDiA.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
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 Python file uses the following encoding: utf-8
Version = "0.17.0"
# Version should be interpreted as: (MAIN).(TOPIC).(FUNCTION).(BUGFIX)
# MAIN marks mayor milestones of the project (like the release)
# TOPIC marks the introduction of
# a new functionality like the addition of a new tab or window that can handle a new mathematical topic
# major internal changes like the introduction of the custom window class
# These introductions are only that: introductions
# Further updates complete the TOPIC. These updates may also be part of a different TOPIC version.
# FUNCTION marks the introduction of new functionality and aim to advance the current TOPIC
# BUGFIX marks very minor updates that:
# fix bugs
# optimize (or even add minor) functions by changing a single line
# edit text
Author = "Robin \'Astus\' Albers"
WindowTitle = "AMaDiA v"
WindowTitle+= Version
WindowTitle+= " by "
WindowTitle+= Author
#region ---------------------------------- imports ----------------------------------
Copyright_Short = """
Copyright (C) 2020 Robin Albers
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import datetime
import platform
if __name__ == "__main__":
print()
print(datetime.datetime.now().strftime('%H:%M:%S'))
print(WindowTitle)
print("Loading Modules")#,end="")
if platform.system() == 'Windows':
try:
import ctypes
myAppId = u'{}{}'.format(WindowTitle , datetime.datetime.now().strftime('%H:%M:%S')) # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myAppId)
except:
pass
from AGeLib import *
import AGeLib
# import qt Modules
from PyQt5.Qt import QApplication, QClipboard # pylint: disable=no-name-in-module
from PyQt5 import QtWidgets,QtCore,QtGui,Qt
#import PyQt5.Qt as Qt
# import standard modules
from distutils.spawn import find_executable
import sys
import socket
import time
import errno
import os
import pathlib
import importlib
import re
import getpass
import traceback
# import Maths modules
import matplotlib
import sympy
from sympy.parsing.sympy_parser import parse_expr
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import colors
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
# Import AMaDiA Core Modules
# To Convert ui to py: (Commands for Anaconda Prompt)
# cd C:"\Users\Robin\Desktop\Projects\AMaDiA\AMaDiA_Files"
# cd /home/robin/Projects/AMaDiA/AMaDiA_Files/
# pyuic5 AMaDiAUI.ui -o AMaDiAUI.py
from AMaDiA_Files.AMaDiAUI import Ui_AMaDiA_Main_Window
from AMaDiA_Files.AMaDiA_Options_UI import Ui_AMaDiA_Options
from AMaDiA_Files import AMaDiA_Widgets as AW
from AMaDiA_Files import AMaDiA_Functions as AF
from AMaDiA_Files import AMaDiA_Classes as AC
from AMaDiA_Files import AMaDiA_ReplacementTables as ART
from AMaDiA_Files import AMaDiA_Threads as AT
from AMaDiA_Files import AstusChat_Client
from AMaDiA_Files import AstusChat_Server
from AMaDiA_Files.Test_Input import Test_Input
# To limit the length of output (Currently used to reduce the length of the y vector when an error in the plotter occurs)
import reprlib
r = reprlib.Repr()
r.maxlist = 20 # max elements displayed for lists
r.maxarray = 20 # max elements displayed for arrays
r.maxother = 500 # max elements displayed for other including np.ndarray
r.maxstring = 40 # max characters displayed for strings
# Load External Libraries
# These are not part of the standard Anaconda package and thus are already part of AMaDiA to make installation easy
#from External_Libraries.python_control_master import control
try:
from External_Libraries.keyboard_master import keyboard
except common_exceptions :
ExceptionOutput(sys.exc_info())
Keyboard_Remap_Works = False
else:
Keyboard_Remap_Works = True
# Slycot is needed for some features of control but can not be included in AMaDiA as it needs system dependent compiling
try:
import slycot
except ModuleNotFoundError:
slycot_Installed = False
else:
slycot_Installed = True
np.set_printoptions(threshold=100)
AltModifier = QtCore.Qt.AltModifier
ControlModifier = QtCore.Qt.ControlModifier
GroupSwitchModifier = QtCore.Qt.GroupSwitchModifier
ShiftModifier = QtCore.Qt.ShiftModifier
MetaModifier = QtCore.Qt.MetaModifier
#endregion
def AltGr_Shortcut(Symbol,shift_Symbol):
if Keyboard_Remap_Works:
if keyboard.is_pressed("shift"):
AltGr_Shift_Shortcut(shift_Symbol)
else:
keyboard.write(Symbol)
keyboard.release("alt")
keyboard.release("control")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")
def AltGr_Shift_Shortcut(Symbol):
if Keyboard_Remap_Works:
keyboard.write(Symbol)
keyboard.release("alt")
keyboard.release("control")
keyboard.press("shift")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")
def Superscript_Shortcut(Symbol):
if Keyboard_Remap_Works:
#keyboard.write("\x08")
keyboard.write(Symbol)
keyboard.write(" ")
keyboard.write("\x08")
else:
print("Could not load External_Libraries.keyboard_master.keyboard")
#region ---------------------------------- Windows ----------------------------------
class AMaDiA_Internal_File_Display_Window(AWWF):
def __init__(self,FileName,parent = None):
try:
super(AMaDiA_Internal_File_Display_Window, self).__init__(parent,True)
self.setWindowTitle(FileName)
self.standardSize = (900, 500)
self.resize(*self.standardSize)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_FileDialogInfoView))
self.centralwidget = QtWidgets.QWidget(self)
self.centralwidget.setAutoFillBackground(True)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.TextBrowser = QtWidgets.QTextBrowser(self)
self.TextBrowser.setObjectName("TextBrowser")
self.gridLayout.addWidget(self.TextBrowser, 0, 0, 0, 0)
self.setCentralWidget(self.centralwidget)
self.load(FileName)
self.setAutoFillBackground(True)
except common_exceptions:
ExceptionOutput(sys.exc_info())
def load(self,FileName):
try:
if "Patchlog" in FileName:
self.setWindowTitle("Patchlog")
#self.FolderPath = os.path.dirname(__file__)
FileName = os.path.join(QtWidgets.QApplication.instance().FolderPath,FileName)
with open(FileName,'r',encoding="utf-8") as text_file:
Text = text_file.read()
List = re.split(r"\nv(0.+):(.+)", Text)
NList = []
i=1
while i < len(List):
NList.append([List[i],"v"+List[i]+":"+List[i+1],List[i+2]])
i+=3
text = ""
for i in reversed(NList):
desc = "<ul>"+re.sub(r"^\+ (.+)$",r"\t<li>\1</li>",
re.sub(r"^\+\+ (.+)$",r"\t\t\t<ul><li>\1</li></ul>",
re.sub(r"^\+\+\+ (.+)$",r"\t\t\t\t<ul><ul><li>\1</li></ul></ul>",
re.sub(r"^\+\+\+\+ (.+)$",r"\t\t\t\t\t<ul><ul><ul><li>\1</li></ul></ul></ul>",i[2],
flags=re.MULTILINE),
flags=re.MULTILINE),
flags=re.MULTILINE),
flags=re.MULTILINE)+"</ul>"
text += "{}{}<br><br>".format(i[1],desc)
self.TextBrowser.setText(text)
else:
self.setWindowTitle(FileName)
#self.FolderPath = os.path.dirname(__file__)
FileName = os.path.join(QtWidgets.QApplication.instance().FolderPath,FileName)
with open(FileName,'r',encoding="utf-8") as text_file:
Text = text_file.read()
#self.TextBrowser.setPlainText(Text)
self.TextBrowser.setText(Text)
except common_exceptions:
NC(1,"Could not load {}".format(str(FileName)),exc=sys.exc_info(),win=self.windowTitle(),func="AMaDiA_Internal_File_Display_Window.load",input=FileName)
def Scroll_To_End(self):
self.TextBrowser.verticalScrollBar().setValue(self.TextBrowser.verticalScrollBar().maximum())
class AMaDiA_About_Window(AWWF):
def __init__(self,parent = None):
try:
super(AMaDiA_About_Window, self).__init__(parent)
self.setWindowTitle("About AMaDiA")
self.standardSize = (400, 600)
self.resize(*self.standardSize)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_DialogHelpButton))
self.centralwidget = QtWidgets.QWidget(self)
self.centralwidget.setAutoFillBackground(True)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.TextBrowser = QtWidgets.QTextBrowser(self)
self.TextBrowser.setObjectName("TextBrowser")
self.gridLayout.addWidget(self.TextBrowser, 0, 0, 0, 0)
#self.layout = QtWidgets.QVBoxLayout()
#self.layout.addWidget(self.TextBrowser)
#self.setLayout(self.layout)
self.setCentralWidget(self.centralwidget)
#Text = WindowTitle+"\nWIP: More coming soon"
#<p> Send comments, ideas and bug reports to: <a href="mailto:[email protected]">[email protected]</a></p>
aboutText = """
<p> <b>AMaDiA v%s</b> </p>
<p> By Robin \"Astus\" Albers.</p>
<p> AMaDiA aims to provide the similar functionality as matlab or mathematica while providing a GUI that is fun to work with.</p>
<p> Furthermore the open source nature and the good documentation from SymPy (which is used for most calculations) allow for scientific work as the entire process can be analysed.</p>
<p> License is GNU GPLv3.</p>
<p> Repo: <a href="https://github.com/AstusRush/AMaDiA">https://github.com/AstusRush/AMaDiA</a></p>
<p>This instance of AMaDiA runs thanks to the following external projects:</p>
<ul>
<li><a href="https://www.python.org/">Python %s</a></li>
<li><a href="https://github.com/AstusRush/AGeLib">AGeLib %s</a></li>
<li><a href="https://www.sympy.org/en/index.html">SymPy %s</a></li>
<li><a href="https://numpy.org/">Numpy %s</a></li>
<li><a href="https://matplotlib.org/">MatplotLib %s</a></li>
<li><a href="https://github.com/boppreh/keyboard">keyboard</a></li>
<li><a href="https://github.com/python-control/python-control/">Python-Control</a></li>
<li><a href="https://www.qt.io/">PyQt %s (Qt %s)</a></li>
</ul>
""" % (Version,
"%d.%d" % (sys.version_info.major, sys.version_info.minor),
AGeLib.__version__,
sympy.__version__,
np.__version__,
matplotlib.__version__,
QtCore.PYQT_VERSION_STR,
QtCore.qVersion())
self.TextBrowser.setText(aboutText)
self.TextBrowser.setOpenExternalLinks(True)
self.setAutoFillBackground(True)
except common_exceptions:
ExceptionOutput(sys.exc_info())
class AMaDiA_exec_Window(AWWF): #CLEANUP: use the standard AGeLib exec_Window
def __init__(self,parent = None):
try:
super(AMaDiA_exec_Window, self).__init__(parent, initTopBar=False)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True, IncludeAdvancedCB=True)
self.setWindowTitle("Code Execution Window")
self.standardSize = (900, 500)
self.resize(*self.standardSize)
self.centralwidget = QtWidgets.QWidget(self)
self.centralwidget.setAutoFillBackground(True)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.Input_Field = AW.AMaDiA_TextEdit(self)
self.Input_Field.setObjectName("Input_Field")
self.gridLayout.addWidget(self.Input_Field, 0, 0, 0, 0)
self.setCentralWidget(self.centralwidget)
self.Input_Field.returnCtrlPressed.connect(self.execute_code)
self.setAutoFillBackground(True)
except common_exceptions:
NC(exc=sys.exc_info(),win=self.windowTitle(),func="AMaDiA_exec_Window.__init__")
def execute_code(self):
input_text = self.Input_Field.toPlainText()
try:
exec(input_text)
except common_exceptions:
NC(exc=sys.exc_info(),win=self.windowTitle(),func="AMaDiA_exec_Window.execute_code",input=input_text)
class AMaDiA_options_window(AWWF, Ui_AMaDiA_Options):
def __init__(self,parent = None):
try:
super(AMaDiA_options_window, self).__init__(parent, includeTopBar=False, initTopBar=False, includeStatusBar=True)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_FileDialogListView))
self.setupUi(self)
self.TopBar = TopBar_Widget(self,False)
self.tabWidget.setCornerWidget(self.TopBar, QtCore.Qt.TopRightCorner)
self.TopBar.init(IncludeFontSpinBox=True,IncludeErrorButton=True)
self.setWindowTitle("Options")
self.standardSize = (900, 500)
self.resize(*self.standardSize)
self.tabWidget.setCurrentIndex(0)
self.setAutoFillBackground(True)
self.ConnectSignals()
except common_exceptions:
ExceptionOutput(sys.exc_info())
def ConnectSignals(self):
self.cb_O_AdvancedMode.clicked.connect(QtWidgets.QApplication.instance().ToggleAdvancedMode)
QtWidgets.QApplication.instance().S_advanced_mode_changed.connect(self.cb_O_AdvancedMode.setChecked)
self.cb_O_Remapper_global.toggled.connect(self.ToggleGlobalRemapper)
self.cb_O_PairHighlighter.toggled.connect(App().S_Highlighter.emit)
def ToggleGlobalRemapper(self):
try:
if self.cb_O_Remapper_global.isChecked():
self.cb_O_Remapper_local.setChecked(False)
self.cb_O_Remapper_local.setDisabled(True)
altgr = "altgr+"
altgrShift = "altgr+shift+"
#keyboard.on_press(print)
#keyboard.add_hotkey("shift",keyboard.release, args=("altgr"),trigger_on_release=True)
#keyboard.block_key("AltGr")
#keyboard.add_hotkey("altgr",keyboard.release, args=("alt+control"), suppress=True)
#keyboard.add_hotkey("control+alt+altgr+shift",keyboard.release, args=("altgr+shift"), suppress=True)
for i in ART.KR_Map:
if i[0]!=" ":
if i[2] != " ":
Key = altgr + i[0]
keyboard.add_hotkey(Key, AltGr_Shortcut, args=(i[2],i[3]), suppress=True, trigger_on_release=True)
#keyboard.add_hotkey(Key, keyboard.write, args=(i[2]), suppress=True, trigger_on_release=True)
if i[3] != " ":
Key = altgrShift + i[0]
keyboard.add_hotkey(Key, AltGr_Shift_Shortcut, args=(i[3]), suppress=True, trigger_on_release=True)
#keyboard.add_hotkey(Key, keyboard.write, args=(i[3]), suppress=True, trigger_on_release=True)
if i[4] != " ":
Key = "^+"+i[0]
keyboard.add_hotkey(Key, Superscript_Shortcut, args=(i[4]), suppress=True, trigger_on_release=True)
#keyboard.add_hotkey(Key, keyboard.write, args=(i[4]), suppress=True, trigger_on_release=True)
else:
keyboard.clear_all_hotkeys()
self.cb_O_Remapper_local.setEnabled(True)
self.cb_O_Remapper_local.setChecked(True)
except common_exceptions :
try:
NC(exc=sys.exc_info(),win=self.windowTitle(),func="AMaDiA_options_window.ToggleGlobalRemapper",input="Failed to map {} to {}".format(str(i),str(Key)))
except common_exceptions :
NC(exc=sys.exc_info(),win=self.windowTitle(),func="AMaDiA_options_window.ToggleGlobalRemapper",input="Could not determine failed remap operation.")
#endregion
# ---------------------------------- Main Application ----------------------------------
class AMaDiA_Main_App(Main_App):
#
# See:
# https://doc.qt.io/qt-5/qapplication.html
# https://doc.qt.io/qt-5/qguiapplication.html
# https://doc.qt.io/qt-5/qcoreapplication.html
S_New_Notification = QtCore.pyqtSignal(NC)
S_Highlighter = QtCore.pyqtSignal(bool)
def __init__(self, args):
super(AMaDiA_Main_App, self).__init__(args)
self.installEventFilter(self)
self.MainWindow = None
self.setApplicationName("AMaDiA")
self.setApplicationVersion(Version)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(QtWidgets.QStyle.SP_ComputerIcon))
self.Colour_Font_Init()
self.AMaDiA_exec_Window_Window = None
def eventFilter(self, source, event):
if event.type() == 6: # QtCore.QEvent.KeyPress
#if event.modifiers() == ControlModifier:
# pass
#if event.modifiers() == AltModifier:
# pass
# #if event.key() == QtCore.Qt.Key_O: #Already part of AGeLib
# # self.Show_Options()
# # return True
if source == self.MainWindow: # THIS IS SPECIFIC TO AMaDiA_Main_Window
if event.modifiers() == ControlModifier:
if event.key() == QtCore.Qt.Key_1:
self.MainWindow.tabWidget.setCurrentIndex(0)
self.MainWindow.Tab_1_InputField.setFocus()
return True
elif event.key() == QtCore.Qt.Key_2:
self.MainWindow.tabWidget.setCurrentIndex(1)
self.MainWindow.Tab_2_InputField.setFocus()
return True
elif event.key() == QtCore.Qt.Key_3:
self.MainWindow.tabWidget.setCurrentIndex(2)
if self.MainWindow.Tab_3_tabWidget.currentIndex() == 0:
self.MainWindow.Tab_3_1_Formula_Field.setFocus()
return True
elif event.key() == QtCore.Qt.Key_4:
self.MainWindow.tabWidget.setCurrentIndex(3)
return True
elif event.key() == QtCore.Qt.Key_5:
self.MainWindow.tabWidget.setCurrentIndex(4)
return True
try: # THIS IS SPECIFIC TO AMaDiA_Main_Window # FEATURE: Add superscript Macros
#if self.MainWindow.Menu_Options_action_Use_Local_Keyboard_Remapper.isChecked():
if self.optionWindow.cb_O_Remapper_local.isChecked():
modifiers = QtWidgets.QApplication.keyboardModifiers() # instead of event.modifiers() to be more reliable
if modifiers == (GroupSwitchModifier | ShiftModifier) or modifiers == (ControlModifier | AltModifier | ShiftModifier):
for i in ART.KR_Map:
if event.key() == i[5] and i[3]!=" ":
try:
if type(source) == QtWidgets.QLineEdit or type(source) == AstusChat_Client.InputFieldClass:
source.insert(i[3])
return True
except:
pass
try:
cursor = source.textCursor()
cursor.insertText(i[3])
return True
except:
break
elif modifiers == GroupSwitchModifier or modifiers == (ControlModifier | AltModifier):
for i in ART.KR_Map:
if event.key() == i[5] and i[2]!=" ":
try:
if type(source) == QtWidgets.QLineEdit or type(source) == AstusChat_Client.InputFieldClass:
source.insert(i[2])
return True
except:
pass
try:
cursor = source.textCursor()
cursor.insertText(i[2])
return True
except:
break
except AttributeError:
pass
return super(AMaDiA_Main_App, self).eventFilter(source, event)
# ---------------------------------- Colour and Font ----------------------------------
#def Recolour(self, Colour = "Dark"):
# super(AMaDiA_Main_App, self).Recolour(Colour)
# if self.MainWindow != None: # THIS IS SPECIFIC TO AMaDiA_Main_Window
# try:
# self.MainWindow.init_Animations_With_Colour()
# brush = self.Palette.text()
# for i in range(self.MainWindow.Tab_3_1_History.count()):
# if self.MainWindow.Tab_3_1_History.item(i).data(100).current_ax == None:
# self.MainWindow.Tab_3_1_History.item(i).setForeground(brush)
# except common_exceptions:
# ExceptionOutput(sys.exc_info())
def r_Recolour(self):
if self.MainWindow != None:
try:
self.MainWindow.init_Animations_With_Colour()
brush = self.Palette.text()
for i in range(self.MainWindow.Tab_3_1_History.count()):
if self.MainWindow.Tab_3_1_History.item(i).data(100).current_ax == None:
self.MainWindow.Tab_3_1_History.item(i).setForeground(brush)
self.MainWindow.Tab_1_InputField.setPalette(self.Palette2)
self.MainWindow.Tab_2_InputField.setPalette(self.Palette2)
self.MainWindow.Tab_3_1_Formula_Field.setPalette(self.Palette2)
self.MainWindow.Tab_4_FormulaInput.setPalette(self.Palette2)
except common_exceptions:
ExceptionOutput(sys.exc_info())
# ---------------------------------- SubWindows ----------------------------------
def r_init_Options(self):
self.optionWindow = AMaDiA_options_window()
#def Show_exec_Window(self): #CLEANUP: use the standard AGeLib exec_Window
# if self.AMaDiA_exec_Window_Window == None:
# self.AMaDiA_exec_Window_Window = AMaDiA_exec_Window()
# self.AMaDiA_exec_Window_Window.show()
# ---------------------------------- Other ----------------------------------
def r_CreateFolders(self):
try:
if self.AGeLibPathOK:
# Create Plots folder to save plots
self.PlotPath = os.path.join(os.path.join(self.AGeLibPath,"AMaDiA"),"Plots")
os.makedirs(self.PlotPath,exist_ok=True)
# Create Config folder to save configs
self.ConfigFolderPath = os.path.join(os.path.join(self.AGeLibPath,"AMaDiA"),"Config")
os.makedirs(self.ConfigFolderPath,exist_ok=True)
self.pathOK = False
# Find the install location of AMaDiA to load the help files
self.selfPath = os.path.abspath(__file__)
self.FolderPath = os.path.dirname(__file__)
# Check if the path that was returned is correct
filePath = os.path.join(self.FolderPath,"AMaDiA.py")
filePath = pathlib.Path(filePath)
if filePath.is_file():
self.pathOK = True
except:
NC(1,"Could not create/validate AMaDiA folders",exc=sys.exc_info())
# ---------------------------------- Main Window ----------------------------------
class AMaDiA_Main_Window(AWWF, Ui_AMaDiA_Main_Window):
S_Terminate_Threads = QtCore.pyqtSignal()
def __init__(self, MainApp, parent = None):
super(AMaDiA_Main_Window, self).__init__(parent,initTopBar=False)
# Read all config files:
# FEATURE: Implement config files
sympy.init_printing() # doctest: +SKIP
self.MainApp = MainApp #CLEANUP: remove self.MainApp since App() has replaced it
App().setMainWindow(self)
#FEATURE: Add Statistic Tab to easily compare numbers and check impact of variables etc
#FEATURE: Make a subtab that makes https://www.youtube.com/watch?v=ovJcsL7vyrk and similar things plottable
# Build the UI
self.init_Menu()
self.setupUi(self)
self.TopBar.init(True,True,True)
self.TopBar.setObjectName("TopBar")
#self.TopBarGridLayout = QtWidgets.QGridLayout(self.TopBar)
#self.TopBarGridLayout.setContentsMargins(0, 0, 0, 0)
#self.TopBarGridLayout.setSpacing(0)
#self.TopBarGridLayout.setObjectName("TopBarGridLayout")
#self.TopBar.setLayout(self.TopBarGridLayout)
self.standardSize = (906, 634)
self.resize(*self.standardSize)
self.tabWidget.setContentsMargins(0,0,0,0)
#self.tabWidget.tabBar(). # Access the TabBar of the TabWidget
self.tabWidget.tabBar().setUsesScrollButtons(True)
self.tabWidget.tabBar().setGeometry(QtCore.QRect(0, 0, 906, 20)) # CLEANUP: Is this necessary?
self.tabWidget.tabBar().installEventFilter(self.TopBar)
#self.MenuBar.setContentsMargins(0,0,0,0)
#QtWidgets.QMainWindow.setMenuBar(self,self.MenuBar) # This allows the extension functionality but has no frame...
#self.setMenuBar(self.MenuBar) # This breaks the extension functionality but has a frame...
#self.MenuBar.setCornerWidget(self.TopBar)
self.Tab_3_1_Button_Plot_SymPy.setVisible(False) # CLEANUP: The Control Tab Has broken the Sympy plotter... Repairing it is not worth it... Remove this function...
self.Tab_3_tabWidget.removeTab(1)# FEATURE: Add Complex plotter
# TODO: Find place to display WindowTitle. Maybe with a TextLabel in the statusbar?
# MAYBE: Do something with the Statusbar
#self.statusbar.showMessage(WindowTitle)
#self.statusbar.setSizeGripEnabled(False)
# Set UI variables
#Set starting tabs
self.Tab_3_tabWidget.setCurrentIndex(0)
self.Tab_3_1_TabWidget.setCurrentIndex(0)
self.Tab_4_tabWidget.setCurrentIndex(0)
self.tabWidget.setCurrentIndex(0)
#Set Splitter Start Values
self.Tab_2_UpperSplitter.setSizes([163,699])
self.Tab_2_LowerSplitter.setSizes([391,70])
self.Tab_3_1_splitter.setSizes([297,565])
#To configure use:
#print(self.Tab_2_UpperSplitter.sizes())
#print(self.Tab_2_LowerSplitter.sizes())
#print(self.Tab_3_1_splitter.sizes())
# Initialize subwindow variables
self.ControlWindow = None
self.AMaDiA_About_Window_Window = None
self.Chat = None
self.Sever = None
self.AMaDiA_Text_File_Window = {}
# Initialize important variables and lists
self.workingThreads = 0
self.LastOpenState = self.showNormal
self.Bool_PreloadLaTeX = True
self.firstrelease = False
self.keylist = []
self.Tab_2_Eval_checkBox.setCheckState(1)
#QtWidgets.QCheckBox.setCheckState(1)
# Initialize Thread Related Things:
self.ThreadList = []
self.oldThreadpools = []
self.threadpool = QtCore.QThreadPool()#.globalInstance()
#self.threadpool.setMaxThreadCount(8)
print("Multithreading with maximum %d threads (when in Threadpool mode)" % self.threadpool.maxThreadCount())
# Thread Mode
self.Threading = "POOL"
#self.Threading = "LIST"
# Set the Text
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("AMaDiA" , WindowTitle))
# EventFilter
self.installEventFilter(self)
# Set up context menus for the histories and other list widgets
for i in self.findChildren(QtWidgets.QListWidget):
i.installEventFilter(self)
# Set up text input related Event Handlers
for i in self.findChildren(QtWidgets.QTextEdit):
i.installEventFilter(self)
for i in self.findChildren(QtWidgets.QLineEdit):
i.installEventFilter(self)
# Activate Pretty-LaTeX-Mode if the Computer supports it
if AF.LaTeX_dvipng_Installed:
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setEnabled(True)
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setChecked(True)
# Run other init methods
self.ConnectSignals()
#self.Colour_Font_Init()
App().Recolour() #IMPROVE: This takes long but is necessary to initialize the Plots.
# This could probably be done in the init of the canvas to reduce start time
# But the Signal S_ColourChanged as well as the method r_Recolour are now used for other UI elements as well thus Recolour MUST be called or the other inits must be changed, too
self.OtherContextMenuSetup()
self.InstallSyntaxHighlighter()
self.INIT_Animation()
# Initialize the first equation in Tab 4
self.Tab_4_2_New_Equation_Name_Input.setText("Equation 1")
self.Tab_4_F_New_Equation()
self.Tab_4_2_New_Equation_Name_Input.clear()
self.Tab_4_1_Dimension_Input.setText(" 3x3 ")
self.Tab_4_Currently_Displayed = ""
self.Tab_4_Currently_Displayed_Solution = ""
# Other things:
# VALIDATE: Check if this fixes the bug on the Laptop --> The Bug is fixed but the question remains wether this is what fixed it
self.Tab_3_1_F_Clear()
#One Little Bug Fix:
#If using LaTeX Display in LaTeX Mode before using the Plotter for the first time it can happen that the plotter is not responsive until cleared.
#Thus the plotter is now cleared on program start to **hopefully** fix this...
#If it does not fix the problem a more elaborate method is required...
# A new variable that checks if the plot has already been used and if the LaTeX view has been used.
# If the first is False and the second True then clear when the plot button is pressed and change the variables to ensure that this only happens once
# to not accidentally erase the plots of the user as this would be really bad...
self.Tab_1_InputField.setFocus()
# Welcome Message and preload LaTeX
msg = ""
if not AF.LaTeX_dvipng_Installed:
msg += "Please install LaTeX and dvipng to enable the LaTeX output mode"
elif self.Bool_PreloadLaTeX:
print("Starting LaTeX")
self.Tab_2_Viewer.PreloadLaTeX()
if not slycot_Installed:
if msg != "":
msg += "\n\n"
msg += "slycot is not installed. The Control Tab might not work correctly\n"
msg += "If you have conda installed use: conda install -c conda-forge slycot\n"
msg += "Otherwise refer to: https://github.com/python-control/Slycot"
if not Keyboard_Remap_Works:
if msg != "":
msg += "\n\n"
msg += "The Keyboard Remapping does not work\n"
msg += "If you are using Linux you need to run as root to enable Keyboard Remapping"
if msg != "":
NC(3,msg,win=self.windowTitle(),func="AMaDiA_Main_Window.__init__")
else:
try:
msg = "Welcome " + getpass.getuser()
#msg += ". How can I be of service?"
NC(10,msg,win=self.windowTitle(),func="AMaDiA_Main_Window.__init__")
except:
Error = ExceptionOutput(sys.exc_info())
NC(10,"Welcome Dave",err=str(Error),win=self.windowTitle(),func="AMaDiA_Main_Window.__init__")
# ---------------------------------- Init and Maintenance ----------------------------------
def ConnectSignals(self):
self.Menu_Options_action_ToggleCompactMenu.changed.connect(self.ToggleCompactMenu)
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.toggled.connect(self.ToggleRemapper)
self.Menu_Options_action_Options.triggered.connect(App().Show_Options)
self.Menu_Options_action_Advanced_Mode.toggled.connect(QtWidgets.QApplication.instance().ToggleAdvancedMode)
QtWidgets.QApplication.instance().S_advanced_mode_changed.connect(self.Menu_Options_action_Advanced_Mode.setChecked)
App().optionWindow.cb_F_EvalF.toggled.connect(self.Menu_Options_action_Eval_Functions.setChecked)
self.Menu_Options_action_Eval_Functions.toggled.connect(App().optionWindow.cb_F_EvalF.setChecked)
App().optionWindow.cb_O_PairHighlighter.toggled.connect(self.Menu_Options_action_Highlighter.setChecked)
self.Menu_Options_action_Highlighter.toggled.connect(App().optionWindow.cb_O_PairHighlighter.setChecked)
self.Menu_Options_action_Highlighter.toggled.connect(App().S_Highlighter.emit)
self.Menu_DevOptions_action_Dev_Function.triggered.connect(self.Dev_Function)
self.Menu_DevOptions_action_Show_AMaDiA_exec_Window.triggered.connect(App().Show_exec_Window)
self.Menu_DevOptions_action_Use_Threadpool.changed.connect(self.ToggleThreadMode)
self.Menu_DevOptions_action_Terminate_All_Threads.triggered.connect(self.TerminateAllThreads)
self.Menu_Chat_action_Open_Client.triggered.connect(self.OpenClient)
self.Menu_Chat_action_Open_Server.triggered.connect(self.OpenServer)
#self.Menu_Colour_action_Dark.triggered.connect(lambda: self.Recolour("Dark"))
#self.Menu_Colour_action_Bright.triggered.connect(lambda: self.Recolour("Bright"))
self.Menu_OtherWindows_action_SystemControl.triggered.connect(self.OpenControlWindow)
self.Menu_Help_action_Examples.triggered.connect(lambda: self.Show_AMaDiA_Text_File("InputExamples.txt"))
self.Menu_Help_action_Helpful_Commands.triggered.connect(lambda: self.Show_AMaDiA_Text_File("Helpful_Useable_Syntax.txt"))
self.Menu_Help_action_Patchlog.triggered.connect(lambda: self.Show_AMaDiA_Text_File("Patchlog.txt"))
self.Menu_Help_action_About.triggered.connect(self.Show_About)
self.Tab_1_History.itemDoubleClicked.connect(self.Tab_1_F_Item_doubleClicked)
self.Tab_1_InputField.returnPressed.connect(self.Tab_1_F_Calculate_Field_Input)
self.Tab_2_History.itemDoubleClicked.connect(self.Tab_2_F_Item_doubleClicked)
self.Tab_2_LaTeXCopyButton.clicked.connect(self.Tab_2_Viewer.action_Copy_LaTeX)
self.Tab_2_ConvertButton.clicked.connect(self.Tab_2_F_Convert)
self.Tab_2_InputField.returnCtrlPressed.connect(self.Tab_2_F_Convert)
self.Tab_3_1_History.itemDoubleClicked.connect(self.Tab_3_1_F_Item_doubleClicked)
self.Tab_3_1_Button_Plot.clicked.connect(self.Tab_3_1_F_Plot_Button)
self.Tab_3_1_Formula_Field.returnPressed.connect(self.Tab_3_1_F_Plot_Button)
self.Tab_3_1_Button_Clear.clicked.connect(self.Tab_3_1_F_Clear)
self.Tab_3_1_Button_Plot_SymPy.clicked.connect(self.Tab_3_1_F_Sympy_Plot_Button)
self.Tab_3_1_RedrawPlot_Button.clicked.connect(self.Tab_3_1_F_RedrawPlot)
self.Tab_3_1_Button_SavePlot.clicked.connect(self.action_tab_3_tab_1_Display_SavePlt)
self.Tab_4_FormulaInput.returnPressed.connect(self.Tab_4_F_Update_Equation)
self.Tab_4_1_Dimension_Input.returnPressed.connect(self.Tab_4_F_Config_Matrix_Dim)
self.Tab_4_1_Configure_Button.clicked.connect(self.Tab_4_F_Config_Matrix_Dim)
self.Tab_4_1_Name_Input.returnPressed.connect(self.Tab_4_F_Save_Matrix)
self.Tab_4_1_Save_Matrix_Button.clicked.connect(self.Tab_4_F_Save_Matrix)
self.Tab_4_2_New_Equation_Button.clicked.connect(self.Tab_4_F_New_Equation)
self.Tab_4_2_New_Equation_Name_Input.returnPressed.connect(self.Tab_4_F_New_Equation)
self.Tab_4_2_Load_Selected_Button.clicked.connect(self.Tab_4_F_Load_Selected_Equation)
def init_Menu(self,FirstTime=True):
if FirstTime:
self.Menu = QtWidgets.QMenu(self)
self.Menu.setObjectName("Menu")
#self.MenuBar = AW.MMenuBar(self)
#self.MenuBar.setObjectName("MenuBar")
# Create submenus
if FirstTime:
self.Menu_Options = QtWidgets.QMenu(self.Menu)
self.Menu_Options.setObjectName("Menu_Options")
self.Menu_DevOptions = QtWidgets.QMenu(self.Menu)
self.Menu_DevOptions.setObjectName("Menu_DevOptions")
self.Menu_Chat = QtWidgets.QMenu(self.Menu)
self.Menu_Chat.setObjectName("Menu_Chat")
#self.Menu_Colour = QtWidgets.QMenu(self.Menu)
#self.Menu_Colour.setObjectName("Menu_Colour")
self.Menu_OtherWindows = QtWidgets.QMenu(self.Menu)
self.Menu_OtherWindows.setObjectName("Menu_OtherWindows")
self.Menu_Help = QtWidgets.QMenu(self.Menu)
self.Menu_Help.setObjectName("Menu_Help")
#self.Menu_Options_MathRemap = QtWidgets.QMenu(self.Menu_Options)
#self.Menu_Options_MathRemap.setObjectName("Menu_Options_MathRemap")
# Create Actions
if FirstTime:
self.Menu_Options_action_Options = MenuAction(self)
self.Menu_Options_action_Options.setObjectName("Menu_Options_action_Options")
self.Menu_Options_action_ToggleCompactMenu = MenuAction(self)
self.Menu_Options_action_ToggleCompactMenu.setCheckable(True)
self.Menu_Options_action_ToggleCompactMenu.setObjectName("Menu_Options_action_ToggleCompactMenu")
self.Menu_Options_action_ToggleCompactMenu.setChecked(False)
self.Menu_Options_action_Advanced_Mode = MenuAction(self)
self.Menu_Options_action_Advanced_Mode.setCheckable(True)
self.Menu_Options_action_Advanced_Mode.setObjectName("Menu_Options_action_Advanced_Mode")
self.Menu_Options_action_Eval_Functions = MenuAction(self)
self.Menu_Options_action_Eval_Functions.setCheckable(True)
self.Menu_Options_action_Eval_Functions.setChecked(True)
self.Menu_Options_action_Eval_Functions.setObjectName("Menu_Options_action_Eval_Functions")
self.Menu_Options_action_Use_Pretty_LaTeX_Display = MenuAction(self)
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setCheckable(True)
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setEnabled(False)
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setObjectName("Menu_Options_action_Use_Pretty_LaTeX_Display")
self.Menu_Options_action_Syntax_Highlighter = MenuAction(self)
self.Menu_Options_action_Syntax_Highlighter.setCheckable(True)
self.Menu_Options_action_Syntax_Highlighter.setChecked(True)
self.Menu_Options_action_Syntax_Highlighter.setObjectName("Menu_Options_action_Syntax_Highlighter")
#self.Menu_Options_action_Use_Local_Keyboard_Remapper = MenuAction(self)
#self.Menu_Options_action_Use_Local_Keyboard_Remapper.setCheckable(True)
#self.Menu_Options_action_Use_Local_Keyboard_Remapper.setChecked(True)
#self.Menu_Options_action_Use_Local_Keyboard_Remapper.setObjectName("Menu_Options_action_Use_Local_Keyboard_Remapper")
#self.Menu_Options_action_Use_Global_Keyboard_Remapper = MenuAction(self)
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.setCheckable(True)
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.setObjectName("Menu_Options_action_Use_Global_Keyboard_Remapper")
self.Menu_Options_action_Highlighter = MenuAction(self)
self.Menu_Options_action_Highlighter.setCheckable(True)
self.Menu_Options_action_Highlighter.setChecked(True)
self.Menu_Options_action_Highlighter.setObjectName("Menu_Options_action_Highlighter")
self.Menu_DevOptions_action_Dev_Function = MenuAction(self)
self.Menu_DevOptions_action_Dev_Function.setObjectName("Menu_DevOptions_action_Dev_Function")
self.Menu_DevOptions_action_Show_AMaDiA_exec_Window = MenuAction(self)
self.Menu_DevOptions_action_Show_AMaDiA_exec_Window.setObjectName("Menu_DevOptions_action_Show_AMaDiA_exec_Window")
self.Menu_DevOptions_action_Use_Threadpool = MenuAction(self)
self.Menu_DevOptions_action_Use_Threadpool.setCheckable(True)
self.Menu_DevOptions_action_Use_Threadpool.setChecked(True)
self.Menu_DevOptions_action_Use_Threadpool.setObjectName("Menu_DevOptions_action_Use_Threadpool")
self.Menu_DevOptions_action_Terminate_All_Threads = MenuAction(self)
self.Menu_DevOptions_action_Terminate_All_Threads.setObjectName("Menu_DevOptions_action_Terminate_All_Threads")
self.Menu_Chat_action_Open_Client = MenuAction(self)
self.Menu_Chat_action_Open_Client.setObjectName("Menu_Chat_action_Open_Client")
self.Menu_Chat_action_Open_Server = MenuAction(self)
self.Menu_Chat_action_Open_Server.setObjectName("Menu_Chat_action_Open_Server")
#self.Menu_Colour_action_Dark = MenuAction(self)
#self.Menu_Colour_action_Dark.setObjectName("Menu_Colour_action_Dark")
#self.Menu_Colour_action_Bright = MenuAction(self)
#self.Menu_Colour_action_Bright.setObjectName("Menu_Colour_action_Bright")
self.Menu_OtherWindows_action_SystemControl = MenuAction(self)
self.Menu_OtherWindows_action_SystemControl.setObjectName("Menu_OtherWindows_action_SystemControl")
self.Menu_Help_action_Examples = MenuAction(self)
self.Menu_Help_action_Examples.setObjectName("Menu_Help_action_Examples")
self.Menu_Help_action_Helpful_Commands = MenuAction(self)
self.Menu_Help_action_Helpful_Commands.setObjectName("Menu_Help_action_Helpful_Commands")
self.Menu_Help_action_License = MenuAction(self)
self.Menu_Help_action_License.setObjectName("Menu_Help_action_License")
self.Menu_Help_action_About = MenuAction(self)
self.Menu_Help_action_About.setObjectName("Menu_Help_action_About")
self.Menu_Help_action_Patchlog = MenuAction(self)
self.Menu_Help_action_Patchlog.setObjectName("Menu_Help_action_Patchlog")
# Add the Actions to the Submenus
if FirstTime:
self.Menu_Options.addAction(self.Menu_Options_action_Options)
self.Menu_Options.addAction(self.Menu_Options_action_ToggleCompactMenu)
self.Menu_Options.addAction(self.Menu_Options_action_Advanced_Mode)
self.Menu_Options.addAction(self.Menu_Options_action_Eval_Functions)
self.Menu_Options.addAction(self.Menu_Options_action_Use_Pretty_LaTeX_Display)
#self.Menu_Options_MathRemap.addAction(self.Menu_Options_action_Use_Local_Keyboard_Remapper)
#self.Menu_Options_MathRemap.addAction(self.Menu_Options_action_Use_Global_Keyboard_Remapper)
#self.Menu_Options.addAction(self.Menu_Options_MathRemap.menuAction())
self.Menu_Options.addAction(self.Menu_Options_action_Highlighter)
self.Menu_DevOptions.addAction(self.Menu_DevOptions_action_Dev_Function)
self.Menu_DevOptions.addAction(self.Menu_DevOptions_action_Show_AMaDiA_exec_Window)
self.Menu_DevOptions.addAction(self.Menu_DevOptions_action_Use_Threadpool)
self.Menu_DevOptions.addAction(self.Menu_DevOptions_action_Terminate_All_Threads)
self.Menu_Chat.addAction(self.Menu_Chat_action_Open_Client)
self.Menu_Chat.addAction(self.Menu_Chat_action_Open_Server)
#self.Menu_Colour.addAction(self.Menu_Colour_action_Dark)
#self.Menu_Colour.addAction(self.Menu_Colour_action_Bright)
self.Menu_OtherWindows.addAction(self.Menu_OtherWindows_action_SystemControl)
self.Menu_Help.addAction(self.Menu_Help_action_Examples)
self.Menu_Help.addAction(self.Menu_Help_action_Helpful_Commands)
self.Menu_Help.addAction(self.Menu_Help_action_Patchlog)
self.Menu_Help.addAction(self.Menu_Help_action_About)
# Add submenus to Menu
self.Menu.addAction(self.Menu_Options.menuAction())
self.MenuBar.addAction(self.Menu_Options.menuAction())
self.Menu.addAction(self.Menu_DevOptions.menuAction())
self.MenuBar.addAction(self.Menu_DevOptions.menuAction())
#self.Menu.addAction(self.Menu_Colour.menuAction())
#self.MenuBar.addAction(self.Menu_Colour.menuAction())
self.Menu.addAction(self.Menu_Chat.menuAction())
self.MenuBar.addAction(self.Menu_Chat.menuAction())
self.Menu.addAction(self.Menu_OtherWindows.menuAction())
self.MenuBar.addAction(self.Menu_OtherWindows.menuAction())
self.Menu.addAction(self.Menu_Help.menuAction())
self.MenuBar.addAction(self.Menu_Help.menuAction())
# Set the text of the menus
if FirstTime:
_translate = QtCore.QCoreApplication.translate
self.Menu_Options.setTitle(_translate("AMaDiA_Main_Window", "O&ptions"))
self.Menu_DevOptions.setTitle(_translate("AMaDiA_Main_Window", "DevOptions"))
self.Menu_Chat.setTitle(_translate("AMaDiA_Main_Window", "Chat"))
#self.Menu_Colour.setTitle(_translate("AMaDiA_Main_Window", "Colour"))
self.Menu_OtherWindows.setTitle(_translate("AMaDiA_Main_Window", "More Windows"))
self.Menu_Help.setTitle(_translate("AMaDiA_Main_Window", "Help"))
self.Menu_Options_action_Options.setText(_translate("AMaDiA_Main_Window", "&Options"))
self.Menu_Options_action_Options.setShortcut(_translate("AMaDiA_Main_Window", "Alt+O"))
self.Menu_Options_action_ToggleCompactMenu.setText(_translate("AMaDiA_Main_Window", "&Compact Menu"))
self.Menu_Options_action_ToggleCompactMenu.setShortcut(_translate("AMaDiA_Main_Window", "Alt+C"))
self.Menu_Options_action_Advanced_Mode.setText(_translate("AMaDiA_Main_Window", "&Advanced Mode"))
self.Menu_Options_action_Advanced_Mode.setShortcut(_translate("AMaDiA_Main_Window", "Alt+A"))
self.Menu_Options_action_Eval_Functions.setText(_translate("AMaDiA_Main_Window", "&Eval Functions"))
self.Menu_Options_action_Eval_Functions.setToolTip(_translate("AMaDiA_Main_Window", "If unchecked functions that would return a float are not evaluated to ensure readability"))
self.Menu_Options_action_Eval_Functions.setShortcut(_translate("AMaDiA_Main_Window", "Alt+E"))
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setText(_translate("AMaDiA_Main_Window", "Use Pretty &LaTeX Display"))
self.Menu_Options_action_Use_Pretty_LaTeX_Display.setShortcut(_translate("AMaDiA_Main_Window", "Alt+L"))
self.Menu_Options_action_Syntax_Highlighter.setText(_translate("AMaDiA_Main_Window", "Syntax Highlighter"))
self.Menu_Options_action_Highlighter.setToolTip(_translate("AMaDiA_Main_Window", "Syntax Highlighter for Brackets"))
self.Menu_Options_action_Highlighter.setText(_translate("AMaDiA_Main_Window", "Highlighter"))
#self.Menu_Options_MathRemap.setTitle(_translate("AMaDiA_Main_Window", "MathKeyboard"))
#self.Menu_Options_action_Use_Local_Keyboard_Remapper.setToolTip(_translate("AMaDiA_Main_Window", "<html><head/><body><p>Use (Shift+)AltGr+Key to type Mathematical Symbols.<br/>Refer to AMaDiA_ReplacementTables for mapping.<br/>For a Remapping that works on all applications use the Global Remapper in the Options.</p></body></html>"))
#self.Menu_Options_action_Use_Local_Keyboard_Remapper.setText(_translate("AMaDiA_Main_Window", "Local Keyboard Remapper"))
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.setText(_translate("AMaDiA_Main_Window", "Global Keyboard Remapper"))
#self.Menu_Options_action_Use_Global_Keyboard_Remapper.setToolTip(_translate("AMaDiA_Main_Window", "<html><head/><body><p>Use (Shift+)AltGr+Key to type Mathematical Symbols.<br/>Refer to AMaDiA_ReplacementTables for mapping.<br/>This works for all inputs including those in other applications!<br/>(This might cause problems with anti cheat systems in games. Use with care.)</p></body></html>"))
self.Menu_DevOptions_action_Dev_Function.setText(_translate("AMaDiA_Main_Window", "&Dev Function"))
self.Menu_DevOptions_action_Dev_Function.setShortcut(_translate("AMaDiA_Main_Window", "Alt+D"))
self.Menu_DevOptions_action_Show_AMaDiA_exec_Window.setText(_translate("AMaDiA_Main_Window", "Show Debug Terminal"))
self.Menu_DevOptions_action_Use_Threadpool.setText(_translate("AMaDiA_Main_Window", "Use Threadpool"))
self.Menu_DevOptions_action_Terminate_All_Threads.setText(_translate("AMaDiA_Main_Window", "Terminate All Threads"))
self.Menu_DevOptions_action_Terminate_All_Threads.setToolTip(_translate("AMaDiA_Main_Window", "Unstable, especially in Threadpool-mode"))
self.Menu_Chat_action_Open_Client.setText(_translate("AMaDiA_Main_Window", "Open Client"))
self.Menu_Chat_action_Open_Server.setText(_translate("AMaDiA_Main_Window", "Open Server"))
#self.Menu_Colour_action_Dark.setText(_translate("AMaDiA_Main_Window", "Dark"))
#self.Menu_Colour_action_Bright.setText(_translate("AMaDiA_Main_Window", "Bright"))
self.Menu_OtherWindows_action_SystemControl.setText(_translate("AMaDiA_Main_Window", "System Control"))
self.Menu_Help_action_Examples.setText(_translate("AMaDiA_Main_Window", "Examples"))
self.Menu_Help_action_Helpful_Commands.setText(_translate("AMaDiA_Main_Window", "Helpful Commands"))
self.Menu_Help_action_License.setText(_translate("AMaDiA_Main_Window", "License"))
self.Menu_Help_action_About.setText(_translate("AMaDiA_Main_Window", "About"))
self.Menu_Help_action_Patchlog.setText(_translate("AMaDiA_Main_Window", "Patchlog"))
def Recolour(self, Colour = "Dark"):
App().Recolour(Colour)
def InstallSyntaxHighlighter(self):
#self.Tab_1_InputField_BracesHighlighter = AW.BracesHighlighter(self.Tab_1_InputField.document())
pass
def INIT_Animation(self):
self.init_Animations_With_Colour()
def init_Animations_With_Colour(self):
pass#self.init_Notification_Flash()
# ---------------------------------- Option Toolbar Functions ----------------------------------
def Dev_Function(self):
#AC.ReloadModules()
#AF.ReloadModules()
#AC.ReloadModules()
#AT.ReloadModules()
#AW.ReloadModules()
#importlib.reload(AW)
#importlib.reload(AF)
#importlib.reload(AC)
#importlib.reload(ART)
#importlib.reload(AT)
#
#self.ColourMain()
NC(3,"The DevFunction is currently not assigned",win=self.windowTitle(),func="AMaDiA_Main_Window.Dev_Function")
def ToggleCompactMenu(self):
#TODO: The size behaves weird when compact->scaling-up->switching->scaling-down
self.init_Menu(False)