Skip to content

Commit 38d4065

Browse files
committed
Remove modality of figure options
1 parent 1cf8786 commit 38d4065

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/matplotlib/backends/qt_editor/_formlayout.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,11 @@ def get(self):
413413
class FormDialog(QtWidgets.QDialog):
414414
"""Form Dialog"""
415415
def __init__(self, data, title="", comment="",
416-
icon=None, parent=None, apply=None):
416+
icon=None, parent=None, apply=None, modal=True):
417417
super().__init__(parent)
418418

419419
self.apply_callback = apply
420+
self.modal = modal
420421

421422
# Form
422423
if isinstance(data[0][0], (list, tuple)):
@@ -469,6 +470,8 @@ def update_buttons(self):
469470
btn.setEnabled(valid)
470471

471472
def accept(self):
473+
if not self.modal:
474+
self.apply_callback(self.formwidget.get())
472475
self.data = self.formwidget.get()
473476
super().accept()
474477

@@ -484,7 +487,8 @@ def get(self):
484487
return self.data
485488

486489

487-
def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
490+
def fedit(data, title="", comment="", icon=None, parent=None, apply=None,
491+
modal=True):
488492
"""
489493
Create form dialog and return result
490494
(if Cancel button is pressed, return None)
@@ -495,6 +499,7 @@ def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
495499
icon: QIcon instance
496500
parent: parent QWidget
497501
apply: apply callback (function)
502+
modal: modality of dialog
498503
499504
datalist: list/tuple of (field_name, field_value)
500505
datagroup: list/tuple of (datalist *or* datagroup, title, comment)
@@ -511,13 +516,19 @@ def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
511516
- list/tuple:
512517
* the first element will be the selected index (or value)
513518
* the other elements can be couples (key, value) or only values
519+
520+
If modal is True, the application will block until the result is selected.
521+
If modal is false, the dialog will be shown and the function returns None.
514522
"""
515523

516524
# Create a QApplication instance if no instance currently exists
517525
# (e.g., if the module is used directly from the interpreter)
518526
if QtWidgets.QApplication.startingUp():
519527
_app = QtWidgets.QApplication([])
520-
dialog = FormDialog(data, title, comment, icon, parent, apply)
528+
dialog = FormDialog(data, title, comment, icon, parent, apply, modal)
529+
if not modal:
530+
dialog.show()
531+
return
521532
if dialog.exec_():
522533
return dialog.get()
523534

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,4 @@ def apply_callback(data):
255255
datalist, title="Figure options", parent=parent,
256256
icon=QtGui.QIcon(
257257
str(cbook._get_data_path('images', 'qt4_editor_options.svg'))),
258-
apply=apply_callback)
259-
if data is not None:
260-
apply_callback(data)
258+
apply=apply_callback, modal=False)

0 commit comments

Comments
 (0)