-3

Buttons 'G','H' working when one of widgets in focus, but 'F' not.

My code:

# -*- 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)

When I uncommented this line

binding_manager=MyBindings_manager

I got error:

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

What am I doing wrong?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
n1k
  • 5
  • 1

1 Answers1

0

Your BindingsManager should be of type PlotBindings, and doesn't need to be set as a companion class.

Take a look at https://github.com/klusta-team/klustaviewa/blob/master/klustaviewa/views/traceview.py to see how it's done, as an example.

Galry is obsolete and has now been superceded by Vispy so it's not the best choice of library to build a new application with!

nippoo
  • 167
  • 1
  • 6
  • self.set_bindings(MyBindings_manager) called, but not working. I will study vispy – n1k Jun 03 '15 at 18:17