I am trying out the new M3 Theme v1.2.1 (Beta) and ran into some errors with m3.TextBox and m3.TextArea using code rather than the drag and drop designer. The designer works well…
Using m3.TextBox() gives: TypeError: ‘module’ object is not callable
I believe the problem is in line 23 of material-3-theme/client_code/components/__init__.py at master · anvil-works/material-3-theme · GitHub which is:
from …_Components.TextInput import TextArea, TextBox
where TextArea and TextBox are modules that hold their respective TextArea and TextBox classes. I think this line should be:
from …_Components.TextInput import TextArea.TextArea, TextBox.TextBox
but of course I could be wrong…
What did work as a temporary work-around is:
from ._anvil_designer import Form1Template
from m3._Components.TextInput.TextBox import TextBox
from m3._Components.TextInput.TextArea import TextArea
import m3.components as m3
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# tb1 = m3.TextBox(appearance='outlined', label='Name') gives TypeError
tb1 = TextBox(appearance='outlined', label='Name')
self.column_panel_1.add_component(tb1)
# ta1 = m3.TextArea(appearance='outlined', label='Street address') gives TypeError
ta1 = TextArea(appearance='outlined', label='Street address')
self.column_panel_1.add_component(ta1)
button = m3.Button(appearance='elevated', text='Submit')
self.column_panel_1.add_component(button)
So this is not really a question, but perhaps it will help others using m3 in code until a fix is made. I am really impressed with this new module!