【发布时间】:2018-08-10 13:16:05
【问题描述】:
嘿,我最近开始使用 python / kivy 编程。 我有一个基本问题,我找到的文档无法解决。
我想在我的根 (ScreenLayout) 上方添加一个自定义函数 (InitiateGraph)。 在这个函数中,我正在使用 matplotlib 绘制一个图形,该图形是通过调用应用程序生成的。它应该是这样的:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|here should be the plotted graph from InitiateGraph|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
| here should follow the GridLayout (ScreenLayout) |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
目前这两个块是相反的。 请参阅以下简约示例。
Python 代码:
class ScreenLayout(GridLayout):
def __init__(self, *args, **kwargs):
super(ScreenLayout, self).__init__(*args, **kwargs)
self.add_widget(self.InitiateGraph())
def InitiateGraph(self):
...
class TestApp(App):
def build(self):
return ScreenLayout()
Test = TestApp()
Test.run()
Kivy 代码:
<ScreenLayout>:
rows: 3
BoxLayout:
BoxLayout:
有没有办法做到这一点?
【问题讨论】:
标签: python layout kivy kivy-language