Esempio n. 1
0
 def add_var(self, var_type, **kw):
     var = var_type(self.studio)
     item_count = len(
         list(filter(lambda x: x.var_type == var_type, self.variables))) + 1
     name = kw.get('name', f"{var_type.__name__}_{item_count}")
     value = kw.get('value')
     item = VariableItem(self._variable_pane.body, var, name)
     item.bind("<Button-1>", lambda e: self.select(item))
     if value is not None:
         item.set(value)
     VariableManager.add(item)
     self._show(item)
     self._show_overlay(False)
     self.select(item)
Esempio n. 2
0
 def set_up(self):
     VariableManager.editors.append(self)
     values = [i.var for i in VariableManager.variables()]
     self._spinner.set_item_class(Variable.VariableChoiceItem)
     self._spinner.set_values((
         '', *values,
     ))
Esempio n. 3
0
 def set_up(self):
     # filter to obtain only string variables
     VariableManager.editors.append(self)
     values = [i.var for i in VariableManager.variables() if i.var.__class__ == StringVar]
     self._spinner.set_item_class(Variable.VariableChoiceItem)
     self._spinner.set_values((
         '', *values,
     ))
Esempio n. 4
0
 def set(menu, index, value, prop):
     if isinstance(value, tk.Variable):
         menu.entryconfigure(index, **{prop: value})
     else:
         variable = VariableManager.lookup(value)
         if isinstance(variable, VariableItem):
             menu.entryconfigure(index, **{prop: variable.var})
         else:
             logging.debug(f'variable {value} not found')
Esempio n. 5
0
 def set(widget, value, prop):
     if hasattr(value, 'handle'):
         setattr(widget, f"__{prop}", value.handle.name)
     else:
         setattr(widget, f"__{prop}", value)
     if isinstance(value, str):
         var = list(
             filter(lambda x: x.name == value, VariableManager.variables()))
         if var:
             value = var[0].var
     widget.config(**{prop: value})
Esempio n. 6
0
 def destroy(self):
     VariableManager.remove_editor(self)
     super().destroy()
Esempio n. 7
0
 def get(menu, index, prop):
     return str(VariableManager.lookup(menu.entrycget(index, prop)))
Esempio n. 8
0
 def on_context_switch(self):
     VariableManager.set_context(self.studio.context)
     self.refresh()
Esempio n. 9
0
 def variables(self):
     return VariableManager.variables()
Esempio n. 10
0
 def delete_var(self, var):
     self._hide(var)
     VariableManager.remove(var)
Esempio n. 11
0
 def _variables_to_tree(self, parent):
     variables = VariableManager.variables(self.designer.context)
     for var_item in variables:
         VariableStudioAdapter.generate(var_item, parent)
Esempio n. 12
0
 def on_var_context_change(self):
     values = [i.var for i in VariableManager.variables() if i.var.__class__ == StringVar]
     self._spinner.set_values((
         '', *values,
     ))
Esempio n. 13
0
 def on_var_context_change(self):
     values = [i.var for i in VariableManager.variables()]
     self._spinner.set_values((
         '', *values,
     ))
Esempio n. 14
0
 def set(self, value):
     # Override default conversion of value to string by Choice class
     var = list(filter(lambda x: x.name == value, VariableManager.variables()))
     # if variable does not match anything in the variable manager presume as empty
     value = var[0].var if var else ''
     self._spinner.set(value)