-
Notifications
You must be signed in to change notification settings - Fork 7
Fixes #14
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
Conversation
Still not a fan of this, why **kwargs? What was past-Marcus thinking?
|
Opps, version num fallback to |
|
Nice catch, thanks |
|
Hope we didn't lose any other changes? :O |
| kwargs["default"] = kwargs.pop("default", None) | ||
| kwargs["items"] = kwargs.get("items", []) | ||
| kwargs["items"] = kwargs.get("items", ["Default"]) | ||
| kwargs["default"] = kwargs.pop("default", kwargs["items"][0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeError raised if kwargs["items"] is a generator :/
TypeError: 'generator' object is not subscriptable
But shouldn't make it to list here as well, the current use case is to run the generator on create.
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, change to kwargs.pop("default", 0) should work ? since looks like Enum is now all index-based ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm changing the line
kwargs["default"] = kwargs.pop("default", kwargs["items"][0])into
kwargs["default"] = kwargs.pop("default", 0)works. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this should work nicely with it also being able to take an integer. Because otherwise, we would have needed to fetch the first string-item from that "items" list.
|
> Integer("foo", min=1)
TypeError: Integer() got an unexpected keyword argument 'min' # |
|
For clarity, left-hand side is native Maya and right-hand side is qargparse. class Options(QtWidgets.QMainWindow):
def __init__(self, title, parent=None):
super(Options, self).__init__(parent)
self.setWindowTitle(title)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setMinimumWidth(px(550))
self.setMinimumHeight(px(370))
buttons = [
QtWidgets.QPushButton("Create Rigid"),
QtWidgets.QPushButton("Apply"),
QtWidgets.QPushButton("Close"),
]
central = QtWidgets.QWidget()
# central = QtWidgets.QGroupBox()
header = self.menuBar()
# body = QtWidgets.QWidget()
footer = QtWidgets.QWidget()
edit = header.addMenu("&Edit")
hlp = header.addMenu("&Help")
edit.addAction("Save Settings")
edit.addAction("Reset Settings")
hlp.addAction("Help on Create Rigid Options")
layout = QtWidgets.QHBoxLayout(footer)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(buttons[0])
layout.addWidget(buttons[1])
layout.addWidget(buttons[2])
args = [
qargparse.Enum("Bind to", items=["Joint Hierarchy", "Selected Joints", "Object Hierarchy"]),
qargparse.Enum("Bind method", items=["Closest Distance", "Closest in hierarchy", "Geodesic voxel"]),
qargparse.Enum("Skinning method", items=["Classic linear", "Dual quaternion"]),
qargparse.Enum("Normalize weights", items=["Interactive", "Post"]),
qargparse.Enum("Weight distribution", items=["Distance", "Neighbors"]),
qargparse.Boolean("Allow multiple bind poses", default=True),
qargparse.Integer("Max influences", default=5, min=1, max=30),
qargparse.Boolean("Maintain max influences", default=True),
qargparse.Boolean("Remove unused influences", default=True),
qargparse.Boolean("Colorize skeleton", default=True),
qargparse.Boolean("Include hidden selections on creation", default=False),
qargparse.Float("Falloff", min=0.0, max=1.0, default=0.2),
qargparse.Enum("Resolution", items=["1024", "512", "256"], default="256"),
qargparse.Boolean("Validate voxel state", default=True),
]
parser = qargparse.QArgumentParser(args)
layout = QtWidgets.QVBoxLayout(central)
layout.addWidget(parser)
layout.addWidget(footer)
self.setCentralWidget(central)
opt = Options("Bind Skin Options")
opt.show()I was going to collapse the comboboxes, like they are in Maya. But now I'm not so sure. In bulk like this, it looks quite nice. I do want those sliders though, they are handy. |
Like things all aligned together as well |
- Improve DPI handling -
# Conflicts: # qargparse.py
|
Added a separate examples file. $ python examples.pyThere's some issue with PySide2 under Maya 2018, the blurry one is at 1.0x scale, the others at 1.5x scale, where 2018 should minimize the width but isn't. Isn't respecting the QSizePolicy it seems like. Not sure what that's about. :/ Either way, I made it an option to either fill or not fill the enum boxes, can't make up my mind and expect others will want the choice. QArgumentParser(style={"comboboxFillWidth": True})I also thought more about whether to include the qargparse.Enum("No spacing")
qargparse.Enum("Spacing: ")
qargparse.Enum("Special spacing : ")
# etc.. |
Now it'll act on mouse-down instead of up, as up only took effect if you pressed and released whilst holding the cursor on that little square (hard with a pen)
|
You can now add an For example. There's also a separation made between default and "initial" value, the default being what you reset to when pressing the reset button, initial being the initial value put into the argument on launch. You would use that to e.g. store initial values on disk, whilst keeping the reset button and the original default value intact. Boolean("alive", default=True, initial=False) |
For cleanup and automatic disconnect of signal connections to arguments
Awesome !
Does that means this mottosso/allzpark#49 can be resolved as well ? |
|
Oo, yes, yes it would. |
|
This works well for me so far, think it's ready to merge. |




Namely:
Enum(fields=["A", "B"])becausefieldsisn't an argument that exists. Still wondering whether we should just use regular function arguments here, would probably help IDEs highlight available arguments etc.Enumcan now be reset properly.