【发布时间】:2020-07-02 20:33:34
【问题描述】:
我正在开发一个 Kivy 应用程序,该应用程序应在用户单击菜单中的项目时生成图。当用户单击该项目时,它会打开一个新屏幕,该屏幕应生成绘图。我的问题是我似乎无法让 Kivy 展示情节。我的代码执行没有错误,所以我不确定哪里出错了。
我一直在寻找有关此问题的问题,我能找到的最好的问题是在这里 (Real-time plotting using matplotlib and kivy in Python),但这对我不起作用。
我还有一个关于重新定义Screen 类的on_enter 方法的第二个问题,以便它可以使用App 方法来创建绘图。这可能吗?
Python 代码(作为 App 类的一部分定义的函数)
def grp_enter(self):
grid = GridLayout(rows = 1, cols = 1)
#grid.add_widget(FigureCanvasKivyAgg(plt.gcf())) should have prepared a canvas but one didn't appear
self.track_instance.associations() # generates the plot
KV代码
<GroupScreen>:
on_enter: app.grp_enter()
name: 'groups_screen'
Button:
on_release:
app.root.transition = SlideTransition(direction = "right")
app.root.current = 'main'
text: 'back to the home screen'
font_size: 50
【问题讨论】:
标签: python matplotlib plot kivy seaborn