Skip to content

Commit

Permalink
Merge pull request #22328 from meeseeksmachine/auto-backport-of-pr-22…
Browse files Browse the repository at this point in the history
…288-on-v3.5.x

Backport PR #22288 on branch v3.5.x (update documentation after #18966)
  • Loading branch information
tacaswell committed Jan 27, 2022
2 parents ffb11cd + 386326d commit dae7a48
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lib/matplotlib/backends/qt_editor/_formlayout.py
Expand Up @@ -47,7 +47,8 @@
from numbers import Integral, Real

from matplotlib import _api, colors as mcolors
from ..qt_compat import QtGui, QtWidgets, QtCore, _enum, _to_int
from matplotlib.backends.qt_compat import (
QtGui, QtWidgets, QtCore, _enum, _to_int)

_log = logging.getLogger(__name__)

Expand Down Expand Up @@ -498,8 +499,7 @@ def get(self):

def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
"""
Create form dialog and return result
(if Cancel button is pressed, return None)
Create form dialog
data: datalist, datagroup
title: str
Expand Down Expand Up @@ -541,6 +541,8 @@ def fedit(data, title="", comment="", icon=None, parent=None, apply=None):

if __name__ == "__main__":

_app = QtWidgets.QApplication([])

def create_datalist_example():
return [('str', 'this is a string'),
('list', [0, '1', '3', '4']),
Expand Down Expand Up @@ -568,18 +570,24 @@ def create_datagroup_example():

def apply_test(data):
print("data:", data)
print("result:", fedit(datalist, title="Example",
comment="This is just an <b>example</b>.",
apply=apply_test))
fedit(datalist, title="Example",
comment="This is just an <b>example</b>.",
apply=apply_test)

_app.exec()

# --------- datagroup example
datagroup = create_datagroup_example()
print("result:", fedit(datagroup, "Global title"))
fedit(datagroup, "Global title",
apply=apply_test)
_app.exec()

# --------- datagroup inside a datagroup example
datalist = create_datalist_example()
datagroup = create_datagroup_example()
print("result:", fedit(((datagroup, "Title 1", "Tab 1 comment"),
(datalist, "Title 2", "Tab 2 comment"),
(datalist, "Title 3", "Tab 3 comment")),
"Global title"))
fedit(((datagroup, "Title 1", "Tab 1 comment"),
(datalist, "Title 2", "Tab 2 comment"),
(datalist, "Title 3", "Tab 3 comment")),
"Global title",
apply=apply_test)
_app.exec()

0 comments on commit dae7a48

Please sign in to comment.