mainwindow.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:solar-sails 作者: metrasynth 项目源码 文件源码
def on_action_import_parameter_values_triggered(self):
        with self.catcher.more:
            filename, _ = QFileDialog.getOpenFileName(
                parent=self,
                caption='Import Parameter Values',
                directory='.',
                filter='Supported Files (*.sunsynth *.sunvox)',
            )
            if filename:
                obj = rv.read_sunvox_file(filename)
                if isinstance(obj, rv.Project):
                    project = obj
                elif isinstance(obj, rv.Synth) and isinstance(obj.module, rv.m.MetaModule):
                    project = obj.module.project
                else:
                    print('{} is not a project or metamodule'.format(filename))
                    return
                mmckdata = None
                for mod in reversed(project.modules):
                    if mod.name == 'mmckdata':
                        mmckdata = mod
                        break
                if not mmckdata:
                    print('Could not find mmckdata module in {}'.format(filename))
                    return
                params = json.loads(mmckdata.samples[-2].data.decode('utf8'))
                self.kit.parameter_values.update(params)
                self.parameters_manager.parameters = self.kit.parameters
                self.rebuild_project()
                self.save_kit_parameter_values()
                if hasattr(self.kit.py_module, 'udc_assignments'):
                    self.update_udc_assignments(self.kit.py_module.udc_assignments(self.kit.parameter_values))
                print('Imported parameter values from {}'.format(filename))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号