1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
import sys
from pivy.qt.QtGui import QColor
from pivy.qt.QtWidgets import QApplication
from pivy import quarter, coin
# testing if a eventcallback can remove itself.
class test(coin.SoSeparator):
def __init__(self):
super(test, self).__init__()
self.events = coin.SoEventCallback()
self += self.events
self.cb = self.events.addEventCallback(
coin.SoLocation2Event.getClassTypeId(), self.my_cb)
self.cb1 = self.events.addEventCallback(
coin.SoEvent.getClassTypeId(), self.my_cb_1)
def my_cb(self, *args):
self.events.removeEventCallback(
coin.SoLocation2Event.getClassTypeId(), self.cb)
def my_cb_1(self, *args):
self.events.removeEventCallback(
coin.SoEvent.getClassTypeId(), self.cb1)
def main():
app = QApplication(sys.argv)
viewer = quarter.QuarterWidget()
root = coin.SoSeparator()
root += coin.SoCone()
root += test()
viewer.setSceneGraph(root)
viewer.setBackgroundColor(QColor(255, 255, 255))
viewer.setWindowTitle("minimal")
viewer.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
|