我有一个用于物理过程模拟的模块。现在我想为它做一个GUI。我使用 PyQt 创建应用程序,它允许控制计算、其参数和图形输出。但有一个问题 - 如果我想在模拟中添加一些新功能,那么除了在计算模块中对其进行编码之外,我还需要创建用于在 GUI 模块中调用它的包装函数、用于调用它的 GUI 元素、设置 GUI 表示并将其绑定到我需要的功能。这很烦人,因为我需要编写大量明显的代码而不是处理逻辑。我对流程自动化有一些想法,但首先我想问:是否有一些推荐的方法来减少这种样板工作?
I have a module for a physical process simulation. Now I want to do a GUI for it. I've used PyQt to create application, which allows to control calculation, its parameters and graphical output. But there is a problem - if I want to add some new feature to simulation, then in addition to coding it in computational module, I need to create wrapper function for calling it in GUI module, GUI element for calling it, set up GUI representation and bind it to the function I need. That's annoying, because I need to write an amount of obvious code instead of working on logic. I have a few ideas on automatization of process, but first I want to ask: are there some recommended ways to reduce this boilerplate work?
发布评论
评论(1)
欢迎来到 GUI 编程! :)
在 PyQt 中,您可以通过 按名称自动连接插槽。
您还可以在运行时创建任何 GUI 元素,而无需求助于 QtDesigner,因此您可以执行诸如在
for
循环中生成复选框列表之类的操作。Welcome to GUI programming! :)
In PyQt, you can slightly reduce the amount of boilerplate by autoconnecting slots by name.
You can also create any GUI element at runtime, without resorting to QtDesigner, so you can do things like generate a list of checkboxes in a
for
loop.