简体   繁体   English

Python 数据库结构和更新值并过渡到 GUI

[英]Python Database Structure and Updating Values and transition to GUI

Im working on a program in python that takes approximately 100 inputs and generates around 500 outputs.There are many calculations that have to be done in the middle and I am having several problems with structuring this program.我正在研究 python 中的一个程序,该程序需要大约 100 个输入并生成大约 500 个输出。中间需要进行许多计算,我在构建这个程序时遇到了几个问题。 I am currently setting up the program to receive inputs through command line and haven't decided how to display the outputs yet.我目前正在设置程序以通过命令行接收输入,但尚未决定如何显示输出。 At the end of my development of this program it needs to be implemented to receive inputs in the form of a GUI and display outputs in the form of the gui, an excel sheet and maybe a pdf.在我开发这个程序的最后,它需要实现以 GUI 的形式接收输入并以 gui、excel 表和可能的 pdf 形式显示输出。

First problem is structuring the inputs, inputs are currently collected into classes that belong in other classes that belong in other classes and so on.第一个问题是构建输入,输入当前被收集到属于其他类的类中,这些类属于其他类,依此类推。 The way I have it currently set up is that I have classes that are a collection of several instances of other classes.我目前设置它的方式是我的类是其他类的几个实例的集合。 The top class can have several instances of each of the other classes.顶部 class 可以有每个其他类的多个实例。 (This is why im having a hard time switching to a database structure, i also don't have that much knowledge about databases and have never worked with them) (这就是为什么我很难切换到数据库结构,我也没有太多关于数据库的知识并且从未使用过它们)

Second problem is editing inputs to see the new outputs.第二个问题是编辑输入以查看新输出。 If the user changes one input that is very deep in the hierarchy i have to call the top class go into the one inside then the one inside that etc and that has become such a hassle to program for each variable.如果用户更改层次结构中非常深的一个输入,我必须调用顶部 class go 到内部的那个,然后是那个内部的那个等等,这已经成为为每个变量编程的麻烦。 So I need to figure out a way to easily access all the attributes and be able to automatically update all the other stored dependent variables that lead to the outputs which should also then update.所以我需要找到一种方法来轻松访问所有属性并能够自动更新所有其他存储的因变量,这些因变量导致输出也应该更新。

Third problem is actually in the calculations.第三个问题实际上是在计算中。 Some of my calculations require iterations of the equation so for example a = 2b b= 3c c = 2a, need to find ab and c.我的一些计算需要等式的迭代,例如 a = 2b b= 3c c = 2a,需要找到 ab 和 c。 I don't understand how to figure that out in python.我不明白如何在 python 中弄清楚这一点。 Would i have to figure out the differential equation or can I just do this like i currently have it in excel?我是否必须弄清楚微分方程,或者我可以像我目前在 excel 中那样做这个吗?

Fourth problem is how to transition this to a gui and excel output.第四个问题是如何将其转换为 gui 和 excel output。

Hope this explains the problems well enough, thanks for taking the time to read this.希望这能很好地解释问题,感谢您花时间阅读本文。 Please Advise.请指教。

What you describe in terms of having class instances containing other class instances with different types of data fits in really well with sqlalchemy .您所描述的 class 实例包含具有不同类型数据的其他 class 实例非常适合sqlalchemy This provides you with a way to tie classes directly to underlying database tables.这为您提供了一种将类直接绑定到底层数据库表的方法。

If you define a class describing your output with relationships to your input through database tables, then all it takes is reloading your input from the db to update your output.如果您定义一个 class 描述您的 output 与您通过数据库表的输入的关系,那么只需从数据库重新加载您的输入以更新您的 output。

Using a local sqlite db to store data also lends well to displaying in a gui and exporting to excel.使用本地 sqlite db 存储数据也有助于在 gui 中显示并导出到 excel。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM