Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[kivy-users] KIVY SCALING ISSUES ON HIGH RESOLUTION SETTINGS

34 views
Skip to first unread message

Jacob Mugala

unread,
Mar 23, 2025, 11:08:09 PMMar 23
to kivy-...@googlegroups.com
Hello,

I am facing a graphics scaling issue in kivy/kivymd when my laptop display resolution is set to 1920 × 1080 (16:9) and scale 125%, kivy window and graphics get too small. How do I work around this?

Platform:
   Machine: Dell Latitude 5480   
   Ubuntu 24.04.2 LTS
   Python v3.12.3
   kivy v2.3.1
   kivymd  v1.2.0,

Output:
image.png

Code:
from kivymd.app import MDApp
from kivy.lang import Builder

from beeui.card import BeeCard
from beeui.layouts import BeeSideRail
from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.label import MDIcon
from beeui.labels import BeeHeaderLabel, BeeTextSpanLabel, BeeFitLabel
from beeui.textinput import BeeTextInput
from beeui.buttons import BeeAbstractButton, BeePlainButton, BeeButton
from kivy.config import Config
from kivy.config import Config
Config.set('graphics', 'dpi', '160') # Adjust value as needed
Config.set('graphics', 'width', '1920')
Config.set('graphics', 'height', '1080')



kv = """
#import MDIcon kivymd.uix.label

BoxLayout:
BeeSideRail:
BoxLayout:
padding: 10
orientation: 'vertical'
BeeFitLabel:
text: "Recents"
hflow: True

BoxLayout:
orientation: "vertical"
padding: 10
spacing: 10
BeeCompoundButton:
orientation: "vertical"
size_hint_y: .2
MDLabel:
text: "/mog/home/downlaod/album/songs/glass.mp3"

BoxLayout:
spacing: 10
BeeButton:
text: "Mutate"
bold: True

BeeButton:
text: "Immutate"
bold: True

BeeButton:
text: "Delete"
background_color: [.8, 0, 0, .5]

BoxLayout:



BoxLayout:
padding: 10
orientation: 'vertical'

BeeTextInput:
right_buttons: [{"icon": "plus"}]

BoxLayout:
orientation: "vertical"
spacing: 20
#
# BeeHeaderLabel:
# text: "No Backup tap the '+' to add one"
# size_hint_y: None
# height: self.texture_size[1]
# # text_size: self.size
# halign: "center"
#
# MDIcon:
# icon: "safe-square"
# size_hint_y: None
# height: self.texture_size[1]
# font_size: 70
# text_size: self.size
# halign: "center"
# color: [.6, .6, .6, 1]
"""


class BeeCompoundButton(BoxLayout, BeeAbstractButton):
def __init__(self, **kwargs):
super().__init__(**kwargs)


class BaseBackApp(MDApp):
def build(self):
# self.theme_cls.theme_style = 'Dark'
return Builder.load_string(kv)


if __name__ == '__main__':
BaseBackApp().run()

I tried setting the resolution to 1800 × 900 (16:9) and scale 100% for which kivy gives better results. But I just want it to work better with 1920 × 1080 (16:9) and scale 125% settings.

I appreciate you response🙏

Jacob,

elli...@cox.net

unread,
Mar 24, 2025, 11:33:57 AMMar 24
to kivy-...@googlegroups.com

Specify dimensions as dp(10) or '10dp'

For example:
padding: dp(10)

 

From: kivy-...@googlegroups.com <kivy-...@googlegroups.com> on behalf of Jacob Mugala <4de...@gmail.com>
Sent: Sunday, March 23, 2025 8:07 PM
To: kivy-...@googlegroups.com <kivy-...@googlegroups.com>
Subject: [kivy-users] KIVY SCALING ISSUES ON HIGH RESOLUTION SETTINGS
 
--
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 visit https://groups.google.com/d/msgid/kivy-users/CADg77KHJjjGySjSi8zHUmyzc1ShoSK7E_nexy0GYd7Tea9KSjg%40mail.gmail.com.

Jacob Mugala

unread,
Mar 31, 2025, 12:25:20 AMMar 31
to kivy-...@googlegroups.com
Hello;

It's no working a tried.

main.py
from kivy import Config
from kivy.app import App
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
Config.set('graphics', 'dpi', 'dp(160)') # Adjust value as needed
Config.set('graphics', 'width', 'dp(1920)')
Config.set('graphics', 'height', 'dp(1080)')



class Box(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.button = Button(text=f"Hello World {Window.dpi}")
self.add_widget(self.button)


class MainApp(App):
def build(self):
return Box()


if __name__ == '__main__':
MainApp().run()
OUTPUT:
image.png



ElliotG

unread,
Mar 31, 2025, 2:03:24 PMMar 31
to Kivy users support
The config.set statements must be before kivy.app is imported. 

The Config.set takes an int as the third parameter. 
In the example below, I demonstrate using dp on the sized objects with dp.  These objects will be the same relative size across devices.

from kivy import Config
# The config.set commands must be before kivy.app is imported
# Config.set('graphics', 'dpi', 160) # the system sets the dpi
# Config.set('graphics', 'width', 600)
# Config.set('graphics', 'height', 600)

from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.metrics import Metrics


kv = f"""
BoxLayout:
    orientation: 'vertical'
    AnchorLayout:
        Button:
            id: button
            size_hint: None, None
            size: dp(200), dp(48)  # use dp on sized objects
            text: f'Show Info'
            on_release: app.show_info()
    Label:
        id: label
        size_hint_y: None
        height: dp(50)
"""


class SetSizeApp(App):
    def build(self):
        return Builder.load_string(kv)

    def show_info(self):
        button = self.root.ids.button
        self.root.ids.label.text = f'{Metrics.dpi=}; {Window.size=}; {button.size=}'

SetSizeApp().run()
Reply all
Reply to author
Forward
0 new messages