factory.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import re
  12. import typing as t
  13. from datetime import datetime
  14. from ..types import PropertyType
  15. from .builder import _Builder
  16. if t.TYPE_CHECKING:
  17. from ..extension.library import ElementLibrary
  18. from ..gui import Gui
  19. class _Factory:
  20. DEFAULT_CONTROL = "text"
  21. _START_SUFFIX = ".start"
  22. _END_SUFFIX = ".end"
  23. __TAIPY_NAME_SPACE = "taipy."
  24. __CONTROL_DEFAULT_PROP_NAME = {
  25. "button": "label",
  26. "chart": "data",
  27. "content": "value",
  28. "date": "date",
  29. "date_range": "dates",
  30. "dialog": "open",
  31. "expandable": "title",
  32. "file_download": "content",
  33. "file_selector": "content",
  34. "image": "content",
  35. "indicator": "display",
  36. "input": "value",
  37. "layout": "columns",
  38. "login": "title",
  39. "menu": "lov",
  40. "navbar": "value",
  41. "number": "value",
  42. "pane": "open",
  43. "part": "class_name",
  44. "selector": "value",
  45. "slider": "value",
  46. "status": "value",
  47. "table": "data",
  48. "text": "value",
  49. "toggle": "value",
  50. "tree": "value",
  51. }
  52. _TEXT_ATTRIBUTES = ["format", "id", "hover_text", "raw"]
  53. __TEXT_ANCHORS = ["bottom", "top", "left", "right"]
  54. __TEXT_ANCHOR_NONE = "none"
  55. __LIBRARIES: t.Dict[str, t.List["ElementLibrary"]] = {}
  56. __CONTROL_BUILDERS = {
  57. "button": lambda gui, control_type, attrs: _Builder(
  58. gui=gui,
  59. control_type=control_type,
  60. element_name="Button",
  61. attributes=attrs,
  62. )
  63. .set_value_and_default(with_update=False)
  64. .set_attributes(
  65. [
  66. ("id",),
  67. ("on_action", PropertyType.function),
  68. ("active", PropertyType.dynamic_boolean, True),
  69. ("hover_text", PropertyType.dynamic_string),
  70. ]
  71. ),
  72. "chart": lambda gui, control_type, attrs: _Builder(
  73. gui=gui, control_type=control_type, element_name="Chart", attributes=attrs, default_value=None
  74. )
  75. .set_value_and_default(with_default=False, var_type=PropertyType.data)
  76. .set_attributes(
  77. [
  78. ("id",),
  79. ("title",),
  80. ("width", PropertyType.string_or_number),
  81. ("height", PropertyType.string_or_number),
  82. ("layout", PropertyType.dynamic_dict),
  83. ("plot_config", PropertyType.dict),
  84. ("on_range_change", PropertyType.function),
  85. ("active", PropertyType.dynamic_boolean, True),
  86. ("render", PropertyType.dynamic_boolean, True),
  87. ("hover_text", PropertyType.dynamic_string),
  88. ("on_change", PropertyType.function),
  89. ("template", PropertyType.dict),
  90. ("template[dark]", PropertyType.dict, gui._get_config("chart_dark_template", None)),
  91. ("template[light]", PropertyType.dict),
  92. ("figure", PropertyType.to_json),
  93. ]
  94. )
  95. ._get_chart_config("scatter", "lines+markers")
  96. ._set_propagate(),
  97. "content": lambda gui, control_type, attrs: _Builder(
  98. gui=gui, control_type=control_type, element_name="PageContent", attributes=attrs
  99. ),
  100. "date": lambda gui, control_type, attrs: _Builder(
  101. gui=gui,
  102. control_type=control_type,
  103. element_name="DateSelector",
  104. attributes=attrs,
  105. default_value=datetime.fromtimestamp(0),
  106. )
  107. .set_value_and_default(var_type=PropertyType.date)
  108. .set_attributes(
  109. [
  110. ("with_time", PropertyType.boolean),
  111. ("id",),
  112. ("active", PropertyType.dynamic_boolean, True),
  113. ("editable", PropertyType.dynamic_boolean, True),
  114. ("hover_text", PropertyType.dynamic_string),
  115. ("label",),
  116. ("on_change", PropertyType.function),
  117. ("format",),
  118. ]
  119. )
  120. ._set_propagate(),
  121. "date_range": lambda gui, control_type, attrs: _Builder(
  122. gui=gui,
  123. control_type=control_type,
  124. element_name="DateRange",
  125. attributes=attrs,
  126. )
  127. .set_value_and_default(var_type=PropertyType.date_range)
  128. .set_attributes(
  129. [
  130. ("with_time", PropertyType.boolean),
  131. ("id",),
  132. ("active", PropertyType.dynamic_boolean, True),
  133. ("editable", PropertyType.dynamic_boolean, True),
  134. ("hover_text", PropertyType.dynamic_string),
  135. ("label_start",),
  136. ("label_end",),
  137. ("on_change", PropertyType.function),
  138. ("format",),
  139. ]
  140. )
  141. ._set_propagate(),
  142. "dialog": lambda gui, control_type, attrs: _Builder(
  143. gui=gui,
  144. control_type=control_type,
  145. element_name="Dialog",
  146. attributes=attrs,
  147. )
  148. .set_value_and_default(var_type=PropertyType.dynamic_boolean)
  149. ._set_partial() # partial should be set before page
  150. .set_attributes(
  151. [
  152. ("id",),
  153. ("page",),
  154. ("title",),
  155. ("on_action", PropertyType.function),
  156. ("close_label", PropertyType.string),
  157. ("labels", PropertyType.string_list),
  158. ("active", PropertyType.dynamic_boolean, True),
  159. ("width", PropertyType.string_or_number),
  160. ("height", PropertyType.string_or_number),
  161. ("hover_text", PropertyType.dynamic_string),
  162. ]
  163. )
  164. ._set_propagate(),
  165. "expandable": lambda gui, control_type, attrs: _Builder(
  166. gui=gui, control_type=control_type, element_name="Expandable", attributes=attrs, default_value=None
  167. )
  168. .set_value_and_default()
  169. ._set_partial() # partial should be set before page
  170. .set_attributes(
  171. [
  172. ("id",),
  173. ("page",),
  174. ("expanded", PropertyType.dynamic_boolean, True, True, False),
  175. ("hover_text", PropertyType.dynamic_string),
  176. ("on_change", PropertyType.function),
  177. ]
  178. ),
  179. "file_download": lambda gui, control_type, attrs: _Builder(
  180. gui=gui,
  181. control_type=control_type,
  182. element_name="FileDownload",
  183. attributes=attrs,
  184. )
  185. .set_value_and_default(var_name="label", with_update=False)
  186. ._set_content("content", image=False)
  187. .set_attributes(
  188. [
  189. ("id",),
  190. ("on_action", PropertyType.function),
  191. ("active", PropertyType.dynamic_boolean, True),
  192. ("render", PropertyType.dynamic_boolean, True),
  193. ("auto", PropertyType.boolean, False),
  194. ("bypass_preview", PropertyType.boolean, True),
  195. ("name",),
  196. ("hover_text", PropertyType.dynamic_string),
  197. ]
  198. ),
  199. "file_selector": lambda gui, control_type, attrs: _Builder(
  200. gui=gui,
  201. control_type=control_type,
  202. element_name="FileSelector",
  203. attributes=attrs,
  204. )
  205. .set_value_and_default(var_name="label", with_update=False)
  206. ._set_file_content()
  207. .set_attributes(
  208. [
  209. ("id",),
  210. ("on_action", PropertyType.function),
  211. ("active", PropertyType.dynamic_boolean, True),
  212. ("multiple", PropertyType.boolean, False),
  213. ("extensions",),
  214. ("drop_message",),
  215. ("hover_text", PropertyType.dynamic_string),
  216. ("notify", PropertyType.boolean, True),
  217. ]
  218. ),
  219. "image": lambda gui, control_type, attrs: _Builder(
  220. gui=gui,
  221. control_type=control_type,
  222. element_name="Image",
  223. attributes=attrs,
  224. )
  225. .set_value_and_default(var_name="label", with_update=False)
  226. ._set_content("content")
  227. .set_attributes(
  228. [
  229. ("id",),
  230. ("on_action", PropertyType.function),
  231. ("active", PropertyType.dynamic_boolean, True),
  232. ("width",),
  233. ("height",),
  234. ("hover_text", PropertyType.dynamic_string),
  235. ]
  236. ),
  237. "indicator": lambda gui, control_type, attrs: _Builder(
  238. gui=gui,
  239. control_type=control_type,
  240. element_name="Indicator",
  241. attributes=attrs,
  242. )
  243. .set_value_and_default(with_update=False, native_type=True)
  244. .set_attributes(
  245. [
  246. ("id",),
  247. ("min", PropertyType.number),
  248. ("max", PropertyType.number),
  249. ("value", PropertyType.dynamic_number),
  250. ("format",),
  251. ("orientation"),
  252. ("hover_text", PropertyType.dynamic_string),
  253. ("width",),
  254. ("height",),
  255. ]
  256. ),
  257. "input": lambda gui, control_type, attrs: _Builder(
  258. gui=gui,
  259. control_type=control_type,
  260. element_name="Input",
  261. attributes=attrs,
  262. )
  263. ._set_input_type("text", True)
  264. .set_value_and_default()
  265. ._set_propagate()
  266. .set_attributes(
  267. [
  268. ("id",),
  269. ("active", PropertyType.dynamic_boolean, True),
  270. ("hover_text", PropertyType.dynamic_string),
  271. ("on_change", PropertyType.function),
  272. ("on_action", PropertyType.function),
  273. ("action_keys",),
  274. ("label",),
  275. ("change_delay", PropertyType.number, gui._get_config("change_delay", None)),
  276. ("multiline", PropertyType.boolean, False),
  277. ("lines_shown", PropertyType.number, 5),
  278. ]
  279. ),
  280. "layout": lambda gui, control_type, attrs: _Builder(
  281. gui=gui, control_type=control_type, element_name="Layout", attributes=attrs, default_value=None
  282. )
  283. .set_value_and_default(with_default=False)
  284. .set_attributes(
  285. [
  286. ("id",),
  287. ("columns[mobile]",),
  288. ("gap",),
  289. ]
  290. ),
  291. "login": lambda gui, control_type, attrs: _Builder(
  292. gui=gui, control_type=control_type, element_name="Login", attributes=attrs, default_value=None
  293. )
  294. .set_value_and_default(default_val="Log-in")
  295. .set_attributes(
  296. [
  297. ("id",),
  298. ("message", PropertyType.dynamic_string),
  299. ("on_action", PropertyType.function, "on_login"),
  300. ]
  301. ),
  302. "menu": lambda gui, control_type, attrs: _Builder(
  303. gui=gui,
  304. control_type=control_type,
  305. element_name="MenuCtl",
  306. attributes=attrs,
  307. )
  308. .set_attributes(
  309. [
  310. ("id",),
  311. ("active", PropertyType.dynamic_boolean, True),
  312. ("label",),
  313. ("width",),
  314. ("width[mobile]",),
  315. ("on_action", PropertyType.function),
  316. ("inactive_ids", PropertyType.dynamic_list),
  317. ("hover_text", PropertyType.dynamic_string),
  318. ("lov", PropertyType.lov),
  319. ]
  320. )
  321. ._set_propagate(),
  322. "navbar": lambda gui, control_type, attrs: _Builder(
  323. gui=gui, control_type=control_type, element_name="NavBar", attributes=attrs, default_value=None
  324. ).set_attributes(
  325. [
  326. ("id",),
  327. ("active", PropertyType.dynamic_boolean, True),
  328. ("hover_text", PropertyType.dynamic_string),
  329. ("lov", PropertyType.single_lov),
  330. ]
  331. ),
  332. "number": lambda gui, control_type, attrs: _Builder(
  333. gui=gui,
  334. control_type=control_type,
  335. element_name="Input",
  336. attributes=attrs,
  337. default_value=0,
  338. )
  339. ._set_input_type("number")
  340. .set_value_and_default(var_type=PropertyType.dynamic_number)
  341. ._set_propagate()
  342. .set_attributes(
  343. [
  344. ("id",),
  345. ("active", PropertyType.dynamic_boolean, True),
  346. ("hover_text", PropertyType.dynamic_string),
  347. ("on_change", PropertyType.function),
  348. ("on_action", PropertyType.function),
  349. ("label",),
  350. ("change_delay", PropertyType.number, gui._get_config("change_delay", None)),
  351. ]
  352. ),
  353. "pane": lambda gui, control_type, attrs: _Builder(
  354. gui=gui, control_type=control_type, element_name="Pane", attributes=attrs, default_value=None
  355. )
  356. .set_value_and_default(var_type=PropertyType.dynamic_boolean)
  357. ._set_partial() # partial should be set before page
  358. .set_attributes(
  359. [
  360. ("id",),
  361. ("page",),
  362. ("anchor", PropertyType.string, "left"),
  363. ("on_close", PropertyType.function),
  364. ("persistent", PropertyType.boolean, False),
  365. ("active", PropertyType.dynamic_boolean, True),
  366. ("width", PropertyType.string_or_number, "30vw"),
  367. ("height", PropertyType.string_or_number, "30vh"),
  368. ("hover_text", PropertyType.dynamic_string),
  369. ("on_change", PropertyType.function),
  370. ]
  371. )
  372. ._set_propagate(),
  373. "part": lambda gui, control_type, attrs: _Builder(
  374. gui=gui, control_type=control_type, element_name="Part", attributes=attrs, default_value=None
  375. )
  376. ._set_partial() # partial should be set before page
  377. .set_attributes(
  378. [
  379. ("id",),
  380. ("page", PropertyType.dynamic_string),
  381. ("render", PropertyType.dynamic_boolean, True),
  382. ("height", PropertyType.dynamic_string),
  383. ("content", PropertyType.toHtmlContent),
  384. ]
  385. ),
  386. "selector": lambda gui, control_type, attrs: _Builder(
  387. gui=gui, control_type=control_type, element_name="Selector", attributes=attrs, default_value=None
  388. )
  389. .set_value_and_default(with_default=False, var_type=PropertyType.lov_value)
  390. .set_attributes(
  391. [
  392. ("active", PropertyType.dynamic_boolean, True),
  393. ("dropdown", PropertyType.boolean, False),
  394. ("filter", PropertyType.boolean),
  395. ("height", PropertyType.string_or_number),
  396. ("hover_text", PropertyType.dynamic_string),
  397. ("id",),
  398. ("value_by_id", PropertyType.boolean),
  399. ("multiple", PropertyType.boolean),
  400. ("width", PropertyType.string_or_number),
  401. ("on_change", PropertyType.function),
  402. ("label",),
  403. ("mode",),
  404. ("lov", PropertyType.lov),
  405. ]
  406. )
  407. ._set_propagate(),
  408. "slider": lambda gui, control_type, attrs: _Builder(
  409. gui=gui,
  410. control_type=control_type,
  411. element_name="Slider",
  412. attributes=attrs,
  413. default_value=0,
  414. )
  415. .set_value_and_default(native_type=True, var_type=PropertyType.slider_value)
  416. .set_attributes(
  417. [
  418. ("active", PropertyType.dynamic_boolean, True),
  419. ("height",),
  420. ("hover_text", PropertyType.dynamic_string),
  421. ("id",),
  422. ("value_by_id", PropertyType.boolean),
  423. ("max", PropertyType.number, 100),
  424. ("min", PropertyType.number, 0),
  425. ("step", PropertyType.number, 1),
  426. ("orientation",),
  427. ("width", PropertyType.string, "300px"),
  428. ("on_change", PropertyType.function),
  429. ("continuous", PropertyType.boolean, True),
  430. ("lov", PropertyType.lov),
  431. ("change_delay", PropertyType.number, gui._get_config("change_delay", None)),
  432. ]
  433. )
  434. ._set_labels()
  435. ._set_string_with_check("text_anchor", _Factory.__TEXT_ANCHORS + [_Factory.__TEXT_ANCHOR_NONE], "bottom")
  436. ._set_propagate(),
  437. "status": lambda gui, control_type, attrs: _Builder(
  438. gui=gui,
  439. control_type=control_type,
  440. element_name="Status",
  441. attributes=attrs,
  442. )
  443. .set_value_and_default(with_update=False)
  444. .set_attributes(
  445. [
  446. ("id",),
  447. ("without_close", PropertyType.boolean, False),
  448. ("hover_text", PropertyType.dynamic_string),
  449. ]
  450. ),
  451. "table": lambda gui, control_type, attrs: _Builder(
  452. gui=gui,
  453. control_type=control_type,
  454. element_name="Table",
  455. attributes=attrs,
  456. )
  457. .set_value_and_default(with_default=False, var_type=PropertyType.data)
  458. ._get_dataframe_attributes()
  459. .set_attributes(
  460. [
  461. ("page_size", PropertyType.number, "100"),
  462. ("allow_all_rows", PropertyType.boolean),
  463. ("show_all", PropertyType.boolean),
  464. ("auto_loading", PropertyType.boolean),
  465. ("width", PropertyType.string_or_number, "100%"),
  466. ("height", PropertyType.string_or_number, "80vh"),
  467. ("id",),
  468. ("active", PropertyType.dynamic_boolean, True),
  469. ("editable", PropertyType.dynamic_boolean, True),
  470. ("on_edit", PropertyType.function),
  471. ("on_delete", PropertyType.function),
  472. ("on_add", PropertyType.function),
  473. ("on_action", PropertyType.function),
  474. ("nan_value",),
  475. ("filter", PropertyType.boolean),
  476. ("hover_text", PropertyType.dynamic_string),
  477. ("size",),
  478. ("downloadable", PropertyType.boolean),
  479. ]
  480. )
  481. ._set_propagate()
  482. ._get_list_attribute("selected", PropertyType.number)
  483. ._set_table_pagesize_options(),
  484. "text": lambda gui, control_type, attrs: _Builder(
  485. gui=gui,
  486. control_type=control_type,
  487. element_name="Field",
  488. attributes=attrs,
  489. )
  490. .set_value_and_default(with_update=False)
  491. ._set_dataType()
  492. .set_attributes(
  493. [
  494. ("format",),
  495. ("id",),
  496. ("hover_text", PropertyType.dynamic_string),
  497. ("raw", PropertyType.boolean, False),
  498. ("mode",),
  499. ]
  500. ),
  501. "toggle": lambda gui, control_type, attrs: _Builder(
  502. gui=gui, control_type=control_type, element_name="Toggle", attributes=attrs, default_value=None
  503. )
  504. .set_value_and_default(with_default=False, var_type=PropertyType.toggle_value)
  505. .set_attributes(
  506. [
  507. ("active", PropertyType.dynamic_boolean, True),
  508. ("hover_text", PropertyType.dynamic_string),
  509. ("id",),
  510. ("label",),
  511. ("value_by_id", PropertyType.boolean),
  512. ("unselected_value", PropertyType.string, ""),
  513. ("allow_unselect", PropertyType.boolean),
  514. ("on_change", PropertyType.function),
  515. ("mode",),
  516. ("lov", PropertyType.single_lov),
  517. ]
  518. )
  519. ._set_kind()
  520. ._set_propagate(),
  521. "tree": lambda gui, control_type, attrs: _Builder(
  522. gui=gui,
  523. control_type=control_type,
  524. element_name="TreeView",
  525. attributes=attrs,
  526. )
  527. .set_value_and_default(with_default=False, var_type=PropertyType.lov_value)
  528. .set_attributes(
  529. [
  530. ("active", PropertyType.dynamic_boolean, True),
  531. ("expanded", PropertyType.boolean_or_list, True),
  532. ("filter", PropertyType.boolean),
  533. ("hover_text", PropertyType.dynamic_string),
  534. ("height", PropertyType.string_or_number),
  535. ("id",),
  536. ("value_by_id", PropertyType.boolean),
  537. ("multiple", PropertyType.boolean),
  538. ("width", PropertyType.string_or_number),
  539. ("on_change", PropertyType.function),
  540. ("select_leafs_only", PropertyType.boolean),
  541. ("row_height", PropertyType.string),
  542. ("lov", PropertyType.lov),
  543. ]
  544. )
  545. ._set_propagate(),
  546. }
  547. # TODO: process \" in property value
  548. _PROPERTY_RE = re.compile(r"\s+([a-zA-Z][\.a-zA-Z_$0-9]*(?:\[(?:.*?)\])?)=\"((?:(?:(?<=\\)\")|[^\"])*)\"")
  549. __COUNTER = 0
  550. @staticmethod
  551. def set_library(library: "ElementLibrary"):
  552. from ..extension.library import Element, ElementLibrary
  553. if isinstance(library, ElementLibrary) and isinstance(library.get_name(), str) and library.get_elements():
  554. elements = library.get_elements()
  555. for name, element in elements.items():
  556. if isinstance(element, Element):
  557. element.check(name)
  558. fact_lib = _Factory.__LIBRARIES.get(library.get_name())
  559. if fact_lib is None:
  560. _Factory.__LIBRARIES.update({library.get_name(): [library]})
  561. else:
  562. fact_lib.append(library)
  563. @staticmethod
  564. def get_default_property_name(control_name: str) -> t.Optional[str]:
  565. name = (
  566. control_name[: -len(_Factory._START_SUFFIX)]
  567. if control_name.endswith(_Factory._START_SUFFIX)
  568. else control_name[: -len(_Factory._END_SUFFIX)]
  569. if control_name.endswith(_Factory._END_SUFFIX)
  570. else control_name
  571. )
  572. name = name[len(_Factory.__TAIPY_NAME_SPACE) :] if name.startswith(_Factory.__TAIPY_NAME_SPACE) else name
  573. prop = _Factory.__CONTROL_DEFAULT_PROP_NAME.get(name)
  574. if prop is None:
  575. _, _, element = _Factory.__get_library_element(name)
  576. if element:
  577. prop = element.default_attribute
  578. return prop
  579. @staticmethod
  580. def __get_library_element(name: str):
  581. parts = name.split(".")
  582. if len(parts) > 1:
  583. element_name = ".".join(parts[1:])
  584. for lib in _Factory.__LIBRARIES.get(parts[0], []):
  585. elts = lib.get_elements()
  586. if isinstance(elts, dict):
  587. if element := elts.get(element_name):
  588. return lib, element_name, element
  589. else:
  590. element_name = name
  591. for libs in list(_Factory.__LIBRARIES.values()):
  592. for lib in libs:
  593. elts = lib.get_elements()
  594. if isinstance(elts, dict):
  595. if element := elts.get(element_name):
  596. return lib, element_name, element
  597. return None, None, None
  598. @staticmethod
  599. def call_builder(
  600. gui: "Gui", name: str, all_properties: t.Optional[t.Dict[str, t.Any]] = None, is_html: t.Optional[bool] = False
  601. ) -> t.Optional[t.Union[t.Any, t.Tuple[str, str]]]:
  602. name = name[len(_Factory.__TAIPY_NAME_SPACE) :] if name.startswith(_Factory.__TAIPY_NAME_SPACE) else name
  603. builder = _Factory.__CONTROL_BUILDERS.get(name)
  604. built = None
  605. _Factory.__COUNTER += 1
  606. with gui._get_autorization():
  607. if builder is None:
  608. lib, element_name, element = _Factory.__get_library_element(name)
  609. if lib:
  610. from ..extension.library import Element
  611. if isinstance(element, Element):
  612. return element._call_builder(
  613. element_name, gui, all_properties, lib, is_html, counter=_Factory.__COUNTER
  614. )
  615. else:
  616. built = builder(gui, name, all_properties)
  617. if isinstance(built, _Builder):
  618. return built._build_to_string() if is_html else built.el
  619. return None