From 7382d197ae3d8a808f5d5d01adebf7506cf3ae18 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Wed, 20 Sep 2023 05:41:34 +0900 Subject: [PATCH] Add menu. --- sandbox/tusdview/tusdview.py | 39 +++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/sandbox/tusdview/tusdview.py b/sandbox/tusdview/tusdview.py index 0dac2f165..40e260650 100644 --- a/sandbox/tusdview/tusdview.py +++ b/sandbox/tusdview/tusdview.py @@ -8,21 +8,21 @@ # # error happens in WSL2 environment -from PySide6.QtWidgets import QApplication, QWidget, QLabel -from PySide6.QtGui import QImage, QPixmap +from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QLabel, QFileDialog +from PySide6.QtGui import QAction, QImage, QPixmap #import cv2 import numpy as np -class MainWindow(QWidget): +class MainWindow(QMainWindow): - def __init__(self, parent=None): + def __init__(self, parent=None): super().__init__(parent) self.setup() - def setup(self): + def setup(self): self.width = 512 self.height = 512 @@ -43,13 +43,38 @@ def setup(self): imgLabel = QLabel(self) imgLabel.setPixmap(pixmap) - self.resize(imgLabel.pixmap().size()) - self.setWindowTitle("TinyUSDZ viewer") + #self.resize(imgLabel.pixmap().size()) + + open_file = QAction("Open(&O)", self) + open_file.setShortcut("Ctrl+O") + open_file.triggered.connect(self.openFile) + quit_app = QAction("Quit(&Q)", self) + quit_app.setShortcut("Ctrl+Q") + quit_app.triggered.connect(self.quitApp) + + menu = self.menuBar() + file_menu = menu.addMenu("File") + file_menu.addAction(open_file) + file_menu.addAction(quit_app) + + + self.setWindowTitle("TinyUSDZ viewer") + def openFile(self): + filters = "USD files(*.usd *.usdc *.usda *.usdz);;Any files (*)" + filename = QFileDialog.getOpenFileName(filter=filters) + print(filename) + + def quitApp(self): + import sys + sys.exit() + if __name__ == '__main__': app = QApplication([]) window = MainWindow() window.show() app.exec() + +