Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions python/note_input_widget/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@
class NoteInputDialog(QtGui.QDialog):
"""
A dialog wrapper for the :class:`NoteInputWidget` widget.

The dialog instance will mirror all attributes and methods
found on the embedded :class:`NoteInputWidget` instance.
Example::
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: this was looking odd in the sphinx docs!


note_dialog = NoteInputDialog(parent=self)
note_dialog.entity_created.connect(self._on_entity_created)
note_dialog.data_updated.connect(self.rescan)
note_dialog.set_bg_task_manager(self._task_manager)
note_dialog.set_current_entity(self._entity_type, self._entity_id)

# show modal
note_dialog.exec_()

"""
def __init__(self, *args, **kwargs):
def __init__(self, parent):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we do it everywhere else in the code. I think in general, we should try to avoid the *args, **kwargs open syntax unless we have reason to use it. It can make it trickier to make changes in the future - say for example we wanted to add some parameters to this method in the future.

"""
Constructor.
:param parent: Qt parent object
:type parent: :class:`~PySide.QtGui.QWidget`
"""
super(NoteInputDialog, self).__init__(*args, **kwargs)
super(NoteInputDialog, self).__init__(parent)

self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint)

Expand All @@ -36,4 +51,10 @@ def __init__(self, *args, **kwargs):
self.widget.open_editor()

def __getattr__(self, name):
"""
Attribute dispatcher that promotes all the properties
and methods of the NoteInputWidget up to the widget.

:param name: Attribute name to retrieve
"""
return getattr(self.widget, name)