2017-12-02 2 views
1

을 보여, 나는의 TextInput 내부의 텍스트를 표시 할. 내가가 Kivy의 TextInput 프레임이 보이지 않게하지만 그러나</p> <pre><code>opacity: 0 </code></pre> <p>를 사용하여 같은 것 "보이지 않는"TextInput 구성 위젯을 시도하고있어 텍스트

opacity: 0 

TextInput 구성 위젯을 사용하고 위젯 내부의 텍스트가 표시되지 않는 경우 여전히 텍스트를 보여주는 동안, 방법을 "숨기기"위젯이있다?

from kivy.app import App 
from kivy.lang import Builder 
from kivy.uix.screenmanager import ScreenManager, Screen 


class ExampleScreen(Screen): 
    pass 


class ExampleManager(ScreenManager): 
    pass 


root_widget = Builder.load_string(''' 
ExampleManager: 
    ExampleScreen: 

<ExampleScreen>: 
    name: 'example_screen' 
    TextInput: 
     id: t_1 
     text: 'Test text in input 1' 
     size_hint: .5, .5 
     pos_hint: {'x': 0, 'y': .5} 
     multiline: True 
     readonly: True 
     opacity: 0 ## If I remove this line both text edits are visible. 
        ##You can test this by putting ## before opacity 

     ## What I'm trying to do, is make the TextInput widget opaque so 
     ##that you can't see the frame and only the text is visible 

    TextInput: 
     id: t_2 
     text: 'Test text in input 2' 
     size_hint: .5, .5 
     pos_hint: {'x': 0, 'y': 0} 
     multiline: True 
     readonly: True 
     opacity: 0 ## If I remove this line both text edits are visible. 
        ##You can test this by putting ## before opacity 

     ## What I'm trying to do, is make the TextInput widget opaque so 
     ##that you can't see the frame and only the text is visible 

''') 

class TestWidgetsApp(App): 
    def build(self): 
     self.title = 'Proj' 
     return root_widget 

TestWidgetsApp().run() 
+0

은 ExampleScreen의 배경 색상을 설정하고 같은 색상 –

+0

만약에 당신의 TextInput의 배경색을 설정 고려 background_color를 설정하지 않으려면 background_normal 및 background_active 이미지를 '012'로 설정하십시오. –

답변

1

사용 background_color 재산 및 설정 알파 샤넬 0 :

from kivy.app import App 
from kivy.lang import Builder 
from kivy.uix.screenmanager import ScreenManager, Screen 


class ExampleScreen(Screen): 
    pass 


class ExampleManager(ScreenManager): 
    pass 


root_widget = Builder.load_string(''' 
ExampleManager: 
    ExampleScreen: 

<ExampleScreen>: 
    name: 'example_screen' 
    TextInput: 
     id: t_1 
     text: 'Test text in input 1' 
     size_hint: .5, .5 
     pos_hint: {'x': 0, 'y': .5} 
     multiline: True 
     readonly: True 
     foreground_color: (1,0,1,1) 
     background_color: (0,0,0,0) 

    TextInput: 
     id: t_2 
     text: 'Test text in input 2' 
     size_hint: .5, .5 
     pos_hint: {'x': 0, 'y': 0} 
     multiline: True 
     readonly: True 
     foreground_color: (1,1,0,1) 
     background_color: (0,0,0,0) 

''') 

class TestWidgetsApp(App): 
    def build(self): 
     self.title = 'Proj' 
     return root_widget 

TestWidgetsApp().run() 

enter image description here

+0

고마워요, 고마워요! – Afflicted

관련 문제