Select Git revision
config_ui.py
config_ui.py 3.29 KiB
import dearpygui.dearpygui as dpg
from utils import combo_menu
from style_constants import *
from style import apply_theme, get_accent_color
from config_callbacks import *
def construct_main_window_ui():
with dpg.window(label='config file editor', tag='main', user_data={'config': None, 'config_file_path': None}):
with dpg.menu_bar():
with dpg.menu(label='config'):
dpg.add_menu_item(label='open\t\t', shortcut='ctrl+o', callback=open_config_open_dialog_clb, tag='open_config_open_dialog')
dpg.add_menu_item(label='search\t\t', shortcut='ctrl+f', callback=show_config_search_window_clb, tag='show_config_search_window')
dpg.add_menu_item(label='save\t\t', shortcut='ctrl+s', callback=config_save_clb, tag='save_config')
dpg.add_menu_item(label='save as\t\t', shortcut='ctrl+shift+s', callback=open_config_save_as_dialog_clb, tag='open_config_save_as_dialog')
dpg.add_menu_item(label='map', callback=show_map_window_clb)
dpg.add_menu_item(label='run', callback=lambda: dpg.show_item('run_window'))
with dpg.menu(label='view'):
with dpg.menu(label='ui', tag='ui'):
for ui in UIS:
dpg.add_menu_item(label=ui, check=True, default_value=False, callback=combo_menu(construct_config_ui_clb), tag=ui)
dpg.set_value(UIS[1], True)
with dpg.menu(label='theme', tag='theme'):
for theme in THEMES:
dpg.add_menu_item(label=theme, check=True, default_value=False, callback=combo_menu(apply_theme_clb), tag=theme)
dpg.set_value('orange', True)
def construct_config_open_dialog():
with dpg.file_dialog(directory_selector=False, modal=True, show=False, callback=config_open_clb, tag='config_open', width=600, height=600):
dpg.add_file_extension('.txt', color=(0, 255, 0, 255))
dpg.add_file_extension('.*', color=(255, 255, 255, 255))
def construct_config_save_as_dialog():
with dpg.file_dialog(directory_selector=False, modal=True, show=False, callback=config_save_as_clb, tag='config_save_as', width=600, height=400):
dpg.add_file_extension('.txt', color=(0, 255, 0, 255))
dpg.add_file_extension('.*', color=(255, 255, 255, 255))
def construct_set_file_path_dialog():
with dpg.file_dialog(directory_selector=True, modal=True, show=False, callback=set_file_path_clb, tag='set_folder_dialog', width=500, height=400):
dpg.add_file_extension('.*', color=(255, 255, 255, 255))
def construct_message_window():
with dpg.window(label='', no_collapse=True, autosize=True, no_resize=True, modal=True, tag='message_window', show=False, pos=(dpg.get_viewport_width() / 3, dpg.get_viewport_height() / 3)):
dpg.add_text('file saved successfully:)', tag='message')
def construct_search_window():
with dpg.window(label='', no_collapse=True, autosize=True, no_resize=True, tag='search_popup', show=False, pos=(40, 40)):
dpg.add_input_text(hint='search for...', on_enter=True, callback=search_clb, tag='search')
def construct_ui():
construct_main_window_ui()
construct_message_window()
construct_config_save_as_dialog()
construct_config_open_dialog()
construct_search_window()
construct_set_file_path_dialog()