-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbloco.py
More file actions
111 lines (92 loc) · 2.85 KB
/
bloco.py
File metadata and controls
111 lines (92 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from tkinter import *
from tkinter.filedialog import askopenfilename, asksaveasfilename
def salvar():
global diretorio
try:
if diretorio == '':
diretorio = asksaveasfilename()
arq = open(diretorio, 'w')
arq.write(texto.get("1.0", END))
except:
pass
def abrir():
global diretorio
try:
diretorio = askopenfilename()
conteudo = []
arq = open(diretorio, 'r')
for linha in arq:
conteudo.append(linha)
texto.delete("1.0", END)
texto.insert('insert' ,'\n'.join(conteudo))
except:
pass
def sair():
tela.destroy()
def tema(estilo):
if estilo == 1:
texto['bg'] = 'black'
texto['fg'] = 'white'
if estilo == 2:
texto['bg'] = 'white'
texto['fg'] = 'black'
if estilo== 3:
texto['bg'] = 'orange'
texto['fg'] = 'black'
def tamanho_fonte(n):
global tamanho
if tamanho == 8:
pass
else:
if n == 1:
tamanho += 2
elif n == 2:
tamanho -= 2
texto['font'] = (fonte_estilo, tamanho)
def tipo_fonte(n):
global fonte_estilo
if n == 1:
texto['font'] = ('arial')
fonte_estilo = 'arial'
if n == 2:
texto['font'] = ('courier')
fonte_estilo = 'courier'
if n == 3:
texto['font'] = ('terminal')
fonte_estilo = 'terminal'
if n == 4:
texto['font'] = ('roman')
fonte_estilo = 'roman'
diretorio = ''
tamanho = 12
fonte_estilo = 'arial'
tela = Tk()
tela['bg'] = 'gray'
tela.title('Bloco De Notas')
tela.geometry('800x600')
menu = Menu(tela)
arquivo = Menu(menu)
arquivo.add_command(label="Abrir", command = abrir)
arquivo.add_command(label="Salvar", command = salvar)
arquivo.add_command(label = "sair", command = sair)
menu.add_cascade(label="Arquivo", menu=arquivo)
estilo = Menu(menu)
estilo.add_command(label = 'escuro', command = lambda : tema(1))
estilo.add_command(label = 'claro', command = lambda : tema(2))
estilo.add_command(label = 'laranja', command = lambda : tema(3))
menu.add_cascade(label="tema", menu = estilo)
fonte = Menu(menu)
fonte.add_command(label = 'Texto Maior', command = lambda : tamanho_fonte(1))
fonte.add_command(label = 'Texto Menor', command = lambda : tamanho_fonte(2))
menu.add_cascade(label = 'texto', menu = fonte)
fonte2 = Menu(menu)
fonte2.add_command(label = 'Arial', command = lambda : tipo_fonte(1))
fonte2.add_command(label = 'Courier', command = lambda : tipo_fonte(2))
fonte2.add_command(label = 'Terminal', command = lambda : tipo_fonte(3))
fonte2.add_command(label = 'Roman', command = lambda : tipo_fonte(4))
menu.add_cascade(label = 'Fonte', menu = fonte2)
tela.config(menu = menu)
texto = Text (tela, width = 180, height = 80, bg = 'white', fg = 'black')
texto.pack(side = TOP)
texto.configure(font=(fonte_estilo, tamanho))
tela.mainloop()