/
main.py
52 lines (36 loc) · 1.45 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
# -*- coding: utf-8 -*-
from kivy.app import App
from free_exploration import *
from kivy_communication import *
from kivy.uix.screenmanager import ScreenManager, Screen
from text_handling import *
class ZeroScreen(Screen):
def on_enter(self, *args):
KL.restart()
class FreeExplorationApp(App):
game_screen = None
def build(self):
self.init_communication()
TTS.start()
self.sm = ScreenManager()
screen = ZeroScreen()
screen.ids['subject_id'].bind(text=screen.ids['subject_id'].on_text_change)
self.sm.add_widget(screen)
self.game_screen = GameScreen(name='the_game')
self.game_screen.start(self)
self.game_screen.add_widget(self.game_screen.curiosity_game.the_widget)
self.sm.add_widget(self.game_screen)
self.sm.current = 'zero_screen'
return self.sm
def init_communication(self):
KC.start(the_ip='192.168.1.254', the_parents=[self]) # 127.0.0.1
KL.start(mode=[DataMode.file, DataMode.communication, DataMode.ros], pathname=self.user_data_dir,
the_ip='192.168.1.254')
def on_connection(self):
KL.log.insert(action=LogAction.data, obj='FreeExplorationApp', comment='start')
def press_start(self, pre_post):
self.game_screen.curiosity_game.filename = 'items_' + pre_post + '.json'
self.sm.current = 'the_game'
if __name__ == '__main__':
FreeExplorationApp().run()