如何在 PyClutter 中检测组上的事件?
我正在尝试检测 PyClutter 中组上的鼠标单击(和其他事件)。但它们似乎没有触发任何东西。这就是我所拥有的:
import clutter
col = clutter.Color(1, 0, 0)
r1 = clutter.Rectangle(col)
r2 = clutter.Rectangle(col)
r1.set_size(100, 50)
r2.set_size(50, 100)
r2.set_position(200, 200)
g = clutter.Group()
g.add(r1)
g.add(r2)
stage = clutter.Stage()
stage.add(g)
def onClickGroup(group, click):
print "Group", click
g.connect("button-press-event", onClickGroup)
def onClickRect(rect, click):
print "Rect", click
r1.connect("button-press-event", onClickRect)
def onClickStage(stage, click):
print "Stage", click
stage.connect("button-press-event", onClickStage)
stage.show_all()
当我尝试运行它时,我唯一的输出是
>>> Stage <Button Press at 74, 31; button: 1; time: 49748777; source actor: ClutterStage at 0x0x8a21008>
所以它没有从各个演员那里获取事件。有什么方法可以让个体演员或团体检测到事件吗?
I am trying to detect mouse clicks (and other events) on groups in PyClutter. But they don't seem to trigger anything. Here is what I have:
import clutter
col = clutter.Color(1, 0, 0)
r1 = clutter.Rectangle(col)
r2 = clutter.Rectangle(col)
r1.set_size(100, 50)
r2.set_size(50, 100)
r2.set_position(200, 200)
g = clutter.Group()
g.add(r1)
g.add(r2)
stage = clutter.Stage()
stage.add(g)
def onClickGroup(group, click):
print "Group", click
g.connect("button-press-event", onClickGroup)
def onClickRect(rect, click):
print "Rect", click
r1.connect("button-press-event", onClickRect)
def onClickStage(stage, click):
print "Stage", click
stage.connect("button-press-event", onClickStage)
stage.show_all()
When I try to run it, my only output is
>>> Stage <Button Press at 74, 31; button: 1; time: 49748777; source actor: ClutterStage at 0x0x8a21008>
So it isn't picking up the events from the individual actors. Is there any way to make individual actors or groups detect events?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论