@@ -14,14 +14,14 @@ def nuevo():
14
14
mensaje .set ("New file" )
15
15
ruta = ""
16
16
texto .delete (1.0 , "end" )
17
- root .title ("Pyfoch Editor " )
17
+ root .title ("Pyfoch" )
18
18
19
19
def abrir ():
20
20
global ruta
21
21
mensaje .set ("Open file" )
22
22
ruta = FileDialog .askopenfilename (
23
23
initialdir = '.' ,
24
- filetypes = (("Pyfoch File " , "*.pfcf" ),("Text file" , "*.txt" ),),
24
+ filetypes = (("Pyfoch" , "*.pfcf" ),("Text file" , "*.txt" ),),
25
25
title = "Open a new file" )
26
26
27
27
if ruta != "" :
@@ -30,7 +30,7 @@ def abrir():
30
30
texto .delete (1.0 ,'end' )
31
31
texto .insert ('insert' , contenido )
32
32
fichero .close ()
33
- root .title (ruta + " - Pyfoch Editor " )
33
+ root .title (ruta + " - Pyfoch" )
34
34
35
35
def guardar ():
36
36
mensaje .set ("Save file" )
@@ -47,13 +47,12 @@ def guardar_como():
47
47
global ruta
48
48
mensaje .set ("Save file as" )
49
49
50
- fichero = FileDialog .asksaveasfile (title = "Save file" ,
51
- mode = "w" , defaultextension = ".pfcf" )
50
+ fichero = FileDialog .asksaveasfile (title = "Save file" , mode = "w" , defaultextension = ".pfcf" )
52
51
53
52
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+' )
57
56
fichero .write (contenido )
58
57
fichero .close ()
59
58
mensaje .set ("File saved succesfully" )
@@ -63,28 +62,66 @@ def guardar_como():
63
62
64
63
65
64
# 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 )
72
73
filemenu .add_command (label = "New" , command = nuevo )
73
74
filemenu .add_command (label = "Open" , command = abrir )
74
- filemenu .add_command (label = "save " , command = guardar )
75
+ filemenu .add_command (label = "Save " , command = guardar )
75
76
filemenu .add_command (label = "Save as" , command = guardar_como )
76
77
filemenu .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
+
77
114
filemenu .add_command (label = "Exit" , command = root .quit )
78
115
menubar .add_cascade (menu = filemenu , label = "File" )
79
116
80
117
# Caja de texto central
81
- texto = Text (root )
118
+ texto = Text (root )
82
119
texto .pack (fill = "both" , expand = 1 )
83
120
texto .config (bd = 0 , padx = 6 , pady = 4 , font = ("Consolas" ,12 ))
84
121
85
122
# Monitor inferior
86
123
mensaje = StringVar ()
87
- mensaje .set ("Welcome to Pyfoch Editor " )
124
+ mensaje .set ("Welcome to Pyfoch" )
88
125
monitor = Label (root , textvar = mensaje , justify = 'left' )
89
126
monitor .pack (side = "left" )
90
127
0 commit comments