Skip to content

Commit 6c18f23

Browse files
authored
Update main.py
1 parent 3d769ca commit 6c18f23

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

Bloc de Notas/main.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ def widgets(self):
3939
archivo.add_command(label="Guardar", command = self.guardar_archivo)
4040
archivo.add_separator()
4141
archivo.add_command(label="Salir", command = self.master.quit)
42+
4243
edicion = Menu(menu, tearoff=0)
4344
edicion.add_command(label="Deshacer", command = lambda: self.texto.edit_undo())
4445
edicion.add_separator()
46+
47+
4548
edicion.add_command(label="Cortar", accelerator='Ctrl+X',
4649
command = lambda: self.master.focus_get().event_generate("<<Cut>>") )
4750
edicion.add_command(label="Copiar", accelerator='Ctrl+C',
@@ -70,20 +73,25 @@ def widgets(self):
7073
ayuda.add_command(label="Ver la ayuda")
7174
ayuda.add_separator()
7275
ayuda.add_command(label="Acerca del Bloc de notas", command= self.acerca_de)
76+
7377
menu.add_cascade(label="Archivo", menu=archivo)
7478
menu.add_cascade(label="Edicion", menu=edicion)
7579
menu.add_cascade(label="Formato", menu=formato)
7680
menu.add_cascade(label="Ver", menu=ver)
7781
menu.add_cascade(label="Ayuda", menu=ayuda)
7882

79-
self.texto = Text(self.master, font= ('Arial', 12), undo= True, insertbackground='red') #undo = True, selectbackground='yellow'
83+
self.texto = Text(self.master, font= ('Arial', 12), undo= True, insertbackground='red')
8084
self.texto.grid(column=0, row=0, sticky='nsew')
8185
ladox = Scrollbar(self.master, orient = 'horizontal', command= self.texto.xview)
8286
ladox.grid(column=0, row = 1, sticky='ew')
8387
ladoy = Scrollbar(self.master, orient ='vertical', command = self.texto.yview)
8488
ladoy.grid(column = 1, row = 0, sticky='ns')
8589
self.texto.configure(xscrollcommand = ladox.set, yscrollcommand = ladoy.set)
8690
self.barra_estado = Label(self.master, font = ('Segoe UI Symbol', 10))
91+
92+
#eventos
93+
self.master.bind('<Shift-KeyPress-S>', self.salir)
94+
8795
def ajustes_de_linea(self):
8896
if self.señal_ajustes.get() == True:
8997
self.texto.config(wrap='word')
@@ -117,21 +125,24 @@ def zoom_menos(self):
117125
else:
118126
self.n = 12
119127

120-
def salir(self):
128+
def salir(self, *args):
121129
valor = messagebox.askyesno('Salir', '¿Desea Salir?',parent= self.master)
122130
if valor == True:
123131
self.master.destroy()
124132
self.master.quit()
125133

126134
def abrir_archivo(self):
127-
direcion = filedialog.askopenfilename(initialdir ='/', title='Archivo',
128-
filetype=(('txt files', '*.txt*'),('All files', '*.*')))
135+
direcion = filedialog.askopenfilename(initialdir ='/',
136+
title='Archivo',
137+
filetype=(('txt files', '*.txt*'),('All files', '*.*')))
129138
if direcion != '':
130139
archivo = open(direcion, 'r')
131140
contenido = archivo.read()
132141
self.texto.delete('1.0', 'end')
133142
self.texto.insert('1.0', contenido)
134143
self.master.title(direcion)
144+
145+
135146
def guardar_archivo(self):
136147
try:
137148
filename = filedialog.asksaveasfilename(defaultextension='.txt')
@@ -153,22 +164,22 @@ def nueva_ventana(self):
153164
self.texto.delete('1.0', 'end')
154165

155166
def segunda_ventana(self):
156-
segunda_ventana = Toplevel()
167+
segunda_ventana = Toplevel(self.master)
157168
segunda_ventana = Ventana(segunda_ventana)
158-
segunda_ventana.mainloop()
159169

160170
def acerca_de(self):
161-
vent_info = Toplevel(bg='white')
171+
vent_info = Toplevel(self.master)
172+
vent_info.config( bg='white')
162173
vent_info.title('')
163174
vent_info.resizable(0,0)
164175
vent_info.iconbitmap('icono.ico')
165176
vent_info.geometry('350x200+200+200')
166177
Label(vent_info, bg='white',
167178
text= 'Programa realizado en Python \n con la liberia de Tkinter \n\n Autor: Magno Efren').pack(expand=True)
168-
vent_info.mainloop()
169179

170-
def formato_fuente(self):
171-
self.vent_tipo_fuente = Toplevel()
180+
181+
def formato_fuente(self):
182+
self.vent_tipo_fuente = Toplevel(self.master)
172183
self.vent_tipo_fuente.overrideredirect(1)
173184
self.vent_tipo_fuente.geometry('390x290+400+200')
174185
self.vent_tipo_fuente.config(bg= 'SeaGreen1', relief ='raised', bd = 3)
@@ -203,7 +214,7 @@ def formato_fuente(self):
203214
self.aceptar.grid(columnspan=2, row=3, padx=5, pady=5)
204215

205216
self.aplicar_formato()
206-
self.vent_tipo_fuente.mainloop()
217+
207218

208219
def mover(self, event):
209220
deltax = event.x - self.x
@@ -238,7 +249,7 @@ def elegir_color_texto(self):
238249
self.texto.config(fg= color, insertbackground = color)
239250

240251
def elegir_color_fondo(self):
241-
color = colorchooser.askcolor()[1] #ff0000 askcolor()[1] , askcolor()[0] (255.0, 0.0, 0.0)
252+
color = colorchooser.askcolor()[1]
242253
self.texto.config(bg= color)
243254

244255

@@ -247,4 +258,3 @@ def elegir_color_fondo(self):
247258
app = Ventana(ventana)
248259
app.mainloop()
249260

250-

0 commit comments

Comments
 (0)