I have a ScrollView
and a Bubble
, that partially overlaps it and contains a GridLayout
Questions:
- How can I hide the widget without removing it?
I've read answers to a question on that topic, the suggestions were either to combine the disabled
and opacity
properties, which is what I ended up using, or to temporarily move the widget off-screen. Using the first way to hide the Bubble
, I found out that even if it is disabled, it blocks the scrolling of the view behind it, even though the documentation states that this property
Indicates whether this widget can interact with input or not
So I would assume it shouldn't have blocked the scrolling. Interesting enough, when it wasn't hidden (disabled=False
), the scrolling passed right through it, which is even more confusing
I also had that Bubble
before contain a ScrollView
, which, in turn, held that GridLayout
. The following question is not an issue anymore, but still an interesting behaviour:
- Why did the
Bubble
pass the scrolling up, but didn't pass the scrolling down?
To understand what I mean, run the code, mouse over the Bubble
and try scrolling in different directions using the mouse wheel. That is considering the GridLayout
in the ScrollView
contains nothing, even though it doesn't affect the behaviour
Here is the code for both questions with some instructions to get the needed behaviour:
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.screenmanager import Screen
from kivy.uix.widget import Widget
from kivy.uix.textinput import TextInput
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
from kivy.uix.bubble import Bubble
from kivy.properties import ListProperty
Builder.load_string('''
<SmileBubble>:
size_hint: None, None
pos: 220, 90
size: 175, 250
#ScrollView:
#GridLayout:
#rows: 8 # To see the second question's example, uncomment this section
# and comment out the one below
GridLayout:
rows: 8
<MessageView>:
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
<Message>:
BoxLayout:
pos: root.pos
height: self.height
TextInput:
pos: root.pos
size: root.size
id: msg
''')
class Message(Widget):
bg_color = ListProperty([0.99, 0.99, 0.99, 1])
class SmileBubble(Bubble):
def hide(self):
self.disabled = True
def show(self):
self.disabled = False
class MessageView(ScrollView):
pass
class TestApp(App):
def msg_in(self, text):
msg = Message()
msg.ids['msg'].text = text
msg.size_hint = [None, None]
msg.width = 160
self.msg_layout.add_widget(msg)
def build(self):
self.scr = Screen()
self.sv1_main = MessageView()
self.msg_layout = GridLayout(cols = 1,
size_hint_y = None)
self.msg_layout.bind(minimum_height = self.msg_layout.setter('height'))
self.smile_bbl = SmileBubble()
for i in range(10):
self.msg_in("test")
self.smile_bbl.hide() # To hide/show the Bubble, comment out this line. For the second question, comment out this line
self.scr.add_widget(self.sv1_main)
self.sv1_main.add_widget(self.msg_layout)
self.scr.add_widget(self.smile_bbl)
return self.scr
TestApp().run()
If it matters, I'm using Kivy v1.9.2-dev0