Search code examples
pythonpython-3.xqttypeerrorqtgui

PyMeasure: ManagedWindow class doesn't contain directory_input argument


I'm trying out the latest version 0.8.0 of the PyMeasure package using the examples given in their tutorial from the official documentation. I want to add the directory input to my GUI but I get the error

TypeError: init() got an unexpected keyword argument 'directory_input'

when I run my script. Here is the part of the code where I added this feature according to the documentation on the pymeasure readthedoc site.

class MainWindow(ManagedWindow):

    def __init__(self):
        super(MainWindow, self).__init__(
            procedure_class=RandomProcedure,
            inputs=['iterations', 'delay', 'seed'],
            displays=['iterations', 'delay', 'seed'],
            x_axis='Iteration',
            y_axis='Random Number',
            directory_input=True
        )
        self.setWindowTitle('GUI Example')

    def queue(self):
        directory = self.directory
        filename = unique_filename(directory)
        #filename = tempfile.mktemp()
        

        procedure = self.make_procedure()
        results = Results(procedure, filename)
        experiment = self.new_experiment(results)

        self.manager.queue(experiment)
    
    def closeEvent(self,event):
        QtGui.QApplication.quit()

My version check showed that I'm using version 0.8.0, however when I investigated the ManagedWindow class is shows this definition

ManagedWindow(procedure_class, inputs=(), displays=(), x_axis=None, y_axis=None,
log_channel='', log_level=logging.INFO, parent=None, sequencer=False,
sequencer_inputs=None, sequence_file=None, inputs_in_scrollarea=False)

which doesn't include the option directory_input as an argument. Does anybody have an idea why this is not available although the versions from the documentation and mine are the same?


Solution

  • I checked the different files that are part of the PyMeasure 0.8.0 package on the GitHub repository and compared these to the ones I got from installing PyMeasure with pip and indeed the lines of code for the implementation of the directory_input where missing. I added them manually with the help of an issue thread on github which solved the problem.

    In short, one needs to adjust the files widgets.py and windows.py then the feature works.