全屏模式无法在galrywidget中使用

时间:2015-06-03 10:33:49

标签: python numpy pyqt vispy

按钮“G”,“H”在其中一个小部件处于焦点时起作用,但“F”不起作用。

我的代码:

# -*- coding: UTF-8 -*-
import numpy
from galry import *

class MyPaintManager(PlotPaintManager):
    def initialize(self):
        self.add_visual(PlotVisual, x=self.parent.x, y=self.parent.y, color='b')

class MyBindings_manager(Bindings):
    def initialize_default(self):
        super(MyBindings_manager, self).initialize_default()
        self.set_fullscreen()
        self.set('KeyPress', 'Fullscreen', key='F')

class MyWidget(GalryWidget):
    def initialize(self, x, y):
        self.activate_grid = True
        self.show_grid = True
        self.is_fullscreen = True
        self.x = x
        self.y = y

        self.set_companion_classes(
            paint_manager=MyPaintManager,
            interaction_manager=PlotInteractionManager,
#           binding_manager=MyBindings_manager
            )
        self.initialize_companion_classes()

class Window(QtGui.QWidget):
    def __init__(self):
        super(Window, self).__init__()
        self.initUI()

    def initUI(self):
        layout = QtGui.QGridLayout(self)
        sampleRate = 30000.
        channelCount = 20
        data = np.random.normal(size=1000000)
        newData = data.reshape(channelCount,-1, order='F')

        for channelNum in range(channelCount):
            count = len(newData[channelNum])
            x = np.linspace(0, count / sampleRate, count)
            graph = MyWidget(x=x, y=newData[channelNum])
            layout.addWidget(graph, channelNum % 4, channelNum / 4)
        self.setLayout(layout)
        self.show()

if __name__ == '__main__':
    show_window(Window)

当我取消注释此行

binding_manager=MyBindings_manager

我收到了错误:

TypeError: __init__() takes exactly 1 argument (2 given)

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您的BindingsManager应该是PlotBindings类型,并且不需要设置为随播类。

https://github.com/klusta-team/klustaviewa/blob/master/klustaviewa/views/traceview.py为例,了解它是如何完成的。

Galry已经过时,现已被Vispy取代,所以它不是构建新应用程序的最佳库选择!