diff options
Diffstat (limited to 'examples/fileDialog.py')
-rw-r--r-- | examples/fileDialog.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/examples/fileDialog.py b/examples/fileDialog.py index 82e6798..6683ca4 100644 --- a/examples/fileDialog.py +++ b/examples/fileDialog.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# Copyright (c) 2016-2021 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,8 +26,6 @@ Example for the use of the ImageFileDialog. """ -from __future__ import absolute_import - __authors__ = ["V. Valls"] __license__ = "MIT" __date__ = "14/02/2018" @@ -41,7 +38,7 @@ from silx.gui.dialog.DataFileDialog import DataFileDialog import silx.io -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig() class Mode(enum.Enum): @@ -54,7 +51,6 @@ class Mode(enum.Enum): class DialogExample(qt.QMainWindow): - def __init__(self, parent=None): super(DialogExample, self).__init__(parent) @@ -177,7 +173,7 @@ class DialogExample(qt.QMainWindow): node = h5[url.data_path()] print("- Node: %s" % node) else: - assert(False) + assert False def createDialog(self): print("") @@ -200,15 +196,17 @@ class DialogExample(qt.QMainWindow): dialog = DataFileDialog(self) dialog.setFilterMode(DataFileDialog.FilterMode.ExistingGroup) elif mode == Mode.DATAFILEDIALOG_NXENTRY: + def customFilter(obj): if "NX_class" in obj.attrs: - return obj.attrs["NX_class"] in [b"NXentry", u"NXentry"] + return obj.attrs["NX_class"] in [b"NXentry", "NXentry"] return False + dialog = DataFileDialog(self) dialog.setFilterMode(DataFileDialog.FilterMode.ExistingGroup) dialog.setFilterCallback(customFilter) else: - assert(False) + assert False return dialog def openDialog(self): @@ -216,7 +214,7 @@ class DialogExample(qt.QMainWindow): dialog = self.createDialog() # Execute the dialog as modal - result = dialog.exec_() + result = dialog.exec() self.printResult(dialog, result) def openDialogStoredState(self): @@ -226,7 +224,7 @@ class DialogExample(qt.QMainWindow): dialog.restoreState(self.__state[dialog.__class__]) # Execute the dialog as modal - result = dialog.exec_() + result = dialog.exec() self.__state[dialog.__class__] = dialog.saveState() self.printResult(dialog, result) @@ -237,7 +235,7 @@ class DialogExample(qt.QMainWindow): dialog.setDirectory(path) # Execute the dialog as modal - result = dialog.exec_() + result = dialog.exec() self.printResult(dialog, result) def openDialogAtComputer(self): @@ -247,7 +245,7 @@ class DialogExample(qt.QMainWindow): dialog.setDirectory(path) # Execute the dialog as modal - result = dialog.exec_() + result = dialog.exec() self.printResult(dialog, result) @@ -255,7 +253,7 @@ def main(): app = qt.QApplication([]) example = DialogExample() example.show() - app.exec_() + app.exec() if __name__ == "__main__": |