PyMeasure:ManagedWindow 类不包含 directory_input 参数

问题描述

我正在使用官方文档中的教程中给出的示例尝试最新版本的 PyMeasure 包 0.8.0。我想将目录输入添加到我的 GUI 中,但出现错误

TypeError: init() 得到了一个意外的关键字参数“directory_input”

当我运行我的脚本时。这是我根据 pymeasure readthedoc 站点上的 documentation 添加功能代码部分。

class MainWindow(ManagedWindow):

    def __init__(self):
        super(MainWindow,self).__init__(
            procedure_class=RandomProcedure,inputs=['iterations','delay','seed'],displays=['iterations',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()

我的版本检查显示我使用的是 0.8.0 版,但是当我调查 ManagedWindow 类时显示了这个定义

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)

包括选项 directory_input 作为参数。 尽管文档中的版本和我的版本相同,但有人知道为什么这不可用吗?

解决方法

我检查了 GitHub 存储库上属于 PyMeasure 0.8.0 包的不同文件,并将这些文件与我使用 pip 安装 PyMeasure 时得到的文件以及用于实现 directory_input 的代码行进行了比较 哪里缺少。我在解决问题的 github 上的问题线程的帮助下手动添加了它们。

简而言之,需要调整文件 widgets.pywindows.py 才能使用该功能。