changed format of main window to class
This commit is contained in:
parent
3862848a7e
commit
ffdb50f07f
@ -15,6 +15,7 @@ def files(path):
|
|||||||
if os.path.isfile(os.path.join(path, file)):
|
if os.path.isfile(os.path.join(path, file)):
|
||||||
yield file
|
yield file
|
||||||
|
|
||||||
|
|
||||||
class LibraryTableButtons(QWidget):
|
class LibraryTableButtons(QWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(LibraryTableButtons,self).__init__(parent)
|
super(LibraryTableButtons,self).__init__(parent)
|
||||||
@ -28,7 +29,9 @@ class LibraryTableButtons(QWidget):
|
|||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
|
||||||
class LibraryTable(QTableWidget):
|
class LibraryTable(QTableWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QTableWidget.__init__(self)
|
QTableWidget.__init__(self)
|
||||||
self.setColumnCount(3)
|
self.setColumnCount(3)
|
||||||
@ -57,51 +60,51 @@ class LibraryTable(QTableWidget):
|
|||||||
if index.isValid():
|
if index.isValid():
|
||||||
print(index.row(), index.column())
|
print(index.row(), index.column())
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QMainWindow):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.initUI()
|
||||||
|
|
||||||
|
# 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__))
|
||||||
|
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg'))
|
||||||
|
|
||||||
|
# Toolbar
|
||||||
|
menuBar = self.menuBar()
|
||||||
|
homeMenu = QMenu("&Home", self)
|
||||||
|
menuBar.addMenu(homeMenu)
|
||||||
|
homeMenu.addAction("Load new file")
|
||||||
|
|
||||||
|
libraryAct = QAction('&Library', self)
|
||||||
|
libraryAct.triggered.connect(self.showLibrary)
|
||||||
|
menuBar.addAction(libraryAct)
|
||||||
|
|
||||||
|
# Exit app
|
||||||
|
exitAct = QAction('&Exit', self)
|
||||||
|
exitAct.setShortcut('Ctrl+Q')
|
||||||
|
exitAct.setStatusTip('Exit')
|
||||||
|
exitAct.triggered.connect(qApp.quit)
|
||||||
|
homeMenu.addAction(exitAct)
|
||||||
|
|
||||||
|
helpMenu = menuBar.addMenu("&Help")
|
||||||
|
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
#w = QWidget()
|
w = MainWindow()
|
||||||
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'))
|
|
||||||
|
|
||||||
'''
|
|
||||||
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.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)
|
|
||||||
menuBar.addAction(libraryAct)
|
|
||||||
|
|
||||||
# Exit app
|
|
||||||
exitAct = QAction('&Exit', w)
|
|
||||||
exitAct.setShortcut('Ctrl+Q')
|
|
||||||
exitAct.setStatusTip('Exit')
|
|
||||||
exitAct.triggered.connect(app.quit)
|
|
||||||
homeMenu.addAction(exitAct)
|
|
||||||
|
|
||||||
helpMenu = menuBar.addMenu("&Help")
|
|
||||||
|
|
||||||
w.show()
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user