Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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 Kivy和XML RPC_Python_User Interface_Xml Rpc_Kivy - Fatal编程技术网

Python Kivy和XML RPC

Python Kivy和XML RPC,python,user-interface,xml-rpc,kivy,Python,User Interface,Xml Rpc,Kivy,我一直在尝试在KivyGUI模块(我的服务器)和另一个python模块(我的客户端)之间执行通信。但到目前为止,我在运行xml rpc服务器和GUI run()函数时遇到了问题。即使在线程中运行服务器之后,我仍然存在这个问题。 我希望有人能对如何修复我的代码,或者如何将xml rpc与kivy一起使用提出建议 这是我的密码: import kivy kivy.require('1.7.1') from kivy.lang import Builder from kivy.uix.gridl

我一直在尝试在KivyGUI模块(我的服务器)和另一个python模块(我的客户端)之间执行通信。但到目前为止,我在运行xml rpc服务器和GUI run()函数时遇到了问题。即使在线程中运行服务器之后,我仍然存在这个问题。 我希望有人能对如何修复我的代码,或者如何将xml rpc与kivy一起使用提出建议

这是我的密码:

import kivy

kivy.require('1.7.1')

from kivy.lang import Builder

from kivy.uix.gridlayout import GridLayout

from kivy.app import App

from threading import Thread

from kivy.clock import Clock

Builder.load_file('kivy_gui.kv')

class RoamClientInterface(GridLayout):

    """
    Sets up connection with XMLRPC server

    """

    move = False

    """
    driveForward() -> Moves robot forward
    """

    def driveForward(self):
        self.move = True

    """
    stop() -> stops robot from moving
    """

    def stop(self):
        self.move = False

    def returnBool(self):
        return self.move

class ClientInterface(App):

    def build(self):
        return RoamClientInterface()

    def sendCommands(dt):

        print "start"
        print ""
        from SimpleXMLRPCServer import SimpleXMLRPCServer
        server = SimpleXMLRPCServer(("localhost", 5000))
        print "initialize server"
        print ""
        server.register_instance(RoamClientInterface())
        print "register instance"
        print ""
        # while True:

        try:
            print "try handle request"
            print ""
            server.handle_request()
            print "print handle request"
            print ""
        except KeyboardInterrupt:
            import sys
            sys.exit()

if __name__ == '__main__':
    serverThread = Thread(target=sendCommands(4))
    serverThread.start()
   # Clock.schedule_once(sendCommands)
    ClientInterface().run()

我必须解决这个问题。 实际上,有必要将它放入RoamClientInterface的内部以使其工作,而不是像上面那样将它放入我的主函数中。
如果有人需要帮助,我可以提供更多详细信息(显示代码)

谢谢您回答自己的问题!它使堆栈溢出成为一个非常好的地方:)