Commit e6b921ea authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

React on click

parent 63608c12
...@@ -14,16 +14,18 @@ ...@@ -14,16 +14,18 @@
import sys import sys
import signal import signal
import time
from PySide.QtGui import QGraphicsView, QApplication from PySide.QtGui import QGraphicsView, QApplication
from PySide.QtCore import Qt from PySide.QtCore import Qt, QTimer
from mscStreamingScene import MscStreamingScene from mscStreamingScene import MscStreamingScene
def test_msc(): def test_msc():
''' Create an MSC Scene and add items to check if streaming is ok ''' ''' Create an MSC Scene and add items to check if streaming is ok '''
app = QApplication(sys.argv) global next_y, counter
app = QApplication(sys.argv)
msc_scene = MscStreamingScene() msc_scene = MscStreamingScene()
msc_view = QGraphicsView(msc_scene) msc_view = QGraphicsView(msc_scene)
...@@ -41,16 +43,41 @@ def test_msc(): ...@@ -41,16 +43,41 @@ def test_msc():
msc_view.show() msc_view.show()
item = msc_scene.addMessage(gui_instance, def add_item(item):
taste_instance, ''' Add item to the scene and update next y position '''
next_y, global next_y, counter
"Hello World ({})".format(counter)) item.show()
msc_scene.visible_items.append(item)
item.show()
msc_scene.visible_items.append (item) counter += 1
next_y += increase_factor
counter += 1
next_y += increase_factor def click(_):
''' Called when user clicks on the scene '''
item = msc_scene.addMessage(gui_instance,
taste_instance,
next_y,
"Ping({})".format(counter))
add_item(item)
item = msc_scene.addMessage(taste_instance,
gui_instance,
next_y,
"Pong({})".format(counter))
add_item(item)
msc_scene.mousePressEvent = click
# for _ in xrange (10):
# item = msc_scene.addMessage(gui_instance,
# taste_instance,
# next_y,
# "Ping({})".format(counter))
# add_item(item)
# item = msc_scene.addMessage(taste_instance,
# gui_instance,
# next_y,
# "Pong({})".format(counter))
# add_item(item)
app.exec_() app.exec_()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment