https://bugs.kde.org/show_bug.cgi?id=428181

samuel-w <343vhy...@relay.firefox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |343vhy...@relay.firefox.com

--- Comment #4 from samuel-w <343vhy...@relay.firefox.com> ---
I created a code example, requires PyQt5. Expected behaviour is clicking the
open button prints the path.

from PyQt5 import QtCore
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget
import os
import sys

class App(QWidget):
    def __init__(self):
        def receive():
            dirs = dialog.selectedFiles()
            print(dirs)
        super().__init__()
        dialog = choose_file_dialog(self, "asdf", want_folder=True)
        dialog.open(receive)  # Open and cancel buttons don't do anything on
KDE, breaks here.
        dialog.exec()
        sys.exit()


def choose_file_dialog(parent, title, want_folder=True):
    options = QFileDialog.Options()
    if want_folder:
        options |= QFileDialog.ShowDirsOnly
    dialog = QFileDialog(parent, title, os.path.expanduser('~'),
options=options)
    dialog.setFileMode(QFileDialog.Directory if want_folder else
QFileDialog.ExistingFiles)
    dialog.setParent(parent, QtCore.Qt.Sheet)
    return dialog

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    sys.exit(app.exec_())

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to