Skip to content

Commit

Permalink
Merge pull request #483 from davidlatwe/qargparse-docstr
Browse files Browse the repository at this point in the history
Update `vendor.qargparse`
  • Loading branch information
davidlatwe authored Dec 14, 2019
2 parents 726022c + 41884c0 commit 1c641d3
Showing 1 changed file with 149 additions and 7 deletions.
156 changes: 149 additions & 7 deletions avalon/vendor/qargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def on_changed(self, arg):


class QArgument(QtCore.QObject):
"""Base class of argument user interface
"""
changed = QtCore.Signal()

# Provide a left-hand side label for this argument
Expand Down Expand Up @@ -242,6 +244,18 @@ def write(self, value):


class Boolean(QArgument):
"""Boolean type user interface
Presented by `QtWidgets.QCheckBox`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (bool, optional): Argument's default value, default None
enabled (bool, optional): Whether to enable this widget, default True
"""
def create(self):
widget = QtWidgets.QCheckBox()
widget.clicked.connect(self.changed.emit)
Expand Down Expand Up @@ -287,10 +301,11 @@ def read(self):


class Tristate(QArgument):
pass
"""Not implemented"""


class Number(QArgument):
"""Base class of numeric type user interface"""
default = 0

def create(self):
Expand All @@ -314,18 +329,61 @@ def create(self):


class Integer(Number):
pass
"""Integer type user interface
A subclass of `qargparse.Number`, presented by `QtWidgets.QSpinBox`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (int, optional): Argument's default value, default 0
min (int, optional): Argument's minimum value, default 0
max (int, optional): Argument's maximum value, default 99
enabled (bool, optional): Whether to enable this widget, default True
"""


class Float(Number):
pass
"""Float type user interface
A subclass of `qargparse.Number`, presented by `QtWidgets.QDoubleSpinBox`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (float, optional): Argument's default value, default 0.0
min (float, optional): Argument's minimum value, default 0.0
max (float, optional): Argument's maximum value, default 99.99
enabled (bool, optional): Whether to enable this widget, default True
"""


class Range(Number):
pass
"""Range type user interface
A subclass of `qargparse.Number`, not production ready.
"""


class Double3(QArgument):
"""Double3 type user interface
Presented by three `QtWidgets.QLineEdit` widget with `QDoubleValidator`
installed.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (tuple or list, optional): Default (0, 0, 0).
enabled (bool, optional): Whether to enable this widget, default True
"""
default = (0, 0, 0)

def create(self):
Expand Down Expand Up @@ -366,6 +424,19 @@ def focusOutEvent(event):


class String(QArgument):
"""String type user interface
Presented by `QtWidgets.QLineEdit`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (str, optional): Argument's default value, default None
placeholder (str, optional): Placeholder message for the widget
enabled (bool, optional): Whether to enable this widget, default True
"""
def __init__(self, *args, **kwargs):
super(String, self).__init__(*args, **kwargs)
self._previous = None
Expand Down Expand Up @@ -396,14 +467,41 @@ def onEditingFinished(self):


class Info(String):
pass
"""String type user interface but read-only
A subclass of `qargparse.String`, presented by `QtWidgets.QLineEdit`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (str, optional): Argument's default value, default None
enabled (bool, optional): Whether to enable this widget, default True
"""


class Color(String):
pass
"""Color type user interface
A subclass of `qargparse.String`, not production ready.
"""


class Button(QArgument):
"""Button type user interface
Presented by `QtWidgets.QPushButton`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (bool, optional): Argument's default value, default None
enabled (bool, optional): Whether to enable this widget, default True
"""
label = False

def create(self):
Expand Down Expand Up @@ -432,10 +530,26 @@ def create(self):


class Toggle(Button):
pass
"""Checkable `Button` type user interface
Presented by `QtWidgets.QPushButton`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
default (bool, optional): Argument's default value, default None
enabled (bool, optional): Whether to enable this widget, default True
"""


class InfoList(QArgument):
"""String list type user interface
Presented by `QtWidgets.QListView`, not production ready.
"""
def __init__(self, name, **kwargs):
kwargs["default"] = kwargs.pop("default", ["Empty"])
super(InfoList, self).__init__(name, **kwargs)
Expand All @@ -457,6 +571,20 @@ def data(self, index, role):


class Choice(QArgument):
"""Argument user interface for selecting one from list
Presented by `QtWidgets.QListView`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
items (list, optional): List of strings for select, default `["Empty"]`
default (str, optional): Default item in `items`, use first of `items`
if not given.
enabled (bool, optional): Whether to enable this widget, default True
"""
def __init__(self, name, **kwargs):
kwargs["items"] = kwargs.get("items", ["Empty"])
kwargs["default"] = kwargs.pop("default", kwargs["items"][0])
Expand Down Expand Up @@ -541,6 +669,20 @@ def create(self):


class Enum(QArgument):
"""Argument user interface for selecting one from dropdown list
Presented by `QtWidgets.QComboBox`.
Arguments:
name (str): The name of argument
label (str, optional): Display name, convert from `name` if not given
help (str, optional): Tool tip message of this argument
items (list, optional): List of strings for select, default `[]`
default (int, optional): Index of default item, use first of `items`
if not given.
enabled (bool, optional): Whether to enable this widget, default True
"""
def __init__(self, name, **kwargs):
kwargs["default"] = kwargs.pop("default", 0)
kwargs["items"] = kwargs.get("items", [])
Expand Down

0 comments on commit 1c641d3

Please sign in to comment.