Implement glyph search
This commit is contained in:
parent
43ea03b175
commit
2b9505b7b3
@ -87,6 +87,7 @@ class EditorCanvas(tkinter.Canvas):
|
|||||||
if not self.project.does_char_exist(self.current_char):
|
if not self.project.does_char_exist(self.current_char):
|
||||||
for x in range(len(self.current_char_pixels)):
|
for x in range(len(self.current_char_pixels)):
|
||||||
self.current_char_pixels[x]=0
|
self.current_char_pixels[x]=0
|
||||||
|
self.draw()
|
||||||
return
|
return
|
||||||
base64_data=self.project.chars[chr(self.current_char)]
|
base64_data=self.project.chars[chr(self.current_char)]
|
||||||
pixels=base64.b64decode(base64_data.encode("ascii"))
|
pixels=base64.b64decode(base64_data.encode("ascii"))
|
||||||
|
25
main.py
25
main.py
@ -88,8 +88,29 @@ def button_next_glyph_click():
|
|||||||
update_glyph_preview()
|
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):
|
def number_only_validate(val):
|
||||||
return str.isdigit(val) or val==""
|
for x in val:
|
||||||
|
if not x.isdigit() and (ord(x)<ord("a") or ord(x)>ord("f")) and (ord(x)<ord("A") or ord(x)>ord("F")):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def update_glyph_preview():
|
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=tkinter.Entry(frame_glyph_id,validate="all",validatecommand=((window.register(number_only_validate)),"%P"))
|
||||||
entry_glyph_id.pack(side="left")
|
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")
|
button_glyph_search.pack(side="left")
|
||||||
|
|
||||||
window.config(menu=menubar)
|
window.config(menu=menubar)
|
||||||
|
Loading…
Reference in New Issue
Block a user