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

Can't set attrs parameters for Custom Node class #731

Open
iazulkarnain-tlkm opened this issue Jul 26, 2022 · 1 comment
Open

Can't set attrs parameters for Custom Node class #731

iazulkarnain-tlkm opened this issue Jul 26, 2022 · 1 comment

Comments

@iazulkarnain-tlkm
Copy link

The Problem

I can't set attr parameters and its values when creating a new instance of the Custom Node class.

How to reproduce the problem

from diagrams.custom import Custom
rabbitmq_icon = "icons/rabbitmq_icon.png"
test = Custom("crawler_news_kazee_q", rabbitmq_icon,pin="true",pos="4,2")

Error notification

TypeError: Custom.__init__() got an unexpected keyword argument 'pin'

Original codes

The original codes for custom node class is:

"""
Custom provides the possibility of load an image to be presented as a node.
"""

from diagrams import Node


class Custom(Node):
    _provider = "custom"
    _type = "custom"
    _icon_dir = None

    fontcolor = "#ffffff"

    def _load_icon(self):
        return self._icon

    def __init__(self, label, icon_path):
        self._icon = icon_path
        super().__init__(label)

Proposed Fix:

"""
Custom provides the possibility of load an image to be presented as a node.
"""

from diagrams import Node


class Custom(Node):
    _provider = "custom"
    _type = "custom"
    _icon_dir = None

    fontcolor = "#ffffff"

    def _load_icon(self):
        return self._icon

    def __init__(self, label, icon_path, **attrs):
        self._icon = icon_path
        super().__init__(label,**attrs)
@bdsoha
Copy link
Contributor

bdsoha commented Jan 8, 2023

@iazulkarnain-tlkm @mingrammer This was fixed already in #437 and can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants