Introduce basic GUI layout
This commit is contained in:
parent
7a373fae03
commit
83d0058218
95
main.py
95
main.py
@ -1,62 +1,91 @@
|
|||||||
import os
|
import os
|
||||||
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
|
|
||||||
import pygame
|
|
||||||
import pygame.freetype
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cli_ui
|
import cli_ui
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
import tkinter
|
||||||
from exporter import export
|
from exporter import export
|
||||||
|
|
||||||
##### CONFIG #####
|
##### CONFIG #####
|
||||||
|
|
||||||
# heigh of guide lines from the top of font pixel grid
|
# height of guide lines from the top of font pixel grid
|
||||||
ascender_line = 10
|
ascender_line = 10
|
||||||
descender_line = 20
|
descender_line = 20
|
||||||
|
|
||||||
|
WINDOW_SIZE = (
|
||||||
|
"1280x720",
|
||||||
window_size = (
|
"1920x1019"
|
||||||
(1280, 720),
|
|
||||||
(1920, 1019)
|
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
# this is just a hard limit additionaly limited by the refresh rate of the monitor (vsync)
|
|
||||||
fps_limit = 240
|
|
||||||
|
|
||||||
|
|
||||||
grid_color = (128,) * 3
|
grid_color = (128,) * 3
|
||||||
grid_guide_color = (128, 128, 255)
|
grid_guide_color = (128, 128, 255)
|
||||||
cross_color = (255, 60, 25)
|
cross_color = (255, 60, 25)
|
||||||
pixel_color = (255,) * 3
|
pixel_color = (255,) * 3
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
|
||||||
|
def menu_file_open_project_click():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def menu_file_save_project_click():
|
||||||
|
pass
|
||||||
|
|
||||||
proj_data, proj_path = cli_ui.cli_main()
|
def menu_file_save_project_as_click():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def number_only_validate(val):
|
||||||
|
return str.isdigit(val) or val==""
|
||||||
|
|
||||||
|
window=tkinter.Tk()
|
||||||
|
window.title("fonteditor")
|
||||||
|
window.geometry(WINDOW_SIZE)
|
||||||
|
|
||||||
|
menubar=tkinter.Menu(window)
|
||||||
|
menu_file=tkinter.Menu(menubar,tearoff=False)
|
||||||
|
menu_file.add_command(label="Open project",command=menu_file_open_project_click)
|
||||||
|
menu_file.add_command(label="Save project",command=menu_file_save_project_click)
|
||||||
|
menu_file.add_command(label="Save project as",command=menu_file_save_project_as_click)
|
||||||
|
menubar.add_cascade(label="File",menu=menu_file)
|
||||||
|
|
||||||
|
canvas_editor=tkinter.Canvas(window,bg="black")
|
||||||
|
canvas_editor.pack(side="left",fill="y")
|
||||||
|
|
||||||
|
frame_controls=tkinter.Frame(window)
|
||||||
|
frame_controls.pack()
|
||||||
|
|
||||||
|
canvas_preview=tkinter.Canvas(frame_controls,width=100,height=200,bg="black")
|
||||||
|
canvas_preview.pack(side="top")
|
||||||
|
|
||||||
|
label_glyph_name=tkinter.Label(frame_controls,text="Placeholder")
|
||||||
|
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.pack(side="left")
|
||||||
|
|
||||||
|
button_next_glyph=tkinter.Button(frame_nav,width=10,text="Next")
|
||||||
|
button_next_glyph.pack(side="left")
|
||||||
|
|
||||||
|
frame_glyph_id=tkinter.Frame(frame_controls)
|
||||||
|
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.pack(side="left")
|
||||||
|
|
||||||
|
window.config(menu=menubar)
|
||||||
|
window.mainloop()
|
||||||
|
|
||||||
|
"""proj_data, proj_path = cli_ui.cli_main()
|
||||||
chars = proj_data["chars"]
|
chars = proj_data["chars"]
|
||||||
|
|
||||||
char_res = (proj_data["char_width"], proj_data["char_height"])
|
char_res = (proj_data["char_width"], proj_data["char_height"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pygame init
|
|
||||||
pygame.init()
|
|
||||||
window = pygame.display.set_mode(window_size, flags=pygame.SCALED, vsync=1)
|
|
||||||
clock = pygame.time.Clock()
|
|
||||||
font = pygame.freetype.SysFont("Arial", 32)
|
|
||||||
alt_font = pygame.freetype.SysFont("monogramextended", 32)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pixel_size = (window_size[1]-1) / char_res[1]
|
pixel_size = (window_size[1]-1) / char_res[1]
|
||||||
canva_width = pixel_size * char_res[0]
|
canva_width = pixel_size * char_res[0]"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def cursor_pos_to_pixel(pos):
|
def cursor_pos_to_pixel(pos):
|
||||||
pixel_pos = (int(pos[0] // pixel_size), int(pos[1] // pixel_size))
|
pixel_pos = (int(pos[0] // pixel_size), int(pos[1] // pixel_size))
|
||||||
@ -290,4 +319,4 @@ while True:
|
|||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
clock.tick(fps_limit)
|
clock.tick(fps_limit)
|
||||||
#d_time = clock.tick(fps_limit) / 1000
|
#d_time = clock.tick(fps_limit) / 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user