質問編集履歴

2

個人情報

2022/02/20 14:39

投稿

Gadget
Gadget

score6

test CHANGED
File without changes
test CHANGED
@@ -73,7 +73,7 @@
73
73
  resource_add_path("/System/Library/Fonts")
74
74
  LabelBase.register(DEFAULT_FONT, "ヒラギノ角ゴシック W0.ttc")
75
75
 
76
- Builder.load_file("/Users/okonogi/Downloads/GpsApp.kv")
76
+ Builder.load_file("/Users/user_name/Downloads/GpsApp.kv")
77
77
 
78
78
  class MenuScreen(Screen):
79
79
  pass

1

追記依頼をいただきましたので、全コードを記載しました。作成途中ですし、初心者が独学で作っているものなので、お見苦しい点が多々あると思いますが、何卒よろしくお願いします。

2022/02/16 13:52

投稿

Gadget
Gadget

score6

test CHANGED
File without changes
test CHANGED
@@ -15,12 +15,69 @@
15
15
  ### 発生している問題・エラーメッセージ
16
16
 
17
17
  ```
18
+ BuilderException: Parser: File "ファイルパス", line 61:
19
+ ...
20
+ 59: font_size: "30"
21
+ 60: bold: True
22
+ >> 61: text: root.get_datetime.place
23
+ 62:
24
+ 63:
25
+ ...
18
- AttributeError: 'StopwatchScreen' object has no attribute 'place'
26
+ AttributeError: 'function' object has no attribute 'place'
27
+ File "ファイルパス", line 242, in create_handler
28
+ return eval(value, idmap), bound_list
29
+ File "ファイルパス", line 61, in <module>
30
+ text: root.get_datetime.place
31
+
32
+ File "ファイルパス", line 695, in _apply_rule
33
+ value, bound = create_handler(
34
+ File "ファイルパス", line 245, in create_handler
35
+ raise BuilderException(rule.ctx, rule.line,
36
+
19
37
  ```
20
38
 
21
39
  ### 該当のソースコード
22
40
 
23
41
  ```python
42
+ from kivy.config import Config
43
+
44
+ Config.set('graphics', 'width', '500')
45
+ Config.set('graphics', 'height', '500')
46
+
47
+ from kivy.app import App
48
+ from kivy.lang import Builder
49
+ from kivy.uix.widget import Widget
50
+ from kivy.uix.button import Button
51
+ from kivy.uix.behaviors import ButtonBehavior
52
+ from kivy.uix.image import Image
53
+ from kivy.uix.screenmanager import ScreenManager, Screen
54
+ from kivy.graphics.texture import Texture
55
+ from kivy.core.text import LabelBase, DEFAULT_FONT
56
+ from kivy.resources import resource_add_path
57
+ from kivy.clock import Clock
58
+ from kivy.properties import StringProperty
59
+ import requests
60
+ import json
61
+
62
+ from datetime import datetime
63
+ import threading
64
+ import time
65
+ import queue
66
+ import csv
67
+ from geopy.distance import geodesic
68
+ import numpy as np
69
+ import requests
70
+ import ui
71
+ import subprocess
72
+
73
+ resource_add_path("/System/Library/Fonts")
74
+ LabelBase.register(DEFAULT_FONT, "ヒラギノ角ゴシック W0.ttc")
75
+
76
+ Builder.load_file("/Users/okonogi/Downloads/GpsApp.kv")
77
+
78
+ class MenuScreen(Screen):
79
+ pass
80
+
24
81
  class StopwatchScreen(Screen):
25
82
  text = StringProperty()
26
83
 
@@ -32,16 +89,177 @@
32
89
  lon = json.dumps(json_geo["longitude"])
33
90
  place = str(lat + "\n" + lon)
34
91
  zikan = str(datetime.now())
35
- return zikan, place
92
+ return zikan + place
93
+
94
+ #作成途中
95
+ def go_clicked(self):
96
+ print("Buckle up!")
97
+ Clock.schedule_interval(get_datetime, 1)
98
+ print(get_datetime)
99
+
100
+ # 作成途中
101
+ def arrived_clicked(self):
102
+ Clock.unschedule(go_clicked)
103
+ print("Arrived!")
104
+
105
+ #作成途中
106
+ class ResultScreen(Screen):
107
+ start_time = time.time()
108
+ stop_time = time.time()
109
+ result = str(stop_time - start_time)
110
+ pass
111
+ #作成途中
112
+ class LogScreen(Screen):
113
+ pass
114
+
115
+ class GpsApp(App):
116
+ def build(self):
117
+ sm = ScreenManager()
118
+ sm.add_widget(MenuScreen(name='menu'))
119
+ sm.add_widget(StopwatchScreen(name='Stopwatch'))
120
+ sm.add_widget(ResultScreen(name="Result"))
121
+ sm.add_widget(LogScreen(name="Log"))
122
+ return sm
123
+
124
+ def __init__(self, **kwargs):
125
+ super(GpsApp, self).__init__(**kwargs)
126
+ self.title = "GPS"
127
+
128
+
129
+ if __name__ == "__main__":
130
+ GpsApp().run()
36
131
  ```
