0
이미지의 색상을 변경하고 싶습니다. 이 이미지는 screenmanager가있는 화면의 버튼에 배치됩니다. 버튼을 누르면 팝업이 나타나서 색상을 선택합니다. 이제이 색은 전역 변수에 저장되고 (이전의 흰색) 이미지의 색으로 설정됩니다. 내 문제는 팝업 클래스에서 이미지의 속성에 액세스 할 수 없다는 것입니다.kivy - 팝업에서 화면의 위젯 속성을 변경하고 싶습니다.
.kv의 관련 부분 :
<HomeScreen>:
sm: sm
name: 'ScreenManager'
BoxLayout:
orientation: 'vertical'
rows: 2
ActionBar:
[...]
ScreenManager:
id: sm
size_hint_y: .935
Screen1:
name: "screen_1"
Screen2:
name: "screen_2"
Screen3:
name: "screen_3"
[...]
<Popup_F>:
size_hint: .75, .5
auto_dismiss: True
BoxLayout
orientation: 'horizontal'
padding: 10, 0
BoxLayout
orientation: 'vertical'
Slider:
id: on_value_slider_r
on_value:
root.on_value_slider_rgb()
Slider:
id: on_value_slider_g
on_value:
root.on_value_slider_rgb()
Slider:
id: on_value_slider_b
on_value:
root.on_value_slider_rgb()
그리고 평 :
class Screen1(Screen):
[...]
def colorchanger(self):
farbenw = Popup_F()
farbenw.open()
def colorchangern(self):
# next line should change the color (as work around) of the Image but has no effect:
self.ids.image_color_change.color = (r_R1, g_R1, b_R1, 1)
class Farbe(Popup):
def on_value_slider_rgb(self):
global r_R1
global g_R1
global b_R1
r_R1 = self.ids.on_value_slider_r.value
g_R1 = self.ids.on_value_slider_g.value
b_R1 = self.ids.on_value_slider_b.value
# next line does cause an error
self.ids.image_color_change.color = (r_R1, g_R1, b_R1, 1)
Screen1().colorchangern()
오류 내가 얻을 :
가 AttributeError : '슈퍼'개체가 어떤 속성을 '이 없다 __ getattr __ '
표시된 줄이있는 것만 ... 나는 이것을 어떻게 실현할 수 있는지 잘 모릅니다. t 개의 오류! 나는 첫 번째 질문으로 모든 것이 정확했으면 좋겠다!
감사합니다.
대단히 감사합니다! 약간의 연구가 끝난 후에 코드에 감사드립니다! – Dersim
@Dersim 당신은 잘되고 있습니다. – EL3PHANTEN