-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
❓ Questions and Help
Is it possible to have nested @guiclass ?
For example, I would like something like this to work:
from magicgui.experimental import guiclass, button
@guiclass
class A:
a: int = 0
b: str = 'hello'
@guiclass
class B:
inst_a: A = A()
c: bool = True
@button
def greet(self):
print(f'Greetings! a={self.inst_a.a}, b={self.inst_a.b}, c={self.c}')The code above fails to run, and I get the following error: ValueError: No widget found for type <class '__main__.A'> and annotation <class '__main__.A'>
What seems to be possible, is to rewrite it like this:
@guiclass
class A:
a: int = 0
b: str = 'hello'
@guiclass
class B:
#inst_a: A = A()
c: bool = True
def __init__(self):
self.inst_a = A()
self.gui.append(self.inst_a.gui)
@button
def greet(self):
print(f'Greetings! a={self.inst_a.a}, b={self.inst_a.b}, c={self.c}')
I've been looking for a while in the documentation, and I don't think it's written whether it's possible to have this (or not). If not, it would be a cool feature to have!
[x] I have searched the documentation
Metadata
Metadata
Assignees
Labels
No labels