@@ -14,14 +14,14 @@ def nuevo():
1414 mensaje .set ("New file" )
1515 ruta = ""
1616 texto .delete (1.0 , "end" )
17- root .title ("Pyfoch Editor " )
17+ root .title ("Pyfoch" )
1818
1919def abrir ():
2020 global ruta
2121 mensaje .set ("Open file" )
2222 ruta = FileDialog .askopenfilename (
2323 initialdir = '.' ,
24- filetypes = (("Pyfoch File " , "*.pfcf" ),("Text file" , "*.txt" ),),
24+ filetypes = (("Pyfoch" , "*.pfcf" ),("Text file" , "*.txt" ),),
2525 title = "Open a new file" )
2626
2727 if ruta != "" :
@@ -30,7 +30,7 @@ def abrir():
3030 texto .delete (1.0 ,'end' )
3131 texto .insert ('insert' , contenido )
3232 fichero .close ()
33- root .title (ruta + " - Pyfoch Editor " )
33+ root .title (ruta + " - Pyfoch" )
3434
3535def guardar ():
3636 mensaje .set ("Save file" )
@@ -47,13 +47,12 @@ def guardar_como():
4747 global ruta
4848 mensaje .set ("Save file as" )
4949
50- fichero = FileDialog .asksaveasfile (title = "Save file" ,
51- mode = "w" , defaultextension = ".pfcf" )
50+ fichero = FileDialog .asksaveasfile (title = "Save file" , mode = "w" , defaultextension = ".pfcf" )
5251
5352 if fichero is not None :
54- ruta = fichero .name
55- contenido = texto .get (1.0 ,'end-1c' )
56- fichero = open (ruta , 'w+' )
53+ ruta = fichero .name
54+ contenido = texto .get (1.0 ,'end-1c' )
55+ fichero = open (ruta , 'w+' )
5756 fichero .write (contenido )
5857 fichero .close ()
5958 mensaje .set ("File saved succesfully" )
@@ -63,28 +62,66 @@ def guardar_como():
6362
6463
6564# Configuracion de la raiz
66- root = Tk ()
67- root .title ("Pyfoch Editor" )
68-
69- # Menu superior
70- menubar = Menu (root )
71- filemenu = Menu (menubar , tearoff = 0 )
65+ root = Tk ()
66+ root .configure (bg = 'white' )
67+ root .title ("Pyfoch" )
68+ root .iconbitmap ('/icon.ico' )
69+
70+ # File Menu
71+ menubar = Menu (root )
72+ filemenu = Menu (menubar , tearoff = 0 )
7273filemenu .add_command (label = "New" , command = nuevo )
7374filemenu .add_command (label = "Open" , command = abrir )
74- filemenu .add_command (label = "save " , command = guardar )
75+ filemenu .add_command (label = "Save " , command = guardar )
7576filemenu .add_command (label = "Save as" , command = guardar_como )
7677filemenu .add_separator ()
78+
79+
80+ '''
81+ This code is mine:
82+ '''
83+ import pyforchange .pfcf .read as pfcf
84+
85+ def export ():
86+ global ruta
87+ mensaje .set ("Export file as" )
88+
89+ if ".pfcf" in ruta :
90+ ruta2 = ruta [:- 5 ]
91+ #.rstrip('f')
92+ T = pfcf .read (ruta2 ,0 )
93+
94+ fichero = FileDialog .asksaveasfile (title = "Save file" , mode = "w" , defaultextension = ".txt" )
95+
96+ if fichero is not None :
97+ ruta = fichero .name
98+ contenido = T
99+ fichero = open (ruta , 'w+' )
100+ fichero .write (contenido )
101+ fichero .close ()
102+ mensaje .set ("File saved succesfully" )
103+ else :
104+ mensaje .set ("Save canceled" )
105+ ruta = ""
106+
107+ #Tools Menu
108+ filemenu .add_command (label = "Export" , command = export )
109+ '''
110+ This code is based on the code from
111+ https://docs.hektorprofe.net/python/interfaces-graficas-con-tkinter/editor-de-texto
112+ '''
113+
77114filemenu .add_command (label = "Exit" , command = root .quit )
78115menubar .add_cascade (menu = filemenu , label = "File" )
79116
80117# Caja de texto central
81- texto = Text (root )
118+ texto = Text (root )
82119texto .pack (fill = "both" , expand = 1 )
83120texto .config (bd = 0 , padx = 6 , pady = 4 , font = ("Consolas" ,12 ))
84121
85122# Monitor inferior
86123mensaje = StringVar ()
87- mensaje .set ("Welcome to Pyfoch Editor " )
124+ mensaje .set ("Welcome to Pyfoch" )
88125monitor = Label (root , textvar = mensaje , justify = 'left' )
89126monitor .pack (side = "left" )
90127
0 commit comments