teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

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

2018/09/15 03:14

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -107,4 +107,95 @@
107
107
 
108
108
 
109
109
  開発環境
110
- Python 3.5.2 + kivy 1.10.1 + Ubuntu16.04
110
+ Python 3.5.2 + kivy 1.10.1 + Ubuntu16.04
111
+
112
+ ---
113
+ ありがとうございましした。
114
+
115
+ ただ、試してみたのですが、まだうまくいきません。
116
+ あれからいろいろ当方でも試してみたのですが、いまだに'BBB'を出すことができません。
117
+ ```Python3
118
+ from kivy.app import App
119
+ from kivy.lang import Builder
120
+
121
+ from kivy.uix.boxlayout import BoxLayout
122
+ from kivy.uix.screenmanager import ScreenManager, Screen
123
+ from kivy.properties import ObjectProperty
124
+ from kivy.clock import Clock
125
+
126
+ from kivy.core.text import LabelBase, DEFAULT_FONT
127
+ from kivy.resources import resource_add_path
128
+
129
+ Builder.load_string('''
130
+ <ResultParts>
131
+ ls_p: ls_v
132
+ Label:
133
+ id: ls_v
134
+ text: 'XXX'
135
+
136
+ <AllSCN>:
137
+ name: 'all'
138
+ us_p: us_v
139
+
140
+ BoxLayout:
141
+ orientation: 'vertical'
142
+
143
+ BoxLayout: #OpnSCN
144
+ Label:
145
+ id: us_v
146
+ BoxLayout: #ResultSCN
147
+ size_hint_y: 0.9
148
+ ResultParts:
149
+ ''')
150
+
151
+ sm = ScreenManager()
152
+
153
+ class ResultParts(BoxLayout):
154
+ ls_p = ObjectProperty()
155
+
156
+ def __init__(self, **kwargs):
157
+ super(ResultParts, self).__init__(**kwargs)
158
+ Clock.schedule_once(self._once_after_init)
159
+
160
+ def _once_after_init(self, dt):
161
+ self.ls_p.text = 'before'
162
+ pass
163
+
164
+ def display(self):
165
+ print('ResultParts display:',self.linked)
166
+ self.ls_p.text = 'koteichi'
167
+ pass
168
+
169
+
170
+ class AllSCN(Screen):
171
+ us_p = ObjectProperty()
172
+
173
+ def __init__(self, **kwargs):
174
+ super(AllSCN, self).__init__(**kwargs)
175
+
176
+ def on_pre_enter(self):
177
+ self.us_p.text = 'AAA'
178
+ rp = ResultParts()
179
+ rp.ls_p.text = 'BBB'
180
+ rp.linked = 'QQQ'
181
+ rp.display()
182
+
183
+
184
+ class TestApp(App):
185
+ def build(self):
186
+ #allscn = AllSCN()
187
+
188
+ #Clock.schedule_once(allscn.begin_display, 0)
189
+
190
+ sm.add_widget(AllSCN())
191
+
192
+ return sm
193
+
194
+
195
+ if __name__ == '__main__':
196
+ TestApp().run()
197
+
198
+ ```
199
+ この場合だと、下段に'koteichi'が出そうなものですが、実際には'before'がでてしまいました。
200
+ どうしたらよいのでしょうか。
201
+ よろしくお願いします。