def __init__(self, editor: BaseEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._entry_id = None self._entry_text = None self._active = False bg_color = self._get_color() self.row_box = editor.Frame( width=self.ENTRY_ID_WIDTH + self.ENTRY_TEXT_WIDTH, height=self.ENTRY_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=2 if self.SHOW_ENTRY_ID else 1, sticky="nsew", ) bind_events(self.row_box, main_bindings) if self.SHOW_ENTRY_ID: self.id_box = editor.Frame(row=row_index, column=0, bg=bg_color, sticky="ew") self.id_label = editor.Label( self.id_box, text="", width=self.ENTRY_ID_WIDTH, bg=bg_color, fg=self.ENTRY_ID_FG, font_size=11, sticky="e", ) if self.EDIT_ENTRY_ID: id_bindings = main_bindings.copy() id_bindings[ "<Button-1>"] = lambda _, i=row_index: self.master.select_entry_row_index( i, id_clicked=True) else: id_bindings = main_bindings bind_events(self.id_box, id_bindings) bind_events(self.id_label, id_bindings) else: self.id_label = None self.text_box = editor.Frame(row=row_index, column=1 if self.SHOW_ENTRY_ID else 0, bg=bg_color, sticky="ew") bind_events(self.text_box, main_bindings) self.text_label = editor.Label( self.text_box, text="", bg=bg_color, fg=self.ENTRY_TEXT_FG, anchor="w", font_size=11, justify="left", width=self.ENTRY_TEXT_WIDTH, ) bind_events(self.text_label, main_bindings) self.context_menu = editor.Menu(self.row_box) self.tool_tip = ToolTip(self.row_box, self.id_box, self.id_label, self.text_box, self.text_label, text=None, wraplength=350)
def __init__(self, editor: SoulstructBaseFieldEditor, row_index: int, main_bindings: dict = None): self.master = editor self.STYLE_DEFAULTS = editor.STYLE_DEFAULTS self.row_index = row_index self._active = False self._link_missing = False self._default_value = False self.field_name = "" self.field_type = type # type: tp.Union[tp.Type[GameObject], tp.Type[GameObjectSequence], type, tp.Iterable] self.field_nickname = "" self.field_docstring = "" self.field_links = [] self.link_missing = False bg_color = self._get_color() self.row_box = editor.Frame( width=editor.FIELD_BOX_WIDTH, height=editor.FIELD_ROW_HEIGHT, bg=bg_color, row=row_index, columnspan=2, sticky="nsew", ) bind_events(self.row_box, main_bindings) self.field_name_box = editor.Frame(row=row_index, column=0, bg=bg_color, sticky="w") bind_events(self.field_name_box, main_bindings) self.field_name_label = editor.Label( self.field_name_box, text="", fg=editor.FIELD_NAME_FG, width=editor.FIELD_NAME_WIDTH, bg=bg_color, anchor="w", font_size=10, ) bind_events(self.field_name_label, main_bindings) self.value_box = editor.Frame( width=editor.FIELD_VALUE_BOX_WIDTH, row=row_index, column=1, bg=bg_color, sticky="ew" ) bind_events(self.value_box, main_bindings) # VALUE WIDGETS self.value_label = editor.Label( self.value_box, text="", bg=bg_color, width=editor.FIELD_VALUE_WIDTH, anchor="w" ) bind_events(self.value_label, main_bindings) self.value_checkbutton = editor.Checkbutton( self.value_box, label=None, bg=bg_color, no_grid=True, selectcolor="#000", command=self._checkbutton_toggle, ) # Main focus bindings are not bound to Checkbutton. self.value_combobox = editor.Combobox( self.value_box, values=None, width=editor.FIELD_VALUE_WIDTH, no_grid=True, font=("Segoe UI", 10), on_select_function=self._combobox_choice, ) self.value_combobox.bind("<MouseWheel>", lambda _: "break") # prevent scrolling on collapsed Combobox # Main focus bindings are not bound to Combobox. # TODO: BEHAVIOR_REF_TYPE combobox should also force a refresh, as it may change field names. # (Class will need access to ParamEntry for this, which is fine.) self.context_menu = editor.Menu(self.row_box) self.tool_tip = ToolTip(self.row_box, self.field_name_box, self.field_name_label, text=None) self.active_value_widget = self.value_label self.hide()