Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python .kv文件中的错误==>;文件"/home/pi/Desktop/ali/my9.kv“;_Python_Python 3.x_Kivy_Kivymd - Fatal编程技术网

Python .kv文件中的错误==>;文件"/home/pi/Desktop/ali/my9.kv“;

Python .kv文件中的错误==>;文件"/home/pi/Desktop/ali/my9.kv“;,python,python-3.x,kivy,kivymd,Python,Python 3.x,Kivy,Kivymd,我的代码点亮了一个LED。 这个程序在Tkinter中运行,但当我用Kivy编写它时,它没有运行!! 有什么问题 kivy.py==> from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import ScreenManager, Screen import requests class MainWindow(Screen): pass class WindowMana

我的代码点亮了一个LED。 这个程序在Tkinter中运行,但当我用Kivy编写它时,它没有运行!! 有什么问题

kivy.py==>

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
import requests

class MainWindow(Screen):
    pass


class WindowManager(ScreenManager):
    pass


kv = Builder.load_file("my9.kv")


class MyMainApp(App):
    def build(self):
        return kv


if __name__ == "__main__":
    MyMainApp().run()
my.kv==>

WindowManager:
    MainWindow:

<MainWindow>:
    name: "main"

    GridLayout:
        cols:1

        Button:
            text: "Submit"
                TheRequest = requests.get('http://192.168.43.91/on')
WindowManager:
主窗口:
:
名称:“主要”
网格布局:
科尔斯:1
按钮:
案文:“提交”
TheRequest=requests.get('http://192.168.43.91/on')
错误==>文件“/home/pi/Desktop/ali/my9.kv”,第13行,在 TheRequest=requests.get('http://192.168.43.91/on')
名称错误:未定义名称“requests”

您需要导入文件中的
requests
模块。并添加
TheRequest=requests.get('http://192.168.43.91/on)
按钮方法的发布时的下的语句。修改后的kv文件如下所示:

#:import requests requests
WindowManager:
    MainWindow:

<MainWindow>:
    name: "main"

    GridLayout:
        cols:1

        Button:
            text: "Submit"
            on_release:
                TheRequest = requests.get('https://www.android.com/')
#:导入请求
WindowManager:
主窗口:
:
名称:“主要”
网格布局:
科尔斯:1
按钮:
案文:“提交”
发布时:
TheRequest=requests.get('https://www.android.com/')

您需要导入文件中的
请求
模块。并添加
TheRequest=requests.get('http://192.168.43.91/on)
按钮
方法的
发布时的下的语句。修改后的kv文件如下所示:

#:import requests requests
WindowManager:
    MainWindow:

<MainWindow>:
    name: "main"

    GridLayout:
        cols:1

        Button:
            text: "Submit"
            on_release:
                TheRequest = requests.get('https://www.android.com/')
#:导入请求
WindowManager:
主窗口:
:
名称:“主要”
网格布局:
科尔斯:1
按钮:
案文:“提交”
发布时:
TheRequest=requests.get('https://www.android.com/')