简体   繁体   English

在python dict和PyQt小部件之间进行连接的最佳方法是什么?

[英]What is the best way to connect between python dict and PyQt widget?

I have a giant dict with thousands of keys, and some of that keys also are giant dicts, and so on. 我有一个包含数千个键的巨型字典,其中一些键也是巨型字典,依此类推。

Also I have a lot of widgets with their fields. 我也有很多与他们的领域的小部件。

What I need is to show some preferred (by me) values from dict at my widgets. 我需要的是在我的窗口小部件上显示dict的一些(首选)值。 But not only show: when value is edited in one place (either widget or dict), I need to automatically change it at the second place. 但不仅要显示:在一个位置(小部件或字典)编辑值时,我需要在第二个位置自动更改它。

The point is, I need to do it real simple and auto, because there are too many values and too many fields. 关键是,我需要真正简单而自动地执行此操作,因为值太多,字段太多。

ps Someone who understand my post, please, suggest fixes correcting my grammar. ps请了解我的帖子的人提出修正我的语法的建议。 I'm sorry for that. 对此我感到抱歉。 Thank you. 谢谢。

You could derive your own model based on QAbstractItemModel , that gives an interface to your dict, without needing to copy values. 您可以基于QAbstractItemModel派生自己的模型,该模型为dict提供接口,而无需复制值。 Then you could display your values using either something derived from QTreeView or QColumnView . 然后,您可以使用从QTreeViewQColumnView派生的值显示值。

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

相关问题 在PyQt中,在主窗口和线程之间共享数据的最佳方法是什么 - In PyQt, what is the best way to share data between the main window and a thread 使用PyQt在小部件之间共享数据的最佳方法是什么? - What is the best way to share data between widgets with PyQt? 在Python中区分标量,列表和字典参数的最佳方法是什么? - Best way to distinguish between scalar, list and dict arguments in Python? 在Python2.7中将列表转换为字典的最佳方法是什么 - What’s the best way to Convert a list to dict in Python2.7 Python 从字典中按值获取密钥的最佳方法是什么 - Python what is the best way to get the key from dict by value 在 python 中进行这种 dict 匹配的最佳方法是什么? - What's the best possible way to do this kind of dict matching in python? 在Python中访问默认dict中最后输入的键的最佳方法是什么? - What is the best way to access the last entered key in a default dict in Python? 将元素添加到 python 中的 dict 列表的最佳方法是什么? - what is the best way to add element to list of dict in python? Python:迭代数据集以将值传递到dict的最佳方法是什么? - Python: what is the best way to iterate through a dataset to pass the values into a dict? 在Python 3中重新初始化dict的最佳方法 - Best way to reinitialize a dict in Python 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM