我正在尝试使用python 3.7在kivy中构建用户界面,并且收到一堆警告,但我不知道为什么。我以前从未使用过kivy,现在我只是想在添加功能之前先构建布局。现在看来这不是问题,但我不想以后再发现这是我应该早些处理的事情。
我收到6条警告,所有警告均与以下内容相似:
[WARNING] [Call to deprecated function __init__ in C]\Users\shanley\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\adapters\adapter.py line 111.Called from C:\Users\shanley\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\adapters\simplelistadapter.py line 55 by __init__().
到目前为止,这是我的代码。 interface.py:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.uix.listview import ListItemButton
class MessageListButton(ListItemButton):
pass
class InterfaceBoxLayout(BoxLayout):
message_list = ObjectProperty()
def connect(self):
pass
def start_trace(self, *args):
pass
def message_callback(self):
pass
def display_message(self):
pass
class InterfaceApp(App):
def build(self):
return InterfaceBoxLayout()
if __name__ == "__main__":
InterfaceApp().run()
和interface.kv:
# Reference interface.py
#: import main interface
#: import ListAdapter kivy.adapters.listadapter.ListAdapter
#: import ListItemButton kivy.uix.listview.ListItemButton
<InterfaceBoxLayout>:
orientation: "vertical"
message_list: message_list_view
padding: 10
spacing: 10
BoxLayout:
orientation: "horizontal"
size_hint_y: None
height: "40dp"
Label:
text: "Q-Logic 3 Trace"
Label:
text: "Interface Selection"
Button:
text: "Connect"
on_press: root.connect()
BoxLayout:
orientation: "horizontal"
size_hint_y: None
height: "40dp"
Button:
text: "Start Trace"
on_press: root.start_trace()
# Define starting data and point to the ListItemButton
# in the Python code
ListView:
id: message_list_view
adapter:
ListAdapter(data=["Starting Data"], cls=main.MessageListButton)
任何建设性的反馈将不胜感激!