예제 #1
0
 def render(self, _):
     self.detail = Label(self, **self.style.text, text=self.message)
     self.detail.pack(fill="x")
     warn_frame = Frame(self, **self.style.surface)
     self._warning = Label(
         warn_frame,
         **self.style.text_passive,
         padx=5,
         anchor='w',
         compound="left",
         image=get_tk_image("dialog_warning", 15, 15),
     )
     self.event_pad = Label(
         self, **self.style.text_accent)
     self._add_button(text="Cancel", value=None)
     self._add_button(text="Okay", command=self.exit_with_key, focus=True)
     warn_frame.pack(side="bottom", fill="x")
     self.event_pad.config(
         **self.style.bright, takefocus=True,
         text="Tap here to begin capturing shortcuts."
     )
     self.event_pad.bind("<Any-KeyPress>", self.on_key_change)
     # for some reason alt needs to be bound separately
     self.event_pad.bind("<Alt-KeyPress>", self.on_key_change)
     self.event_pad.bind("<Button-1>", lambda e: self.event_pad.focus_set())
     self.event_pad.pack(fill="both", expand=True)
예제 #2
0
 def render(self, window):
     self.minsize(700, 500)
     pane = PanedWindow(window, **self.style.surface)
     self.nav = CompoundList(pane)
     self.nav.config_all(**self.style.bright)
     self.nav.set_item_class(PreferenceManager.NavItem)
     self.pref_frame = Frame(pane, **self.style.surface)
     pane.add(self.nav, width=250, minsize=250, sticky="nswe")
     pane.add(self.pref_frame, width=450, minsize=200, sticky="nswe")
     self._make_button_bar()
     warning_bar = Frame(self.bar, **self.style.surface)
     warning_bar.pack(side="left")
     self._restart_label = Label(
         warning_bar, **self.style.text, compound="left",
         image=get_tk_image("dialog_info", 20, 20),
         text="Some changes require restart"
     )
     self._restart_button = Button(
         warning_bar, **self.style.button, text="restart", height=25,
     )
     self._restart_button.configure(width=self._restart_button.measure_text("restart"))
     self._restart_button.on_click(self.apply_and_restart)
     self._restart_button.configure(**self.style.highlight_active)
     self.cancel_btn = self._add_button(text="Cancel", command=self.cancel)
     self.okay_btn = self._add_button(text="Okay", command=self.okay, focus=True)
     pane.pack(side="top", fill='both', expand=True)
예제 #3
0
 def __init__(self, master, studio, path=None):
     super(DesignContext, self).__init__(master, studio)
     self.designer = Designer(self, studio)
     self.designer.pack(fill="both", expand=True)
     self.path = path
     self.icon = get_tk_image("paint", 15, 15)
     self.name = self.name_from_path(path) if path else self._create_name()
     self._loaded = False
예제 #4
0
 def _show_empty(self, flag, **kw):
     if flag:
         kw['image'] = kw.get('image', get_tk_image('paint', 30, 30))
         kw['text'] = kw.get('text',
                             "Drag or paste a container here to start")
         self._empty.configure(**kw)
         self._empty.place(relwidth=1, relheight=1)
     else:
         self._empty.place_forget()
예제 #5
0
 def __init__(self, master, pref: SharedPreferences, path, _, **__):
     super().__init__(master)
     self.config(**self.style.dark)
     self.bindings = {}
     self.is_disabled = False
     self.load(pref, path)
     self.shortcut_list = CompoundList(self)
     self.shortcut_list.set_item_class(ShortcutPane.ShortcutItem)
     self.shortcut_list.set_values(list(self.bindings.items()))
     self.shortcut_list.pack(fill="both", expand=True)
     self.shortcut_list.body.set_up_context((
         EnableIf(
             lambda: (not self.is_disabled) and self.shortcut_list.get(),
             ("command", "Change Shortcut", get_tk_image('edit', 14, 14), self.pick_key, {}),
             EnableIf(
                 lambda: self.shortcut_list.get() and self.shortcut_list.get().value[1] != BlankKey,
                 ("command", "Remove", get_tk_image('delete', 14, 14), self.remove_key, {})
             ),
         ),
     ))
