全屏模式在galrywidg中不工作

2024-10-03 04:34:07 发布

您现在位置:Python中文网/ 问答频道 /正文

当其中一个小部件处于焦点时,按钮“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)

我做错什么了?你知道吗


Tags: selftrueinitdefshowmanagerwindowclass