Example #1
0
    def __init__(self, app):
        super().__init__(app)
        self.nav = Frame(self.body, bg="#5a5a5a", height=40)
        self.nav.pack(side='top', fill='x', expand=True)
        self.body = ScrolledGridHolder(self.body,
                                       height=230,
                                       width=400,
                                       bg='#f7f7f7')
        self.body.pack(side='top')
        self.body = self.body.body
        self.body.bind('<Leave>', lambda ev: self.deactivate_grid())
        self.grids = []
        self.active_grid = None
        self.load_favourites()
        self.title("Favourites")
        self.context_menu = ContextMenu()
        self.context_menu.load_actions(
            ("\ue923", "Copy unicode", lambda: self.active_grid.copy(0)),
            ("\ue923", "Copy code point", lambda: self.active_grid.copy(2)),
            ("\ue923", "Copy hexadecimal scalar",
             lambda: self.active_grid.copy(1)), ('separator', ),
            ("\ue7a9", "Save as image", lambda: SaveAsImage(self)),
            ("\ue735", "remove from favorites", self.remove),
            ("\ue946", "unicode info", lambda: UnicodeInfo(self)))
        self.components = [components.GridTracker(self)]

        ttk.Button(self.button_holder,
                   text="Clear all",
                   command=self.clear_favourites).pack(side='left',
                                                       padx=5,
                                                       pady=5)
        ttk.Button(self.button_holder, text="Close",
                   command=self.destroy).pack(side='right', padx=5, pady=5)
Example #2
0
    def __init__(self, ):
        super().__init__()
        self.geometry('800x500')
        self.config(bg='#5a5a5a')
        self.title("Unicode viewer")
        # Icon resource is not accessible during tests so ignore the TclError raised
        try:
            self.icon = PhotoImage(file="resources/unicode_viewer.png")
            self.iconphoto(True, self.icon)
        except TclError:
            pass

        self.resizable(0, 0)
        self.nav = Frame(self, bg="#5a5a5a")
        self.nav.place(x=0, y=0, relwidth=1, relheight=0.1)
        self.body = Frame(self)
        self.body.place(rely=0.101, x=0, relwidth=1, relheight=0.9)
        self.body.bind('<Leave>', lambda ev: self.deactivate_grid())
        self.body.bind('<Button-3>',
                       lambda ev: print('context menu requested.'))
        self.context_menu = ContextMenu()
        self.context_menu.load_actions(
            ("\ue923", "Copy unicode", lambda: self.active_grid.copy(0)),
            ("\ue923", "Copy code point", lambda: self.active_grid.copy(2)),
            ("\ue923", "Copy hexadecimal scalar",
             lambda: self.active_grid.copy(1)), ('separator', ),
            ("\ue7a9", "Save as image", lambda: dialogs.SaveAsImage(self)),
            ("\ue735", "Add to favorites",
             lambda: self.toggle_from_favourites()),
            ("\ue946", "Unicode info", lambda: dialogs.UnicodeInfo(self)))
        self._size = (MAX_GRID_WIDTH, MAX_GRID_HEIGHT)
        self.grids = []
        self.grid_cluster = []
        self.init_grids()
        self.active_grid = None
        # Plugin components here. Your component has to inherit the Component class
        # Components not placed here will not be rendered or receive broadcast events
        self.components = [
            components.Swipe(self),
            components.RenderRangeControl(self),
            components.GridTracker(self),
            components.RenderSizeControl(self),
            components.FontSelector(self),
            components.FavouritesManager(self)
        ]
        self._from = 0
        self.render_thread = None
        self.render(59422)
        self.size = (10, 5)
        self.style = ttk.Style()
        self.style.configure('Horizontal.TScale', background='#5a5a5a')
Example #3
0
 def test_hovering(self):
     self.dialog.clear_favourites()
     self.app.set_favourites([(45000, 'Arial'), (45000, 'Arial black')])
     self.dialog.load_favourites()
     tracker = components.GridTracker(self.dialog)
     self.dialog.components.append(tracker)
     grid_1 = random.choice(self.dialog.grids)
     grid_1.hover(True)
     self.assertEqual(grid_1.text, tracker.text,
                      "Failed to dispatch hovered grid")
     grid_1.hover(False)
     self.dialog.deactivate_grid()
     self.assertEqual(tracker.text, "",
                      "Failed to remove no longer hovered grid")
Example #4
0
 def test_lock_mechanism(self):
     self.app.set_favourites([(45000, 'Arial'), (45000, 'Arial black')])
     self.dialog.load_favourites()
     tracker = components.GridTracker(self.dialog)
     self.dialog.components.append(tracker)
     grid_1, grid_2, *_ = self.dialog.grids
     grid_1.lock()
     self.assertEqual(self.dialog.active_grid, grid_1, "Locked failed")
     grid_2.lock()
     self.assertEqual(self.dialog.active_grid, grid_2,
                      "Unlock then lock new failed")
     grid_1.hover(True)
     self.dialog.deactivate_grid()
     self.assertEqual(tracker.text, grid_2.text,
                      "Failed to persist locked grid")
Example #5
0
 def setUp(self) -> None:
     self.app = MockApp()
     self.component = components.GridTracker(self.app)
     self.app.components.append(self.component)
     self.grid = self.app.grid_cluster[0]