88from textual .widgets import (Button , Input , ListItem , ListView , Select , Static ,
99 TextArea )
1010
11+ from .strings import (BUTTON_ADD , BUTTON_ADD_ALIAS , BUTTON_ADD_SOCIAL ,
12+ BUTTON_BACK , BUTTON_DELETE , BUTTON_QUIT , BUTTON_SAVE ,
13+ FORM_HEADER , LIST_TITLE , MESSAGE_EXIT , MESSAGE_QUIT ,
14+ PLACEHOLDER_ALIAS , PLACEHOLDER_CITY , PLACEHOLDER_EMAIL ,
15+ PLACEHOLDER_HOMEPAGE , PLACEHOLDER_NAME ,
16+ PLACEHOLDER_SOCIAL_URL , SECTION_ALIASES , SECTION_AVAIL ,
17+ SECTION_CONTRIB , SECTION_PYTHON , SECTION_SOCIAL ,
18+ SECTION_WHO )
1119from .utils import (build_md_content , create_pr , fork_repo , get_repo ,
1220 load_file_into_form )
1321
@@ -38,12 +46,12 @@ def compose(self) -> ComposeResult:
3846
3947 def on_mount (self ) -> None :
4048 # 1) Build the list portion
41- self .list_title = Static ("Archivos en 'blog/members':" )
49+ self .list_title = Static (LIST_TITLE )
4250 self .list_view = ListView ()
43- self .quit_list_button = Button ("Salir" , id = "quit_list" )
51+ self .quit_list_button = Button (BUTTON_QUIT , id = "quit_list" )
4452
4553 self .list_container .mount (self .list_title )
46- self .add_list_button = Button ("Añadir" , id = "add_list" )
54+ self .add_list_button = Button (BUTTON_ADD , id = "add_list" )
4755 self .list_container .mount (self .list_view )
4856 self .list_container .mount (self .add_list_button )
4957 self .list_container .mount (self .quit_list_button )
@@ -56,11 +64,11 @@ def on_mount(self) -> None:
5664 self .list_view .append (ListItem (Static (basename )))
5765
5866 # 2) Build the form portion, hidden at first
59- self .form_header = Static ("Formulario de Miembro" , classes = "header" )
60- self .name_input = Input (placeholder = "Nombre" )
61- self .email_input = Input (placeholder = "Correo electrónico" )
62- self .city_input = Input (placeholder = "Ciudad" )
63- self .homepage_input = Input (placeholder = "Página personal" )
67+ self .form_header = Static (FORM_HEADER , classes = "header" )
68+ self .name_input = Input (placeholder = PLACEHOLDER_NAME )
69+ self .email_input = Input (placeholder = PLACEHOLDER_EMAIL )
70+ self .city_input = Input (placeholder = PLACEHOLDER_CITY )
71+ self .homepage_input = Input (placeholder = PLACEHOLDER_HOMEPAGE )
6472
6573 self .who_area = TextArea ()
6674 self .python_area = TextArea ()
@@ -69,48 +77,42 @@ def on_mount(self) -> None:
6977
7078 self .social_container = Vertical ()
7179 self .alias_container = Vertical ()
72- self .add_social_button = Button ("Agregar Red Social" , id = "add_social" )
73- self .add_alias_button = Button ("Agregar Alias" , id = "add_alias" )
80+ self .add_social_button = Button (BUTTON_ADD_SOCIAL , id = "add_social" )
81+ self .add_alias_button = Button (BUTTON_ADD_ALIAS , id = "add_alias" )
7482
75- self .save_button = Button ("Guardar" , id = "save" )
76- self .back_button = Button ("Atrás" , id = "back" )
77- self .quit_button = Button ("Salir" , id = "quit" )
83+ self .save_button = Button (BUTTON_SAVE , id = "save" )
84+ self .back_button = Button (BUTTON_BACK , id = "back" )
85+ self .quit_button = Button (BUTTON_QUIT , id = "quit" )
7886
7987 # 3) Mount them in the form container
8088 self .form_container .mount (self .form_header )
8189 self .form_container .mount (self .name_input )
8290 self .form_container .mount (self .email_input )
8391
84- self .form_container .mount (
85- Static ("Redes Sociales" , classes = "subheader" )
86- )
92+ self .form_container .mount (Static (SECTION_SOCIAL , classes = "subheader" ))
8793 self .form_container .mount (self .social_container )
8894 self .form_container .mount (self .add_social_button )
8995
90- self .form_container .mount (Static ("Aliases" , classes = "subheader" ))
96+ self .form_container .mount (Static (SECTION_ALIASES , classes = "subheader" ))
9197 self .form_container .mount (self .alias_container )
9298 self .form_container .mount (self .add_alias_button )
9399
94100 self .form_container .mount (self .city_input )
95101 self .form_container .mount (self .homepage_input )
96- self .form_container .mount (
97- Static ("¿Quién eres y a qué te dedicas?" , classes = "subheader" )
98- )
102+ self .form_container .mount (Static (SECTION_WHO , classes = "subheader" ))
99103 self .form_container .mount (self .who_area )
100- self .form_container .mount (
101- Static ("¿Cómo programas en Python?" , classes = "subheader" )
102- )
104+ self .form_container .mount (Static (SECTION_PYTHON , classes = "subheader" ))
103105 self .form_container .mount (self .python_area )
104106 self .form_container .mount (
105107 Static (
106- "¿Tienes algún aporte a la comunidad de Python?" ,
108+ SECTION_CONTRIB ,
107109 classes = "subheader" ,
108110 )
109111 )
110112 self .form_container .mount (self .contributions_area )
111113 self .form_container .mount (
112114 Static (
113- "¿Estás disponible para hacer mentoring, consultorías, charlas?" ,
115+ SECTION_AVAIL ,
114116 classes = "subheader" ,
115117 )
116118 )
@@ -177,7 +179,7 @@ def on_list_view_selected(self, event: ListView.Selected) -> None:
177179 def on_button_pressed (self , event : Button .Pressed ) -> None :
178180 bid = event .button .id
179181 if bid == "quit_list" :
180- self .exit ("¡Hasta la próxima!" )
182+ self .exit (message = MESSAGE_EXIT )
181183 elif bid == "add_social" :
182184 self .add_social_entry ()
183185 elif bid == "add_alias" :
@@ -193,7 +195,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
193195 self .clear_form ()
194196 self .show_list ()
195197 elif bid == "quit" :
196- self .exit ("Saliendo de la aplicación." )
198+ self .exit (MESSAGE_QUIT )
197199 elif bid and bid .startswith ("delete_social_" ):
198200 index = int (bid .replace ("delete_social_" , "" ))
199201 self .remove_social_entry (index )
@@ -205,13 +207,13 @@ def add_social_entry(self) -> None:
205207 class SocialEntry (Horizontal ):
206208 DEFAULT_CSS = """
207209 SocialEntry Select {
208- width: 25%;
210+ width: 25%;
209211 }
210212 SocialEntry Input {
211- width: 50%;
213+ width: 50%;
212214 }
213215 SocialEntry Button {
214- width: 25%;
216+ width: 25%;
215217 }
216218 """
217219
@@ -229,10 +231,12 @@ def __init__(se, index):
229231 ("X" , "x" ),
230232 ("YouTube" , "youtube" ),
231233 ],
232- prompt = "Red Social" ,
234+ prompt = "Social Network" ,
235+ )
236+ se .url_input = Input (placeholder = PLACEHOLDER_SOCIAL_URL )
237+ se .delete_btn = Button (
238+ BUTTON_DELETE , id = f"delete_social_{ index } "
233239 )
234- se .url_input = Input (placeholder = "URL de la red social" )
235- se .delete_btn = Button ("Eliminar" , id = f"delete_social_{ index } " )
236240
237241 def compose (se ) -> ComposeResult :
238242 yield se .select
@@ -258,18 +262,20 @@ def add_alias_entry(self) -> None:
258262 class AliasEntry (Horizontal ):
259263 DEFAULT_CSS = """
260264 AliasEntry Input {
261- width: 75%;
265+ width: 75%;
262266 }
263267 AliasEntry Button {
264- width: 25%;
268+ width: 25%;
265269 }
266270 """
267271
268272 def __init__ (se , index ):
269273 super ().__init__ ()
270274 se .index = index
271- se .alias_input = Input (placeholder = "Alias" )
272- se .delete_btn = Button ("Eliminar" , id = f"delete_alias_{ index } " )
275+ se .alias_input = Input (placeholder = PLACEHOLDER_ALIAS )
276+ se .delete_btn = Button (
277+ BUTTON_DELETE , id = f"delete_alias_{ index } "
278+ )
273279
274280 def compose (se ) -> ComposeResult :
275281 yield se .alias_input
0 commit comments