Implement switching edited character
This commit is contained in:
parent
1870471445
commit
aba843ef1e
42
main.py
42
main.py
@ -39,6 +39,7 @@ def draw_editor_canvas():
|
|||||||
global project_char_res
|
global project_char_res
|
||||||
global canvas_width
|
global canvas_width
|
||||||
global canvas_height
|
global canvas_height
|
||||||
|
|
||||||
canvas_editor.delete("all")
|
canvas_editor.delete("all")
|
||||||
|
|
||||||
# draw grid
|
# draw grid
|
||||||
@ -96,9 +97,32 @@ def menu_file_save_project_click():
|
|||||||
def menu_file_save_project_as_click():
|
def menu_file_save_project_as_click():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def button_prev_glyph_click():
|
||||||
|
global current_char
|
||||||
|
current_char-=1
|
||||||
|
keep_char_num_in_bounds()
|
||||||
|
draw_editor_canvas()
|
||||||
|
|
||||||
|
|
||||||
|
def button_next_glyph_click():
|
||||||
|
global current_char
|
||||||
|
current_char+=1
|
||||||
|
keep_char_num_in_bounds()
|
||||||
|
draw_editor_canvas()
|
||||||
|
|
||||||
|
|
||||||
|
def keep_char_num_in_bounds():
|
||||||
|
global current_char
|
||||||
|
if current_char<0:
|
||||||
|
current_char=0
|
||||||
|
elif current_char>99999:
|
||||||
|
current_char=99999
|
||||||
|
|
||||||
|
|
||||||
def number_only_validate(val):
|
def number_only_validate(val):
|
||||||
return str.isdigit(val) or val==""
|
return str.isdigit(val) or val==""
|
||||||
|
|
||||||
|
|
||||||
window=tkinter.Tk()
|
window=tkinter.Tk()
|
||||||
window.title("fonteditor")
|
window.title("fonteditor")
|
||||||
window.geometry(f"{WINDOW_SIZE[0]}x{WINDOW_SIZE[1]}")
|
window.geometry(f"{WINDOW_SIZE[0]}x{WINDOW_SIZE[1]}")
|
||||||
@ -125,10 +149,10 @@ label_glyph_name.pack(side="top")
|
|||||||
frame_nav=tkinter.Frame(frame_controls)
|
frame_nav=tkinter.Frame(frame_controls)
|
||||||
frame_nav.pack(side="top",pady=10)
|
frame_nav.pack(side="top",pady=10)
|
||||||
|
|
||||||
button_prev_glyph=tkinter.Button(frame_nav,width=10,text="Previous")
|
button_prev_glyph=tkinter.Button(frame_nav,width=10,text="Previous",command=button_prev_glyph_click)
|
||||||
button_prev_glyph.pack(side="left")
|
button_prev_glyph.pack(side="left")
|
||||||
|
|
||||||
button_next_glyph=tkinter.Button(frame_nav,width=10,text="Next")
|
button_next_glyph=tkinter.Button(frame_nav,width=10,text="Next",command=button_next_glyph_click)
|
||||||
button_next_glyph.pack(side="left")
|
button_next_glyph.pack(side="left")
|
||||||
|
|
||||||
frame_glyph_id=tkinter.Frame(frame_controls)
|
frame_glyph_id=tkinter.Frame(frame_controls)
|
||||||
@ -156,15 +180,6 @@ def cursor_pos_to_pixel(pos):
|
|||||||
return pixel_pos
|
return pixel_pos
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#d_time = 1 / fps_limit
|
|
||||||
|
|
||||||
is_grid = True
|
|
||||||
|
|
||||||
does_char_exist = check_char_exist(char_num)
|
|
||||||
|
|
||||||
force_deleted = False
|
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
@ -175,11 +190,6 @@ while True:
|
|||||||
elif event.type == pygame.MOUSEWHEEL:
|
elif event.type == pygame.MOUSEWHEEL:
|
||||||
char_num += event.y * -1
|
char_num += event.y * -1
|
||||||
|
|
||||||
if char_num < 0:
|
|
||||||
char_num = 0
|
|
||||||
elif char_num > 99999:
|
|
||||||
char_num = 99999
|
|
||||||
|
|
||||||
does_char_exist = check_char_exist(char_num)
|
does_char_exist = check_char_exist(char_num)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user