質問編集履歴
2
コード変更2の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -212,13 +212,13 @@
|
|
212
212
|
|
213
213
|
|
214
214
|
|
215
|
-
# コード変更2(
|
215
|
+
# コード変更2(ObjectPropertyパターン)
|
216
216
|
|
217
217
|
**add_widgetなしの目的は達成**
|
218
218
|
|
219
|
-
|
219
|
+
一番目的に近いパターンです。
|
220
|
-
|
220
|
+
|
221
|
-
|
221
|
+
可能であればObjectPropertyなしでできないかというところです。
|
222
222
|
|
223
223
|
|
224
224
|
|
@@ -232,6 +232,8 @@
|
|
232
232
|
|
233
233
|
from kivy.uix.floatlayout import FloatLayout
|
234
234
|
|
235
|
+
from kivy.properties import ObjectProperty
|
236
|
+
|
235
237
|
|
236
238
|
|
237
239
|
class MainImage(Image):
|
@@ -242,16 +244,28 @@
|
|
242
244
|
|
243
245
|
|
244
246
|
|
247
|
+
def set(self,**package):
|
248
|
+
|
249
|
+
self.source = package["image"]
|
250
|
+
|
251
|
+
|
252
|
+
|
245
253
|
class MainFrame(FloatLayout):
|
246
254
|
|
255
|
+
mainimage = ObjectProperty(None)
|
256
|
+
|
257
|
+
|
258
|
+
|
247
|
-
def __init__(self, **kwargs):
|
259
|
+
def __init__(self, **kwargs):
|
248
|
-
|
249
|
-
mainimage = MainImage()
|
250
|
-
|
251
|
-
mainimage.source = "./ss.png"
|
252
260
|
|
253
261
|
super(MainFrame, self).__init__(**kwargs)
|
254
262
|
|
263
|
+
package = {"image": "./ss.png"}
|
264
|
+
|
265
|
+
self.mainimage.set(**package)
|
266
|
+
|
267
|
+
|
268
|
+
|
255
269
|
|
256
270
|
|
257
271
|
class MainApp(App):
|
@@ -270,6 +284,8 @@
|
|
270
284
|
|
271
285
|
|
272
286
|
|
287
|
+
|
288
|
+
|
273
289
|
if __name__ == '__main__':
|
274
290
|
|
275
291
|
MainApp().run()
|
@@ -284,10 +300,16 @@
|
|
284
300
|
|
285
301
|
#-*- coding: utf-8 -*-
|
286
302
|
|
303
|
+
|
304
|
+
|
287
|
-
<MainFrame>:
|
305
|
+
<MainFrame>:
|
306
|
+
|
307
|
+
mainimage:image1
|
288
308
|
|
289
309
|
MainImage:
|
290
310
|
|
311
|
+
id:image1
|
312
|
+
|
291
313
|
<Image>:
|
292
314
|
|
293
315
|
allow_stretch:True
|
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -246,7 +246,9 @@
|
|
246
246
|
|
247
247
|
def __init__(self, **kwargs):
|
248
248
|
|
249
|
+
mainimage = MainImage()
|
250
|
+
|
249
|
-
|
251
|
+
mainimage.source = "./ss.png"
|
250
252
|
|
251
253
|
super(MainFrame, self).__init__(**kwargs)
|
252
254
|
|