コード例 #1
0
class Text(TextMixin, Editor):
    def __init__(self, master, style_def=None):
        super().__init__(master, style_def)
        if style_def is None:
            style_def = {}
        self.config(**self.style.dark_highlight_active)
        self._entry = Entry(self, **self.style.dark_input)
        self._entry.pack(fill="x")
        self._entry.on_entry(self._change)
        if style_def.get("readonly", False):
            self._entry.config(state='disabled')
コード例 #2
0
ファイル: editors.py プロジェクト: Shiloli-r/Formation
class Text(TextMixin, Editor):
    def __init__(self, master, style_def=None):
        super().__init__(master, style_def)
        self.config(**self.style.dark_highlight_active)
        self._entry = Entry(self, **self.style.dark_input)
        self._entry.configure(**self.style.no_highlight)
        self._entry.pack(fill="x")
        self._entry.on_entry(self._change)
        self.set_def(style_def)

    def set_def(self, definition):
        if definition.get("readonly", False):
            self._entry.config(state='disabled')
        super().set_def(definition)
コード例 #3
0
ファイル: eventspane.py プロジェクト: ObaraEmmanuel/Formation
    class EventItem(CompoundList.BaseItem):
        def __init__(self, master, value: EventBinding, index, isolated=False):
            super().__init__(master, value, index, isolated)
            self.parent_list = master

        @property
        def id(self):
            return self.value.id

        def _on_value_change(self):
            event = EventBinding(
                self.id,
                self.sequence.get(),
                self.handler.get(),
                self.add_arg.get(),
            )
            self.parent_list._item_changed(event)

        def _delete_entry(self, *_):
            self.parent_list._item_deleted(self)
            # prevent event propagation since item will be deleted
            return "break"

        def render(self):
            self.config(height=40)
            seq_frame = Frame(self, **self.style.highlight)
            seq_frame.grid(row=0, column=0, sticky="nsew")
            seq_frame.pack_propagate(False)
            self.sequence = Entry(seq_frame, **self.style.input)
            self.sequence.place(x=0, y=0, relwidth=1, relheight=1, width=-40)
            self.sequence.set(self.value.sequence)
            self.sequence.configure(**self.style.no_highlight)
            self.sequence.focus_set()
            self.handler = Entry(self, **self.style.input)
            self.handler.grid(row=0, column=1, sticky="ew")
            self.handler.set(self.value.handler)
            self.handler.config(**self.style.highlight)
            self.add_arg = Checkbutton(self, **self.style.checkbutton)
            self.add_arg.grid(row=0, column=2, sticky="ew")
            self.add_arg.set(self.value.add)
            del_btn = Label(self,
                            **self.style.button,
                            image=get_icon_image("delete", 14, 14))
            del_btn.grid(row=0, column=3, sticky='nswe')
            del_btn.bind("<Button-1>", self._delete_entry)
            # set the first two columns to expand evenly
            for column in range(2):
                self.grid_columnconfigure(column, weight=1, uniform=1)

            for widget in (self.sequence, self.handler):
                widget.on_change(self._on_value_change)

            self.add_arg._var.trace("w", lambda *_: self._on_value_change())

        def hide(self):
            self.pack_forget()

        def show(self):
            self.pack(fill="x", pady=1, side="top")

        def on_hover(self, *_):
            pass

        def on_hover_ended(self, *_):
            pass

        def update_details(self, value, index):
            self._index = index
            self._value = value
            self.sequence.set(value.sequence)
            self.handler.set(value.handler)
            self.add_arg.set(value.add)