Reputation: 917
I'm attempting to make the TextInput widgets "invisible" like you would by using
opacity: 0
However, I want the text inside the TextInput to show. If I use
opacity: 0
The TextInput widget and the text inside the widget is not visible, is there a way to "hide" the widget while still showing the text?
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()
Upvotes: 3
Views: 1932
Reputation: 4543
Use background_color
property and set alpha chanel to 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()
Upvotes: 4