2
2
import re
3
3
from tkinter import messagebox
4
4
from threading import Thread
5
- import webbrowser
6
5
from tkinter import filedialog
7
6
from typing import Literal
8
7
import uuid
12
11
from modules import filesystem
13
12
from modules .filesystem import Directory , restore_from_meipass
14
13
from modules .functions .interface .image import load as load_image , load_from_image
14
+ from modules .functions .interface .CTkHyperlink import CTkHyperlink
15
15
from modules .config import settings
16
16
from modules import mod_generator
17
17
from modules .mod_generator .get_mask import get_mask
@@ -72,7 +72,7 @@ def _destroy(self) -> None:
72
72
def _load_title (self ) -> None :
73
73
frame : ctk .CTkFrame = ctk .CTkFrame (self .container , fg_color = "transparent" )
74
74
frame .grid_columnconfigure (0 , weight = 1 )
75
- frame .grid (column = 0 , row = 0 , sticky = "nsew" , pady = (0 ,16 ))
75
+ frame .grid (column = 0 , row = 0 , sticky = "nsew" , pady = (0 ,8 ))
76
76
77
77
ctk .CTkLabel (frame , text = self .Constants .SECTION_TITLE , anchor = "w" , font = self .Fonts .title ).grid (column = 0 , row = 0 , sticky = "nsew" )
78
78
ctk .CTkLabel (frame , text = self .Constants .SECTION_DISCLAIMER , anchor = "w" , font = self .Fonts .large ).grid (column = 0 , row = 1 , sticky = "nsew" )
@@ -85,9 +85,24 @@ def _load_content(self) -> None:
85
85
container .grid_columnconfigure (0 , weight = 1 )
86
86
container .grid (column = 0 , row = 1 , sticky = "nsew" , padx = (0 ,4 ))
87
87
88
+ # Run
89
+ run_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
90
+ run_frame .grid (column = 0 , row = 0 , sticky = "nsew" , pady = (0 , 16 ))
91
+ ctk .CTkLabel (run_frame , text = "Run" , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 0 , sticky = "nw" )
92
+
93
+ run_icon : Path = (Directory .RESOURCES / "menu" / "common" / "image-run" ).with_suffix (".png" )
94
+ if not run_icon .is_file ():
95
+ restore_from_meipass (run_icon )
96
+ run_image = load_image (run_icon )
97
+
98
+ ctk .CTkButton (run_frame , text = "Generate mod" , image = run_image , command = self ._run , width = 1 , anchor = "w" , compound = ctk .LEFT ).grid (column = 0 , row = 1 , sticky = "w" )
99
+
100
+ # Progress label
101
+ ctk .CTkLabel (run_frame , textvariable = self .progress_variable , anchor = "w" , font = self .Fonts .bold ).grid (column = 1 , row = 1 , sticky = "w" , padx = (4 , 0 ))
102
+
88
103
# name input
89
104
name_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
90
- name_frame .grid (column = 0 , row = 0 , sticky = "nsew" )
105
+ name_frame .grid (column = 0 , row = 1 , sticky = "nsew" )
91
106
ctk .CTkLabel (name_frame , text = "Mod name" , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 0 , sticky = "nw" )
92
107
self .mod_name_entry = ctk .CTkEntry (
93
108
name_frame , width = 256 , height = 40 , validate = "key" ,
@@ -97,7 +112,7 @@ def _load_content(self) -> None:
97
112
98
113
# color/angle inputs
99
114
color_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
100
- color_frame .grid (column = 0 , row = 1 , sticky = "nsew" , pady = (16 , 0 ))
115
+ color_frame .grid (column = 0 , row = 2 , sticky = "nsew" , pady = (16 , 0 ))
101
116
102
117
color1_frame : ctk .CTkFrame = ctk .CTkFrame (color_frame , fg_color = "transparent" )
103
118
color1_frame .grid (column = 0 , row = 1 )
@@ -129,21 +144,18 @@ def _load_content(self) -> None:
129
144
self .angle_entry .bind ("<Control-s>" , lambda _ : self .root .focus ())
130
145
self .angle_entry .bind ("<FocusOut>" , lambda _ : self ._generate_preview ())
131
146
147
+ # Possible colors
132
148
possible_colors_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
133
- possible_colors_frame .grid (column = 0 , row = 2 , sticky = "w" , pady = (4 , 0 ))
149
+ possible_colors_frame .grid (column = 0 , row = 3 , sticky = "w" , pady = (4 , 0 ))
134
150
ctk .CTkLabel (possible_colors_frame , text = "A list of available color formats can be found at " ).grid (column = 0 , row = 0 )
135
151
url : str = r"https://pillow.readthedocs.io/en/stable/reference/ImageColor.html#color-names"
136
- unhover_color : str | tuple [str ,str ] = ("#0000EE" , "#2fa8ff" )
137
- hover_color : str | tuple [str ,str ] = ("#0000CC" , "#58bbff" )
138
- hyperlink : ctk .CTkLabel = ctk .CTkLabel (possible_colors_frame , text = url , cursor = "hand2" , text_color = unhover_color )
139
- hyperlink .bind ("<Button-1>" , lambda _ : self ._open_in_browser (url ))
152
+
153
+ hyperlink : CTkHyperlink = CTkHyperlink (possible_colors_frame , url )
140
154
hyperlink .grid (column = 1 , row = 0 )
141
- hyperlink .bind ("<Enter>" , lambda _ : hyperlink .configure (text_color = hover_color ))
142
- hyperlink .bind ("<Leave>" , lambda _ : hyperlink .configure (text_color = unhover_color ))
143
155
144
- # Preview
156
+ # Color Preview
145
157
preview_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
146
- preview_frame .grid (column = 0 , row = 3 , sticky = "nsew" , pady = (16 , 0 ))
158
+ preview_frame .grid (column = 0 , row = 4 , sticky = "nsew" , pady = (12 , 0 ))
147
159
148
160
ctk .CTkLabel (preview_frame , text = "Preview" , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 0 , sticky = "w" )
149
161
self .preview_image = ctk .CTkLabel (preview_frame , text = "" , fg_color = "#000" , width = self .Constants .PREVIEW_SIZE , height = self .Constants .PREVIEW_SIZE )
@@ -153,7 +165,7 @@ def _load_content(self) -> None:
153
165
# User selected files
154
166
user_selected_files_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
155
167
user_selected_files_frame .grid_columnconfigure (0 , weight = 1 )
156
- user_selected_files_frame .grid (column = 0 , row = 4 , pady = (16 , 0 ), sticky = "nsew" )
168
+ user_selected_files_frame .grid (column = 0 , row = 5 , pady = (16 , 0 ), sticky = "nsew" )
157
169
ctk .CTkLabel (user_selected_files_frame , text = "Additional files" , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 0 , sticky = "nw" )
158
170
ctk .CTkLabel (user_selected_files_frame , text = "Select additional files to be generated on top of the default ones. (only PNG files are supported)" , anchor = "w" ).grid (column = 0 , row = 1 , sticky = "nw" )
159
171
@@ -169,21 +181,6 @@ def _load_content(self) -> None:
169
181
self .user_selected_files_container = ctk .CTkFrame (user_selected_files_frame )
170
182
self .user_selected_files_container .grid_columnconfigure (0 , weight = 1 )
171
183
self ._load_user_selected_files ()
172
-
173
- # Run
174
- run_frame : ctk .CTkFrame = ctk .CTkFrame (container , fg_color = "transparent" )
175
- run_frame .grid (column = 0 , row = 5 , sticky = "nsew" , pady = (32 , 0 ))
176
- ctk .CTkLabel (run_frame , text = "Run" , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 0 , sticky = "nw" )
177
-
178
- run_icon : Path = (Directory .RESOURCES / "menu" / "common" / "image-run" ).with_suffix (".png" )
179
- if not run_icon .is_file ():
180
- restore_from_meipass (run_icon )
181
- run_image = load_image (run_icon )
182
-
183
- ctk .CTkButton (run_frame , text = "Generate mod" , image = run_image , command = self ._run , width = 1 , anchor = "w" , compound = ctk .LEFT ).grid (column = 0 , row = 1 , sticky = "w" )
184
-
185
- # Progress label
186
- ctk .CTkLabel (container , textvariable = self .progress_variable , anchor = "w" , font = self .Fonts .bold ).grid (column = 0 , row = 6 , sticky = "w" , pady = (4 , 0 ))
187
184
# endregion
188
185
189
186
@@ -346,10 +343,6 @@ def _load_user_selected_files(self) -> None:
346
343
self .user_selected_files_container .grid (column = 0 , row = 3 , sticky = "nsew" , pady = (8 , 0 ))
347
344
348
345
349
- def _open_in_browser (self , url : str ) -> None :
350
- webbrowser .open_new_tab (url )
351
-
352
-
353
346
def _generate_preview (self , default : bool = False ) -> None :
354
347
if default :
355
348
self .default_image : Image .Image = get_mask (ImageColor .getcolor ("black" , "RGBA" ), None , 0 , size = (self .Constants .PREVIEW_SIZE , self .Constants .PREVIEW_SIZE ))
0 commit comments