diff --git a/canvas.py b/canvas.py index 53ea01d..425c687 100644 --- a/canvas.py +++ b/canvas.py @@ -87,6 +87,7 @@ class EditorCanvas(tkinter.Canvas): if not self.project.does_char_exist(self.current_char): for x in range(len(self.current_char_pixels)): self.current_char_pixels[x]=0 + self.draw() return base64_data=self.project.chars[chr(self.current_char)] pixels=base64.b64decode(base64_data.encode("ascii")) diff --git a/main.py b/main.py index 98e3ccc..b889ea5 100644 --- a/main.py +++ b/main.py @@ -88,8 +88,29 @@ def button_next_glyph_click(): update_glyph_preview() +def button_glyph_search_click(): + global canvas_editor + global entry_glyph_id + global project + if not project.loaded: + return + code=entry_glyph_id.get() + canvas_editor.save_char() + try: + canvas_editor.current_char=int(code,base=16) + except ValueError as e: + tkinter.messagebox.showerror("Searching glyph", f"Invalid hex value {code}: {e}") + finally: + canvas_editor.keep_current_char_in_bounds() + canvas_editor.load_char() + update_glyph_preview() + + def number_only_validate(val): - return str.isdigit(val) or val=="" + for x in val: + if not x.isdigit() and (ord(x)ord("f")) and (ord(x)ord("F")): + return False + return True def update_glyph_preview(): @@ -140,7 +161,7 @@ frame_glyph_id.pack(side="top",pady=10) entry_glyph_id=tkinter.Entry(frame_glyph_id,validate="all",validatecommand=((window.register(number_only_validate)),"%P")) entry_glyph_id.pack(side="left") -button_glyph_search=tkinter.Button(frame_glyph_id,width=10,text="Search") +button_glyph_search=tkinter.Button(frame_glyph_id,width=10,text="Search",command=button_glyph_search_click) button_glyph_search.pack(side="left") window.config(menu=menubar)