from ipywidgets import interact
def any_function_returning_value(word1,word2):
new_word = 'Combining words is easy: %s %s'%(word1,word2)
return new_word
class interact_workaround():
def __init__(self, param1 = 'a word', param2 = 'another word'):
self.p1 = param1
self.p2 = param2
self.w = interact(self.interact_bridge,word1=self.p1,word2=self.p2)
def interact_bridge(self,word1,word2):
self.new_word = any_function_returning_value(word1,word2)
f = interact_workaround(param1 = 'try this word')
printing f.new_word will show the return of the function outside the class. Some creative messing around with kwargs and you could probably make something that implements as simply as interact.