質問編集履歴

1

別の問題が発生してしまいました。

2018/09/15 03:14

投稿

arakawa_kohsen
arakawa_kohsen

スコア8

test CHANGED
File without changes
test CHANGED
@@ -217,3 +217,185 @@
217
217
  開発環境
218
218
 
219
219
  Python 3.5.2 + kivy 1.10.1 + Ubuntu16.04
220
+
221
+
222
+
223
+ ---
224
+
225
+ ありがとうございましした。
226
+
227
+
228
+
229
+ ただ、試してみたのですが、まだうまくいきません。
230
+
231
+ あれからいろいろ当方でも試してみたのですが、いまだに'BBB'を出すことができません。
232
+
233
+ ```Python3
234
+
235
+ from kivy.app import App
236
+
237
+ from kivy.lang import Builder
238
+
239
+
240
+
241
+ from kivy.uix.boxlayout import BoxLayout
242
+
243
+ from kivy.uix.screenmanager import ScreenManager, Screen
244
+
245
+ from kivy.properties import ObjectProperty
246
+
247
+ from kivy.clock import Clock
248
+
249
+
250
+
251
+ from kivy.core.text import LabelBase, DEFAULT_FONT
252
+
253
+ from kivy.resources import resource_add_path
254
+
255
+
256
+
257
+ Builder.load_string('''
258
+
259
+ <ResultParts>
260
+
261
+ ls_p: ls_v
262
+
263
+ Label:
264
+
265
+ id: ls_v
266
+
267
+ text: 'XXX'
268
+
269
+
270
+
271
+ <AllSCN>:
272
+
273
+ name: 'all'
274
+
275
+ us_p: us_v
276
+
277
+
278
+
279
+ BoxLayout:
280
+
281
+ orientation: 'vertical'
282
+
283
+
284
+
285
+ BoxLayout: #OpnSCN
286
+
287
+ Label:
288
+
289
+ id: us_v
290
+
291
+ BoxLayout: #ResultSCN
292
+
293
+ size_hint_y: 0.9
294
+
295
+ ResultParts:
296
+
297
+ ''')
298
+
299
+
300
+
301
+ sm = ScreenManager()
302
+
303
+
304
+
305
+ class ResultParts(BoxLayout):
306
+
307
+ ls_p = ObjectProperty()
308
+
309
+
310
+
311
+ def __init__(self, **kwargs):
312
+
313
+ super(ResultParts, self).__init__(**kwargs)
314
+
315
+ Clock.schedule_once(self._once_after_init)
316
+
317
+
318
+
319
+ def _once_after_init(self, dt):
320
+
321
+ self.ls_p.text = 'before'
322
+
323
+ pass
324
+
325
+
326
+
327
+ def display(self):
328
+
329
+ print('ResultParts display:',self.linked)
330
+
331
+ self.ls_p.text = 'koteichi'
332
+
333
+ pass
334
+
335
+
336
+
337
+
338
+
339
+ class AllSCN(Screen):
340
+
341
+ us_p = ObjectProperty()
342
+
343
+
344
+
345
+ def __init__(self, **kwargs):
346
+
347
+ super(AllSCN, self).__init__(**kwargs)
348
+
349
+
350
+
351
+ def on_pre_enter(self):
352
+
353
+ self.us_p.text = 'AAA'
354
+
355
+ rp = ResultParts()
356
+
357
+ rp.ls_p.text = 'BBB'
358
+
359
+ rp.linked = 'QQQ'
360
+
361
+ rp.display()
362
+
363
+
364
+
365
+
366
+
367
+ class TestApp(App):
368
+
369
+ def build(self):
370
+
371
+ #allscn = AllSCN()
372
+
373
+
374
+
375
+ #Clock.schedule_once(allscn.begin_display, 0)
376
+
377
+
378
+
379
+ sm.add_widget(AllSCN())
380
+
381
+
382
+
383
+ return sm
384
+
385
+
386
+
387
+
388
+
389
+ if __name__ == '__main__':
390
+
391
+ TestApp().run()
392
+
393
+
394
+
395
+ ```
396
+
397
+ この場合だと、下段に'koteichi'が出そうなものですが、実際には'before'がでてしまいました。
398
+
399
+ どうしたらよいのでしょうか。
400
+
401
+ よろしくお願いします。