简体   繁体   English

如何将饼图添加到 GUI?

[英]How to add a piechart to a GUI?

I need to add a pie chart to a GUI, and my code is not in OOP format, and most of the tutorials I have seen are based on code in OOP format.我需要在GUI中添加饼图,而我的代码不是OOP格式的,而且我看到的大部分教程都是基于OOP格式的代码。 Could someone let me know if they know a way I could solve this problem.有人可以让我知道他们是否知道我可以解决这个问题的方法。

"OOP" format doesn't matter. “OOP”格式无关紧要。 Just use pygal:只需使用pygal:

http://pygal.org/en/stable/documentation/types/pie.html http://pygal.org/en/stable/documentation/types/pie.html

pie_chart = pygal.Pie()
pie_chart.title = 'Browser usage in February 2012 (in %)'
pie_chart.add('IE', 19.5)
pie_chart.add('Firefox', 36.6)
pie_chart.add('Chrome', 36.3)
pie_chart.add('Safari', 4.5)
pie_chart.add('Opera', 2.3)
pie_chart.render()

The following are the output methods以下是输出方法

http://pygal.org/en/stable/documentation/output.html http://pygal.org/en/stable/documentation/output.html

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

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