aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
diff options
context:
space:
mode:
authormartin2022-05-01 22:41:20 +0200
committerGitHub2022-05-01 22:41:20 +0200
commit4c5aa37aa6f41d909153a2b7d522db6d7582659a (patch)
tree326aa67921439defcb8c25ea5f770feb63e878a4 /src/main.py
parent4a3ff8bfce622de0e5affa312d50557b5d336371 (diff)
parent820358a79a87b214139eb7693ce80e96be79e3d8 (diff)
Merge pull request #69 from djfun/feature-newgui
GUI Redesign with Component System
Diffstat (limited to 'src/main.py')
-rw-r--r--src/main.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/main.py b/src/main.py
new file mode 100644
index 0000000..709e5e7
--- /dev/null
+++ b/src/main.py
@@ -0,0 +1,53 @@
+from PyQt5 import uic, QtWidgets
+import sys
+import os
+import logging
+import re
+import string
+
+from .__init__ import wd
+
+
+log = logging.getLogger('AVP.Main')
+
+
+def main():
+ # Determine primary mode
+ proj = None
+ mode = 'GUI'
+ if len(sys.argv) > 2:
+ mode = 'commandline'
+ elif len(sys.argv) == 2:
+ if sys.argv[1].startswith('-'):
+ mode = 'commandline'
+ else:
+ # remove unsafe punctuation characters such as \/?*&^%$#
+ sys.argv[1] = re.sub(f'[{re.escape(string.punctuation)}]', '', sys.argv[1])
+ # opening a project file with gui
+ proj = sys.argv[1]
+
+ # Create Qt Application
+ app = QtWidgets.QApplication(sys.argv)
+ app.setApplicationName("audio-visualizer")
+ # Launch program
+ if mode == 'commandline':
+ from .command import Command
+
+ main = Command()
+ mode = main.parseArgs()
+ log.debug("Finished creating command object")
+
+ # Both branches here may occur in one execution:
+ # Commandline parsing could change mode back to GUI
+ if mode == 'GUI':
+ from .gui.mainwindow import MainWindow
+
+ mainWindow = MainWindow(proj)
+ log.debug("Finished creating MainWindow")
+ mainWindow.raise_()
+
+ sys.exit(app.exec_())
+
+
+if __name__ == "__main__":
+ main()