Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set title correctly in the class FormDockWidget #102

Merged
merged 9 commits into from
Nov 30, 2023
4 changes: 3 additions & 1 deletion eqt/ui/UIFormWidget.py
Original file line number Diff line number Diff line change
@@ -337,7 +337,9 @@ def __init__(self, parent=None):

class FormDockWidget(QtWidgets.QDockWidget):
def __init__(self, parent=None, title=None):
QtWidgets.QDockWidget.__init__(self, parent)
if title is None:
title = ''
QtWidgets.QDockWidget.__init__(self, title, parent)
widget = FormWidget(parent)
self.setWidget(widget)
if title is not None:
3 changes: 1 addition & 2 deletions examples/remove_widgets_example.py
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)

# create a FormDockWidget
dock = UIFormWidget.FormDockWidget(parent=self)
dock.setWindowTitle('Example remove widget')
dock = UIFormWidget.FormDockWidget(parent=self, title='Example remove widget')
self.addWidgetsToExampleForm(dock)

# add a button to dock to remove user selected widget
12 changes: 12 additions & 0 deletions test/test__formUI_status_test.py
Original file line number Diff line number Diff line change
@@ -328,6 +328,12 @@ def setUp(self):
self.add_two_widgets()
self.layout = self.form.formWidget.uiElements['groupBoxFormLayout']

def test_form_init_title(self):
"""Tests if the FormDialog is created correctly with or without the title argument."""
FormDialog()
FormDialog(title=None)
FormDialog(title='title')

def test_getWidgetState_returns_QLabel_value(self):
"""Check that the value of the QLabel is saved to the state"""
initial_label_value = 'Label: '
@@ -478,6 +484,12 @@ def setUp(self):
self.add_two_widgets()
self.layout = self.form.widget().uiElements['groupBoxFormLayout']

def test_form_init_title(self):
"""Tests if the FormDockWidget is created correctly with or without the title argument."""
FormDockWidget()
FormDockWidget(title=None)
FormDockWidget(title='title')

def test_getWidgetState_returns_QLabel_value(self):
"""Check that the value of the QLabel is saved to the state"""
initial_label_value = 'test label'