Here the widget is allocated
(self, widget)
| 533 | self.create_instance(None) |
| 534 | |
| 535 | def create_instance(self, widget): |
| 536 | """ Here the widget is allocated |
| 537 | """ |
| 538 | self.varname_list = [] |
| 539 | self.build_widget_name_list_from_tree(self.appInstance.project) |
| 540 | self.used_keys_list = [] |
| 541 | self.build_widget_used_keys_list_from_tree(self.appInstance.project) |
| 542 | print("-------------used keys:" + str(self.used_keys_list)) |
| 543 | variableName = '' |
| 544 | for i in range(0, 1000): # reasonably no more than 1000 widget instances in a project |
| 545 | variableName = self.widgetClass.__name__.lower() + str(i) |
| 546 | if not variableName in self.varname_list and not variableName in self.used_keys_list: |
| 547 | break |
| 548 | |
| 549 | """ |
| 550 | if re.match('(^[a-zA-Z][a-zA-Z0-9_]*)|(^[_][a-zA-Z0-9_]+)', variableName) == None: |
| 551 | self.errorDialog = gui.GenericDialog("Error", "Please type a valid variable name.", width=350,height=120) |
| 552 | self.errorDialog.show(self.appInstance) |
| 553 | return |
| 554 | |
| 555 | if variableName in self.varname_list: |
| 556 | self.errorDialog = gui.GenericDialog("Error", "The typed variable name is already used. Please specify a new name.", width=350,height=150) |
| 557 | self.errorDialog.show(self.appInstance) |
| 558 | return |
| 559 | """ |
| 560 | # here we create and decorate the widget |
| 561 | widget = self.widgetClass(**self.kwargs_to_widget) |
| 562 | widget.attr_editor_newclass = False |
| 563 | widget.variable_name = variableName |
| 564 | |
| 565 | for key in self.optional_style_dict: |
| 566 | widget.style[key] = self.optional_style_dict[key] |
| 567 | self.optional_style_dict = {} |
| 568 | |
| 569 | self.appInstance.add_widget_to_editor(widget) |
| 570 | |
| 571 | |
| 572 | class WidgetCollection(gui.Container): |
no test coverage detected