-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Implement PyComponent #7051
Implement PyComponent #7051
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7051 +/- ##
==========================================
- Coverage 82.23% 81.82% -0.42%
==========================================
Files 334 337 +3
Lines 49925 50199 +274
==========================================
+ Hits 41058 41077 +19
- Misses 8867 9122 +255 ☔ View full report in Codecov by Sentry. |
The content here is ready for review. I believe though that it should be refactored using a new |
-1 on actually documenting CompositeWidget, through composition this can now be achieved using |
Just read your last comment, glad we agree 😄 |
Just had a look at the tutorial and imo it absolutely does not read like a tutorial. There's no real steps for the user to follow along except for pasting the entire thing into a file and then running it. It's really much closer to a how-to guide. |
…ent/document-composite-widget
Fair point. I will try to improve it. Its just hard for me to see how I can break it further down as it consists of a single class definition and a single function. |
It would like to help finalize this, but its very unclear for me how to proceed. It seems to me that the When I run import panel as pn
import param
from panel.custom import PyComponent
class CounterButton(PyComponent):
value = param.Integer()
def __init__(self, **params):
super().__init__()
self._layout = pn.widgets.Button(
name=self._button_name, on_click=self._on_click, **params
)
def _on_click(self, event):
self.value += 1
@param.depends("value")
def _button_name(self):
return f"count is {self.value}"
def __panel__(self):
return self._layout
CounterButton(width=300) I get TypeError: PyComponent._sync__views() takes 1 positional argument but 2 were given Do you plan on finalizing the implementation of the |
I don't plan on changing anything else, there was just a small typo. I'm unclear whether it's useful or adds anything on top of what |
Nevermind, it does need a lot more work. |
The docs can still be improved here but the component now behaves as I'd like it to and I want it to get into an RC release. |
I've been pointing out multiple times that its very hard to create real Panel widgets from the
Viewer
. Andrew then told me in #7030 that I should be using theCompositeWidget
. I had not used that because theViewer
was originally added to enable me and others to create custom Panel components in general, so I thought that was the one I should use.