Shows how to add a custom python widget to the mdi-area of OpenStructure.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19from PyQt5 import QtGui, QtCore, QtWidgets
20
21from ost import gui
22import sys, random
23
24class Points(QtWidgets.QWidget):
25 def __init__(self, parent=None):
26 QtWidgets.QWidget.__init__(self, parent)
27 self.setWindowTitle('Some Points')
28
29 def paintEvent(self, event):
30 paint = QtGui.QPainter()
31 paint.begin(self)
32 size = self.size()
33 paint.setPen(QtCore.Qt.red)
34 for i in range(5000):
35 x = random.randint(1, size.width()-1)
36 y = random.randint(1, size.height()-1)
37 paint.drawPoint(x, y)
38 paint.setPen(QtCore.Qt.green)
39 for i in range(5000):
40 x = random.randint(1, size.width()-1)
41 y = random.randint(1, size.height()-1)
42 paint.drawPoint(x, y)
43 paint.setPen(QtCore.Qt.blue)
44 for i in range(5000):
45 x = random.randint(1, size.width()-1)
46 y = random.randint(1, size.height()-1)
47 paint.drawPoint(x, y)
48 paint.end()
49
50
51app=gui.GostyApp.Instance()
52
53
54main_area=app.perspective.main_area
55
56pts=Points(main_area.qobject)
57
58
59main_area.AddWidget("Some Points", pts)
60
61