2222import sys
2323import tkinter as tk
2424from pathlib import Path
25+ from pprint import pprint
2526
2627import customtkinter
2728
28- from vuegen .__main__ import main
29+ # from vuegen.__main__ import main
2930from vuegen .report import ReportType
3031
3132customtkinter .set_appearance_mode ("system" )
3233customtkinter .set_default_color_theme ("dark-blue" )
34+ from tkinter import filedialog
35+
36+ from vuegen import report_generator
37+ from vuegen .utils import print_completion_message
3338
3439app_path = Path (__file__ ).absolute ()
3540print ("app_path:" , app_path )
5661
5762##########################################################################################
5863# callbacks
64+ # def create_run_vuegen(is_dir, config_path, report_type, run_streamlit):
65+ # def inner():
66+ # args = ["vuegen"]
67+ # print(f"{is_dir.get() = }")
68+ # if is_dir.get():
69+ # args.append("--directory")
70+ # else:
71+ # args.append("--config")
72+ # args.append(config_path.get())
73+ # args.append("--report_type")
74+ # args.append(report_type.get())
75+ # print(f"{run_streamlit.get() = }")
76+ # if run_streamlit.get():
77+ # args.append("--streamlit_autorun")
78+ # print("args:", args)
79+ # sys.argv = args
80+ # main() # Call the main function from vuegen
81+
82+ # return inner
83+
84+
5985def create_run_vuegen (is_dir , config_path , report_type , run_streamlit ):
6086 def inner ():
61- args = [ "vuegen" ]
87+ kwargs = {}
6288 print (f"{ is_dir .get () = } " )
6389 if is_dir .get ():
64- args . append ( "--directory" )
90+ kwargs [ "dir_path" ] = config_path . get ( )
6591 else :
66- args .append ("--config" )
67- args .append (config_path .get ())
68- args .append ("--report_type" )
69- args .append (report_type .get ())
92+ kwargs ["config_path" ] = config_path .get ()
93+ kwargs ["report_type" ] = report_type .get ()
7094 print (f"{ run_streamlit .get () = } " )
71- if run_streamlit .get ():
72- args . append ( "--streamlit_autorun " )
73- print ( "args:" , args )
74- sys . argv = args
75- main () # Call the main function from vuegen
95+ kwargs [ "streamlit_autorun" ] = run_streamlit .get ()
96+ print ( "kwargs: " )
97+ pprint ( kwargs )
98+ report_generator . get_report ( ** kwargs )
99+ print_completion_message ( report_type . get ())
76100
77101 return inner
78102
@@ -89,10 +113,18 @@ def radio_button_callback():
89113 return radio_button_callback
90114
91115
116+ def create_select_directory (string_var ):
117+ def select_directory ():
118+ directory = filedialog .askdirectory ()
119+ string_var .set (directory )
120+
121+ return select_directory
122+
123+
92124##########################################################################################
93125# APP
94126app = customtkinter .CTk ()
95- app .geometry ("460x400 " )
127+ app .geometry ("600x400 " )
96128app .title ("VueGen GUI" )
97129
98130##########################################################################################
@@ -127,7 +159,12 @@ def radio_button_callback():
127159 width = 400 ,
128160 textvariable = config_path ,
129161)
130- config_path_entry .grid (row = 2 , column = 0 , columnspan = 2 , padx = 20 , pady = 10 )
162+ config_path_entry .grid (row = 2 , column = 0 , columnspan = 2 , padx = 5 , pady = 10 )
163+ select_directory = create_select_directory (config_path )
164+ select_button = customtkinter .CTkButton (
165+ app , text = "Select Directory" , command = select_directory
166+ )
167+ select_button .grid (row = 2 , column = 2 , columnspan = 2 , padx = 5 , pady = 10 )
131168
132169##########################################################################################
133170# Report type dropdown
0 commit comments