Skip to content

Commit

Permalink
PySide6 experiment.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Aug 17, 2023
1 parent ea483ac commit 82d76f8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sandbox/tusdview/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
python tusdview.py
5 changes: 5 additions & 0 deletions sandbox/tusdview/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PySide6
numpy
scipy
opencv-python
matplotlib
55 changes: 55 additions & 0 deletions sandbox/tusdview/tusdview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

import os, sys

# workaround.
# import PySide6 first, then import numpy, cv2, etc. otherwise
#
# qt.qpa.wayland: Failed to initialize EGL display 3001
#
# error happens in WSL2 environment

from PySide6.QtWidgets import QApplication, QWidget, QLabel
from PySide6.QtGui import QImage, QPixmap

#import cv2
import numpy as np


class MainWindow(QWidget):

def __init__(self, parent=None):
super().__init__(parent)

self.setup()

def setup(self):

self.width = 512
self.height = 512

# HWC
img = np.zeros((self.height, self.width, 3)).astype(np.uint8)

for x in range(self.width):
for y in range(self.height):
img[x,y,0] = x % 256
img[x,y,1] = y % 256
img[x,y,2] = 127

stride = img.strides[0]

qimg = QImage(img.data, self.width, self.height, stride, QImage.Format.Format_RGB888)
pixmap = QPixmap(QPixmap.fromImage(qimg))
imgLabel = QLabel(self)
imgLabel.setPixmap(pixmap)

self.resize(imgLabel.pixmap().size())
self.setWindowTitle("TinyUSDZ viewer")


if __name__ == '__main__':
app = QApplication([])
window = MainWindow()
window.show()
app.exec()

0 comments on commit 82d76f8

Please sign in to comment.