VisionScore/win_venv/main.py

64 lines
1.9 KiB
Python
Raw Normal View History

2020-12-14 14:28:42 +01:00
#import tkinter as tk
import sys
import os
import shutil
from pathlib import Path
2020-12-14 15:38:18 +01:00
from PyQt5 import QtCore
2020-12-21 15:13:58 +01:00
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QMainWindow, QGridLayout, QMenu, QFileDialog, QAction
2020-12-14 15:38:18 +01:00
from PyQt5.QtGui import QIcon, QPixmap
2020-12-14 14:28:42 +01:00
# todo: change app into class (no time to do it now so sorry for it being messy code
2020-12-14 14:28:42 +01:00
def main():
app = QApplication(sys.argv)
2020-12-14 15:38:18 +01:00
#w = QWidget()
w = QMainWindow()
w.setGeometry(0, 0, 600, 400)
w.setWindowTitle('VisionScore')
scriptDir = os.path.dirname(os.path.realpath(__file__))
w.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg'))
2020-12-21 15:13:58 +01:00
'''
2020-12-14 15:38:18 +01:00
label = QLabel()
pixmap = QPixmap(scriptDir + os.path.sep + 'static/visionscore_logo.jpg')
label.setPixmap(pixmap)
label.resize(pixmap.width(), pixmap.height())
label.setAlignment(QtCore.Qt.AlignTop)
w.setCentralWidget(label)
2020-12-21 15:13:58 +01:00
'''
# Toolbar
menuBar = w.menuBar()
homeMenu = QMenu("&Home", w)
menuBar.addMenu(homeMenu)
def showDialog():
home_dir = str(Path.home())
fname = QFileDialog.getOpenFileName(w, 'Load new file', home_dir)
if fname[0]:
shutil.copy(fname[0], 'files/input/test.jpg') #copy the file to destination dir
# Load new file
loadFileAct = QAction('&Load new file', w)
loadFileAct.setStatusTip('Load new file')
# todo: fix - it opens on app run not on click
#loadFileAct.triggered.connect(showDialog())
homeMenu.addAction(loadFileAct)
2020-12-14 15:38:18 +01:00
2020-12-21 15:13:58 +01:00
# Exit app
exitAct = QAction('&Exit', w)
exitAct.setShortcut('Ctrl+Q')
exitAct.setStatusTip('Exit')
exitAct.triggered.connect(app.quit)
homeMenu.addAction(exitAct)
historyMenu = menuBar.addMenu("&History")
helpMenu = menuBar.addMenu("&Help")
2020-12-14 15:38:18 +01:00
2020-12-14 14:28:42 +01:00
w.show()
sys.exit(app.exec_())
2020-12-14 14:28:42 +01:00
if __name__ == '__main__':
main()