Quick snackbar

已查看 35 次
跳至第一个未读帖子

coutinh...@gmail.com

未读,
2022年5月15日 08:18:292022/5/15
收件人 Kivy users support
Hello friends.

I'm having some trouble with the snackbar.
They work, they appear as is in the kivymd demo, however they appear where they are not needed.

In the attached example I have the screen_lista.py file

In the on_enter event on line 111 of this file it should show the snackbar, the error is that it is showing the snackbar as soon as the application starts.

Any tips?

Elliot Garbus

未读,
2022年5月15日 09:48:112022/5/15
收件人 kivy-...@googlegroups.com
Looks like you forgot to attach the file. 

Sent from my iPhone

On May 15, 2022, at 5:18 AM, coutinh...@gmail.com <coutinh...@gmail.com> wrote:

Hello friends.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c8bd4023-e806-4925-8a79-79ac0f480f34n%40googlegroups.com.

Elias Coutinho

未读,
2022年5月16日 06:46:212022/5/16
收件人 kivy-...@googlegroups.com
Elliot, if you click on some points on the first screen, the snackbar appears, it should only appear in the list.



--
Elias Coutinho.
Aprender sobre alguns assuntos é fundamental.
Aprender sobre Deus é indiscutivelmente o melhor conteúdo.
snackbar.zip

Elliot Garbus

未读,
2022年5月16日 10:43:522022/5/16
收件人 kivy-...@googlegroups.com

If the problem is you do not want to snackbar to be opened the first time the screen is entered, you can add a variable to track that.  See the example below.

 

class ScreenRecycleView(Screen):
    image_data = ListProperty()

   
def __init__(self, **kwargs):
       
super().__init__(**kwargs)
       
self.first_view = True

    def
on_kv_post(self, base_widget):
       
self.ids.rv.data = [
            {
                
'source': choice(sample_images),
               
'text': ''.join(sample(ascii_lowercase, 6))

            }
           
for x in range(50)
        ]

   
def on_enter(self):
       
if self.first_view:
           
self.first_view = False
        else
:
            Snackbar(
text='Após a pesquisa clique 2x na imagem.').open()

Elias Coutinho

未读,
2022年5月17日 18:59:552022/5/17
收件人 kivy-...@googlegroups.com
The problem is that I call the snackbar in the screen_lista file in the on_enter event, however on the login screen if I click anywhere other than a field it calls the snackbar incorrectly.

Elliot Garbus

未读,
2022年5月17日 23:07:242022/5/17
收件人 kivy-...@googlegroups.com

I did not see this behavior.

Elias Coutinho

未读,
2022年5月18日 07:51:472022/5/18
收件人 kivy-...@googlegroups.com
When the first screen appears, note that the snackbarr already appears, the correct thing would be to appear on the listing screen.

Captura de tela de 2022-05-18 08-50-01.png

Elliot Garbus

未读,
2022年5月18日 17:04:282022/5/18
收件人 kivy-...@googlegroups.com

The on_enter event is firing in your nested screen manager, causing the snackbar to show up.  The snackbar is not attached to the screen so is displayed on the current screen.  Here is a possible workaround.

 

Add a screen to the nested screen_manager as a place holder.  This way the ScreenRecycleView will not be entered by default.

 


ScreenManager:
    id: screen_manager
    Screen:  # placeholder so ScreenRecycleView is not opened by default
    ScreenRecycleView:
    TelaLogin:
    TelaItem:

 

Then in your primary screen_manager, change to the ‘screen_listagem’ when entering the main screen.

ScreenManager:
    id: screen_manager_login

    TelaLogin:
        name: 'tela_login'

    MainScreen:
        name: 'main_screen'
        on_enter: self.ids.screen_manager.current = 'screen_listagem'              
'''

 

This should fix the behavior of the SnackBar.

 

Things might be simpler if you did not nest your ScreenManagers.  They are both taking the full screen – so I don’t understand the utility of nesting them.

Elias Coutinho

未读,
2022年5月20日 18:32:122022/5/20
收件人 kivy-...@googlegroups.com
I think it's a bug, the problem continues.

Elliot Garbus

未读,
2022年5月20日 19:22:282022/5/20
收件人 kivy-...@googlegroups.com
I don’t see buggy behavior. 

Sent from my iPhone

On May 20, 2022, at 3:32 PM, Elias Coutinho <coutinh...@gmail.com> wrote:


回复全部
回复作者
转发
0 个新帖子