changed format of main window to class

This commit is contained in:
Agata 2020-12-21 21:39:56 +01:00
parent 3862848a7e
commit ffdb50f07f

View File

@ -15,6 +15,7 @@ def files(path):
if os.path.isfile(os.path.join(path, file)):
yield file
class LibraryTableButtons(QWidget):
def __init__(self, parent=None):
super(LibraryTableButtons,self).__init__(parent)
@ -28,7 +29,9 @@ class LibraryTableButtons(QWidget):
self.setLayout(layout)
class LibraryTable(QTableWidget):
def __init__(self, parent=None):
QTableWidget.__init__(self)
self.setColumnCount(3)
@ -58,50 +61,50 @@ class LibraryTable(QTableWidget):
print(index.row(), index.column())
def main():
app = QApplication(sys.argv)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
#w = QWidget()
w = QMainWindow()
w.setGeometry(0, 0, 600, 400)
w.setWindowTitle('VisionScore')
# Show raw uploaded files
def showLibrary(self):
libTable = LibraryTable()
self.setCentralWidget(libTable)
def initUI(self):
self.setGeometry(0, 0, 600, 400)
self.setWindowTitle('VisionScore')
scriptDir = os.path.dirname(os.path.realpath(__file__))
w.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg'))
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg'))
'''
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)
'''
# Toolbar
menuBar = w.menuBar()
homeMenu = QMenu("&Home", w)
menuBar = self.menuBar()
homeMenu = QMenu("&Home", self)
menuBar.addMenu(homeMenu)
homeMenu.addAction("Load new file")
# Show raw uploaded files
def showLibrary():
libTable = LibraryTable()
w.setCentralWidget(libTable)
libraryAct = QAction('&Library', w)
libraryAct.triggered.connect(showLibrary)
libraryAct = QAction('&Library', self)
libraryAct.triggered.connect(self.showLibrary)
menuBar.addAction(libraryAct)
# Exit app
exitAct = QAction('&Exit', w)
exitAct = QAction('&Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.setStatusTip('Exit')
exitAct.triggered.connect(app.quit)
exitAct.triggered.connect(qApp.quit)
homeMenu.addAction(exitAct)
helpMenu = menuBar.addMenu("&Help")
w.show()
self.show()
def main():
app = QApplication(sys.argv)
w = MainWindow()
sys.exit(app.exec_())
if __name__ == '__main__':
main()