Commit e6b921ea authored by Maxime Perrotin's avatar Maxime Perrotin

React on click

parent 63608c12
......@@ -14,16 +14,18 @@
import sys
import signal
import time
from PySide.QtGui import QGraphicsView, QApplication
from PySide.QtCore import Qt
from PySide.QtCore import Qt, QTimer
from mscStreamingScene import MscStreamingScene
def test_msc():
''' 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_view = QGraphicsView(msc_scene)
......@@ -41,16 +43,41 @@ def test_msc():
msc_view.show()
item = msc_scene.addMessage(gui_instance,
taste_instance,
next_y,
"Hello World ({})".format(counter))
item.show()
msc_scene.visible_items.append (item)
counter += 1
next_y += increase_factor
def add_item(item):
''' Add item to the scene and update next y position '''
global next_y, counter
item.show()
msc_scene.visible_items.append(item)
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_()
......
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