diff --git a/main.py b/main.py index 25e3ea8..c018944 100644 --- a/main.py +++ b/main.py @@ -39,6 +39,7 @@ def draw_editor_canvas(): global project_char_res global canvas_width global canvas_height + canvas_editor.delete("all") # draw grid @@ -96,9 +97,32 @@ def menu_file_save_project_click(): def menu_file_save_project_as_click(): 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): return str.isdigit(val) or val=="" + window=tkinter.Tk() window.title("fonteditor") 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.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_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") frame_glyph_id=tkinter.Frame(frame_controls) @@ -156,15 +180,6 @@ def cursor_pos_to_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 while True: for event in pygame.event.get(): @@ -175,11 +190,6 @@ while True: elif event.type == pygame.MOUSEWHEEL: 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)