Shows how to add a custom python widget to the mdi-area of OpenStructure.
from PyQt4 import QtCore, QtGui
from ost import gui
import sys, random
class Points(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('Some Points')
def paintEvent(self, event):
paint = QtGui.QPainter()
paint.begin(self)
size = self.size()
paint.setPen(QtCore.Qt.red)
for i in range(5000):
x = random.randint(1, size.width()-1)
y = random.randint(1, size.height()-1)
paint.drawPoint(x, y)
paint.setPen(QtCore.Qt.green)
for i in range(5000):
x = random.randint(1, size.width()-1)
y = random.randint(1, size.height()-1)
paint.drawPoint(x, y)
paint.setPen(QtCore.Qt.blue)
for i in range(5000):
x = random.randint(1, size.width()-1)
y = random.randint(1, size.height()-1)
paint.drawPoint(x, y)
paint.end()
app=gui.GostyApp.Instance()
main_area=app.perspective.main_area
pts=Points(main_area.qobject)
main_area.AddWidget("Some Points", pts)