kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd

Home Page:https://kivymd.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MDFileManager cancel button goes past the right border of window

lulingar opened this issue · comments

Description of the Bug

The position of the cancel button (X shape at the top right of the window) is strongly coupled to the size of the path currently selected in the MDFileManager, such that once the path length grows past some limit, the button is rendered out of the window, well past the right border, and hence it is unreachable. The screenshot sequence below demonstrates it:

Screenshots

image
image
image
image

Code and Logs

from pathlib import Path
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivymd.app import MDApp
from kivymd.uix.filemanager import MDFileManager

KV = '''
<MyView>:
    MDBoxLayout:
        orientation: 'vertical'

        Button:
            text: "Open manager"
            on_release: root.file_manager_open()

MDScreen:
    MDBoxLayout:
        MyView:
'''

class MyView(BoxLayout):

    def __init__(self, **kargs):
        super().__init__(**kargs)
        self.manager_open = False
        self.opening_path = Path.cwd()
        self.file_manager = MDFileManager(
            search="dirs",
            exit_manager=self.exit_manager,
            select_path=self.select_path,
        )

    def file_manager_open(self):
        self.file_manager.show(str(self.opening_path))
        self.manager_open = True

    def select_path(self, path_str: str):
        """
        It will be called when the user clicks on the file name
        or the catalog selection button.

        :param path: path to the selected directory or file;
        """
        self.exit_manager()
        path = Path(path_str)
        self.opening_path = path.parent

    def exit_manager(self, *args):
        """Called when the user reaches the root of the directory tree."""
        self.manager_open = False
        self.file_manager.close()


class MainApp(MDApp):
    def build(self):
        self.root = Builder.load_string(KV)


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

Versions

  • OS: Ubuntu 22.04
  • Python: 3.11.8
  • Kivy: 2.3.0
  • KivyMD: ea56649 (requirements.txt has: kivymd @ git+https://github.com/kivymd/KivyMD.git@ea56649290aba81bfae81d02d081c5bb44ee0a4a)

Thanks for triaging this issue. Is there a workaround I can apply to my code, pending the bugfix? I don't mind "forking classes" and contributing here once the workaround is suitable, so if you could provide a hint, I would appreciate it.

So far, the issue remains open...