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
https://kivymd.readthedocs.io
MIT License
2.14k stars 655 forks source link

MDFileManager cancel button goes past the right border of window #1678

Closed lulingar closed 2 months ago

lulingar commented 2 months ago

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

HeaTTheatR commented 2 months ago

https://github.com/kivymd/KivyMD/issues/1660

lulingar commented 2 months ago

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.

HeaTTheatR commented 2 months ago

So far, the issue remains open...