Skip to content

Instantly share code, notes, and snippets.

@reusee
Created April 25, 2012 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reusee/2486397 to your computer and use it in GitHub Desktop.
Save reusee/2486397 to your computer and use it in GitHub Desktop.
print a matrix using QGraphicsView
from PySide.QtCore import *
from PySide.QtGui import *
from numpy import *
import sys
app = QApplication(sys.argv)
matrix = arange(16).reshape(4, 4)
scene = QGraphicsScene()
view = QGraphicsView(scene)
for x, row in enumerate(matrix):
for y, elem in enumerate(row):
print x, y
char = chr(ord('A') + int(elem))
item = QGraphicsTextItem(char)
item.scale(4.5, 4.5)
pos = QPoint(-800 + y * 50, -800 + x * 50)
item.setPos(pos)
scene.addItem(item)
view.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment