1

按照马特对这个问题的回答,我试图 clock.schedule在另一个进程中使用以更改我的ListProperty所谓“data_items”,但我仍然收到错误“未定义全局名称'set_property'”

beedo.py:

class MyW(Widget):
data_items = ListProperty([])
def set_property(camera, *largs):
    self.data_items.append(camera)
    print(data_items)
    return
....   

class beedoApp(App):
    def build(self):
        return MyW()
    ....

def do_list(camera):
    Clock.schedule_once(partial(set_property, camera))
    print "do list startet.."

def socket_server()
    ....

def event_handler
    ....
    list1 = Process (target=do_list, args=(camera))
    list1.start()

if __name__ == "__main__":
    server1 = Process (target=socket_server, args=(....)
    server2 = Process (target=socket_server, args=(....)
    handler = Process (target=event_handler, args=(....)

    server1.start()
    server2.start()
    handler.start()

    beedoApp().run()

    server1.join()
    server2.join()
    handler.join()

在文件 beedo.kv 我定义了一个SimpleListAdapter

ListView:
     adapter:
     sla.SimpleListAdapter(data=root.data_items, cls=ListItemButton)

报警器屏幕如下:

屏幕

我在这里上传了完整的代码:

beedo.py https://www.dropbox.com/s/pyqpfefkia6lj0r/beedo.py?dl=0

请,如果你能帮助我将非常感激!问候, Pipe007

4

0 回答 0