Пример #1
0
    def _on_obj_changed(self, event):
        val_str: str = self.obj_combobox.GetValue()
        if len(val_str) == 0:
            val_str = "0"

        val_int = int(val_str.split()[0])
        try:
            if isinstance(self.entry, EntryTEnum):
                enum_type = self.entry.construct.enum_type
                new_value = enum_type(val_int)
            elif isinstance(self.entry, EntryEnum):
                new_value = self.entry.construct.decmapping[val_int]
            else:
                raise TypeError("type not supported")
        except Exception:
            new_value = val_int  # this will probably result in a building error

        metadata = get_gui_metadata(self.entry.obj)
        if metadata is not None:
            self.entry.obj = add_gui_metadata(new_value, metadata)
        else:
            self.entry.obj = new_value

        self.entry.model.ItemChanged(self.entry.dvc_item)
        if self.entry.model._on_obj_changed is not None:
            self.entry.model._on_obj_changed()
Пример #2
0
    def _on_dvc_selection_changed(self, event: wx.Event):
        """
        This method is called, if the selection in the dvc has changed.

        Then the infos of the new selected entry is shown.
        """
        dvc = event.GetEventObject()
        item = dvc.GetSelection()
        if item.ID is not None:
            entry: EntryConstruct = dvc.Model.ItemToObject(item)
            self._entry_details_viewer.set_entry(entry)

            metadata = get_gui_metadata(entry.obj)

            if metadata is None:
                start = None
                end = None
            else:
                start = metadata.offset_start
                end = metadata.offset_end

            if self._on_entry_selected is not None:
                self._on_entry_selected(start, end)

        else:
            self._entry_details_viewer.clear()
Пример #3
0
 def _get_subentry(self) -> "Optional[EntryConstruct]":
     """ Evaluate the conditional function to detect the type of the subentry """
     obj = self.obj
     if obj is None:
         return None
     else:
         metadata = get_gui_metadata(obj)
         key = evaluate(self.construct.keyfunc, metadata.context)
         if key in self._subentry_cases:
             return self._subentry_cases[key]
         else:
             return self._subentry_default
Пример #4
0
 def _get_subentry(self) -> "Optional[EntryConstruct]":
     """ Evaluate the conditional function to detect the type of the subentry """
     obj = self.obj
     if obj is None:
         return None
     else:
         metadata = get_gui_metadata(obj)
         cond = evaluate(self.construct.condfunc, metadata.context)
         if cond:
             return self._subentry_then.subentry
         else:
             return self._subentry_else.subentry
Пример #5
0
    def set_entry(self, entry: "EntryConstruct"):
        # set general infos
        self.name_txt.SetValue("->".join(entry.path))
        self.type_txt.SetValue(entry.typ_str)
        self.docs_txt.SetValue(entry.docs)

        # get metadata
        metadata = get_gui_metadata(entry.obj)
        if metadata is not None:
            self.offset_txt.SetValue(str(metadata.offset_start))
            self.length_txt.SetValue(str(metadata.length))
        else:
            self.offset_txt.SetValue("")
            self.length_txt.SetValue("")

        # set obj panel
        self._replace_obj_panel(entry)
Пример #6
0
    def _on_obj_changed(self, event):
        val_str: str = self.obj_txtctrl.GetValue()
        if len(val_str) == 0:
            val_str = "0"

        try:
            new_value = int(
                val_str,
                base=0)  # base=0 means, that eg. 0x, 0b prefixes are allowed
        except Exception:
            new_value = val_str  # this will probably result in a building error

        metadata = get_gui_metadata(self.entry.obj)
        if metadata is not None:
            self.entry.obj = add_gui_metadata(new_value, metadata)
        else:
            self.entry.obj = new_value

        self.entry.model.ItemChanged(self.entry.dvc_item)
        if self.entry.model._on_obj_changed is not None:
            self.entry.model._on_obj_changed()
Пример #7
0
    def _on_obj_changed(self, event):
        date: wx.DateTime = self.date_picker.GetValue()
        time: wx.DateTime = self.time_picker.GetValue()
        new_value = arrow.Arrow(
            year=date.year,
            month=date.month +
            1,  # in wx.adc.DatePickerCtrl the month start with 0
            day=date.day,
            hour=time.hour,
            minute=time.minute,
            second=time.second,
        )

        metadata = get_gui_metadata(self.entry.obj)
        if metadata is not None:
            self.entry.obj = add_gui_metadata(new_value, metadata)
        else:
            self.entry.obj = new_value

        self.obj_txtctrl.SetValue(self.entry.obj_str)

        self.entry.model.ItemChanged(self.entry.dvc_item)
        if self.entry.model._on_obj_changed is not None:
            self.entry.model._on_obj_changed()