please help me change height in MDToolbar widget (kaki + kivy + kivymd)

548 views
Skip to first unread message

Dmytro Kravchenko

unread,
May 12, 2022, 9:29:36 AM5/12/22
to Kivy users support
Hello. Thanks for reading! When i try change height on MDToolbar but nothing happened. 
My code: 
Main.py:
=====================
import os

from kivy.properties import StringProperty, NumericProperty
from kivy.config import Config

from kaki.app import App
# from kivymd.factory_registers import Factory
from kivy.factory import Factory
from kivymd.app import MDApp
from kivymd.uix.button import MDFlatButton


from ui.snackbar import CustomSnackbar
from kivy.core.window import Window


Window.maximize()
from kivy.config import Config
Config.set("kivy", "log_level", "debug")


# main app class for kaki app with kivymd modules
class DoClusterApp(MDApp, App):
""" Hi Windows users """

DEBUG = 1 # set this to 0 make live app not working

# *.kv files to watch
KV_FILES = {
os.path.join(os.getcwd(), "ui/screenmanager.kv"), # main screen manager
os.path.join(os.getcwd(), "ui/login/login.kv"), # login lo
os.path.join(os.getcwd(), "ui/snackbar.kv"), # snackbar
os.path.join(os.getcwd(), "ui/root.kv"), # root screen
}

# class to watch from *.py files
CLASSES = {
"MainScreenManager": "ui.screenmanager",
"LoginScreen": "ui.login.login",
"CustomSnackbar": "ui.snackbar",
"RootScreen": "ui.root",
}

# auto reload path
AUTORELOADER_PATHS = [
(".", {"recursive": True}),
]

def build_app(self, **kwargs):
self.icon = "ui/img/logo.png"
return Factory.RootScreen()

@classmethod
def show(cls, text):
"""
Эта функция необходима для вызова всплывающего уведомления
"""
print(text)
snackbar = CustomSnackbar(
text=text,
icon="information",
snackbar_x="10dp",
snackbar_y="10dp",
# buttons=[MDFlatButton(text="Ok", text_color=(0, 0, 0, 0))]
)
snackbar.size_hint_x = (Window.width - (snackbar.snackbar_x * 2)) / Window.width
snackbar.open()

@classmethod
def runsss(cls, text):
print(text)
app = MDApp.get_running_app()
print(app.root)


# finally, run the app
if __name__ == "__main__":
DoClusterApp().run()

===============
root.kv:
======
#: import dp kivy.metrics.dp

<RootScreen>:
id: root_screen
FloatLayout:
orientation: "horizontal"
MDToolbar:
id: toolbar
pos_hint: {"top": 1}
size_hint: 1, None
size: 0, dp(1)
elevation: 10
title: "ZW"
left_action_items: [["menu", lambda x: root.ids.appmenu.set_states(root.ids.appmenu2)]]
======
My widget MDToolbar must be to 1 dp size height, but my MDToolbar widget have 64 dp (standard size) always. Tell me please, what I'm doing wrong, why can't I change the height of the bar? 
Could it be a problem with the kaki module?

Guilherme Soares Lima

unread,
May 12, 2022, 11:04:00 AM5/12/22
to Kivy users support
I haven 't tried to see if it works.
I would remove "size" row and add:

height: '1dp'

see if it works. Remember proper indentation.

Elliot Garbus

unread,
May 12, 2022, 12:20:13 PM5/12/22
to kivy-...@googlegroups.com

Your code formatting will be retained if you right click and select “paste as plain text”

--
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/e00139d4-fa2c-44f1-998d-70211d113109n%40googlegroups.com.

 

Guilherme Soares Lima

unread,
May 12, 2022, 12:39:31 PM5/12/22
to Kivy users support
There's a shortcut for this (on many systems): "ctrl-shift-v".

Elliot Garbus

unread,
May 12, 2022, 12:56:40 PM5/12/22
to kivy-...@googlegroups.com

I just did a quick test, MDToolbar does not have an adjustable height attribute.

 

 

From: Dmytro Kravchenko
Sent: Thursday, May 12, 2022 6:29 AM
To: Kivy users support
Subject: [kivy-users] please help me change height in MDToolbar widget (kaki +kivy + kivymd)

 

Hello. Thanks for reading! When i try change height on MDToolbar but nothing happened. 

--

Guilherme Soares Lima

unread,
May 12, 2022, 1:06:48 PM5/12/22
to Kivy users support
I decided to take a look on the docs, I don't  know what are you trying to accomplish but it says:

type_height
Toolbar height type.

New in version 1.0.0.
Available options are: ‘small’, ‘large’, ‘small’.

type_height is an OptionProperty and defaults to ‘small’.

https://kivymd.readthedocs.io/en/latest/components/toolbar/index.html

Hope it helps!
Reply all
Reply to author
Forward
0 new messages