37
132
  ```kivy
133
+ <MenuScreen>:
134
+ canvas.before:
135
+ Color:
136
+ rgba: 1, 1, 1, 1
137
+ Rectangle:
138
+ pos: self.pos
139
+ size: self.size
140
+
141
+ GridLayout:
142
+ rows: 2
143
+ cols: 1
144
+
145
+ Button:
146
+ text_size: self.size
147
+ valign: "top"
148
+ color: 0, 1, 0, 1
149
+ font_size: "30"
150
+ bold: True
151
+ text: "Drive_Logger"
152
+ on_press: root.manager.current = 'Stopwatch'
153
+ Button:
154
+ text_size: self.size
155
+ valign: "top"
156
+ color: 0, 1, 0, 1
157
+ font_size: "30"
158
+ bold: True
159
+ text: "Log"
160
+ on_press: root.manager.current = 'Log'
161
+
162
+
163
+ <StopwatchScreen>:
164
+ canvas.before:
165
+ Color:
166
+ rgba: 1, 1, 1, 1
167
+ Rectangle:
168
+ pos: self.pos
169
+ size: self.size
170
+
171
+ GridLayout:
172
+ rows: 2
173
+ cols: 2
174
+
38
175
  Label:
39
176
  text_size: self.size
40
177
  valign: "top"
41
178
  color: 0, 1, 0, 1
42
179
  font_size: "30"
43
180
  bold: True
181
+ text: root.get_datetime().zikan
182
+
183
+ Label:
184
+ text_size: self.size
185
+ valign: "top"
186
+ color: 0, 1, 0, 1
187
+ font_size: "30"
188
+ bold: True
44
- text: root.get_datetime().place
189
+ text: root.get_datetime.place
190
+
191
+
192
+ Button:
193
+ text_size: self.size
194
+ valign: "top"
195
+ color: 0, 1, 0, 1
196
+ font_size: "30"
197
+ bold: True
198
+ text: "Go!"
199
+ on_press: root.get_datetime()
200
+
201
+ Button:
202
+ text_size: self.size
203
+ valign: "top"
204
+ color: 0, 1, 0, 1
205
+ font_size: "30"
206
+ bold: True
207
+ text: "Arrived!"
208
+ on_press: root.arrived_clicked()
209
+
210
+
211
+ <ResultScreen>
212
+ canvas.before:
213
+ Color:
214
+ rgba: 1, 1, 1, 1
215
+ Rectangle:
216
+ pos: self.pos
217
+ size: self.size
218
+
219
+ GridLayout:
220
+ rows: 2
221
+ cols: 1
222
+
223
+ Label:
224
+ text_size: self.size
225
+ valign: "top"
226
+ color: 0, 1, 0, 1
227
+ font_size: "30"
228
+ bold: True
229
+ text: root.result
230
+
231
+ Button:
232
+ text_size: self.size
233
+ valign: "top"
234
+ color: 0, 1, 0, 1
235
+ font_size: "30"
236
+ bold: True
237
+ text: "Back to menu"
238
+ on_press: root.manager.current = 'menu'
239
+
240
+
241
+
242
+
243
+ <LogScreen>:
244
+ canvas.before:
245
+ Color:
246
+ rgba: 1, 1, 1, 1
247
+ Rectangle:
248
+ pos: self.pos
249
+ size: self.size
250
+
251
+ GridLayout:
252
+ rows: 1
253
+ cols: 4
254
+
255
+ Button:
256
+ text_size: self.size
257
+ valign: "top"
258
+ color: 0, 1, 0, 1
259
+ font_size: "30"
260
+ bold: True
261
+ text: "Back to menu"
262
+ on_press: root.manager.current = 'menu'
45
263
 
46
264
  ```
47
265
  ### 試したこと