예제 #6
0
 def __init__(self, master, studio):
     super().__init__(master)
     self.id = None
     self.setup_widget()
     self.parent = self
     self.studio = studio
     self.config(**self.style.bright, takefocus=True)
     self.objects = []
     self.root_obj = None
     self.layout_strategy = DesignLayoutStrategy(self)
     self.highlight = HighLight(self)
     self.highlight.on_resize(self._on_size_changed)
     self.highlight.on_move(self._on_move)
     self.highlight.on_release(self._on_release)
     self._update_throttling()
     self.studio.pref.add_listener(
         "designer::frame_skip",
         self._update_throttling
     )
     self.current_obj = None
     self.current_container = None
     self.current_action = None
     self._frame.bind("<Button-1>", lambda *_: self.focus_set())
     self._frame.bind('<Motion>', self.on_motion, '+')
     self._padding = 30
     self.design_path = None
     self.xml = XMLForm(self)
     self._load_progress = None
     self._shortcut_mgr = KeyMap(self._frame)
     self._set_shortcuts()
     self._last_click_pos = None
     # create the dynamic menu
     self._context_menu = MenuUtils.make_dynamic(
         self.studio.menu_template +
         ToolManager.get_tool_menu(self.studio) +
         (LoadLater(lambda: self.current_obj.create_menu() if self.current_obj else ()),),
         self.studio,
         self.style
     )
     self._coord_indicator = self.studio.install_status_widget(CoordinateIndicator)
     self._empty = Label(
         self,
         image=get_tk_image("paint", 30, 30), compound="top",
         text="Drag a container here to start",
         **self.style.dark_text_passive,
     )
     self._empty.config(**self.style.bright)
     self._show_empty(True)
예제 #7
0
 def _load_design(self, path, progress=None):
     # Loading designs is elaborate so better do it on its own thread
     # Capture any errors that occur while loading
     # This helps the user single out syntax errors and other value errors
     try:
         self.design_path = path
         self.root_obj = self.builder.load(path, self)
         self.context.on_load_complete()
     except Exception as e:
         self.clear()
         self.studio.on_session_clear(self)
         accelerator = actions.get_routine("STUDIO_RELOAD").accelerator
         text = f"{str(e)}\nPress {accelerator} to reload" if accelerator else f"{str(e)} \n reload design"
         self._show_empty(True,
                          text=text,
                          image=get_tk_image("dialog_error", 50, 50))
         # MessageDialog.show_error(parent=self.studio, title='Error loading design', message=str(e))
     finally:
         if progress:
             progress.destroy()
         self._verify_version()
예제 #8
0
    def __init__(self, master, studio):
        super().__init__(master)
        self.id = None
        self.context = master
        self.studio = studio
        self.name_generator = NameGenerator(self.studio.pref)
        self.setup_widget()
        self.parent = self
        self.config(**self.style.bright, takefocus=True)
        self.objects = []
        self.root_obj = None
        self.layout_strategy = DesignLayoutStrategy(self)
        self.highlight = HighLight(self)
        self.highlight.on_resize(self._on_size_changed)
        self.highlight.on_move(self._on_move)
        self.highlight.on_release(self._on_release)
        self.highlight.on_start(self._on_start)
        self._update_throttling()
        self.studio.pref.add_listener("designer::frame_skip",
                                      self._update_throttling)
        self.current_obj = None
        self.current_container = None
        self.current_action = None
        self._displace_active = False
        self._last_displace = time.time()
        self._frame.bind("<Button-1>", lambda _: self.focus_set(), '+')
        self._frame.bind("<Button-1>", self.set_pos, '+')
        self._frame.bind('<Motion>', self.on_motion, '+')
        self._frame.bind('<KeyRelease>', self._stop_displace, '+')
        self._padding = 30
        self.design_path = None
        self.builder = DesignBuilder(self)
        self._shortcut_mgr = KeyMap(self._frame)
        self._set_shortcuts()
        self._last_click_pos = None

        self._empty = Label(
            self,
            image=get_tk_image("paint", 30, 30),
            compound="top",
            text=" ",
            **self.style.text_passive,
        )
        self._empty.config(**self.style.bright)
        self._show_empty(True)

        # create the dynamic menu
        self._context_menu = MenuUtils.make_dynamic(
            self.studio.menu_template +
            (LoadLater(self.studio.tool_manager.get_tool_menu), ) +
            (LoadLater(lambda: self.current_obj.create_menu()
                       if self.current_obj else ()), ), self.studio,
            self.style)
        design_menu = (EnableIf(
            lambda: self.studio._clipboard is not None,
            ("command", "paste", icon("clipboard", 14, 14),
             lambda: self.paste(self.studio._clipboard, paste_to=self), {})), )
        self.set_up_context(design_menu)
        self._empty.set_up_context(design_menu)
        if Designer._coord_indicator is None:
            Designer._coord_indicator = self.studio.install_status_widget(
                CoordinateIndicator)
        self._text_editor = Text(self, wrap='none')
        self._text_editor.on_change(self._text_change)
        self._text_editor.bind("<FocusOut>", self._text_hide)
        self._base_font = FontStyle()
예제 #9
0
def get_icon_image(identifier: str, width=25, height=25, **kwargs):
    return get_tk_image(identifier, width, height, **kwargs)