-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
def get_vars(conta) -> list: | ||
vars = list() | ||
for c in conta: | ||
# print(c) | ||
if c.isalpha() or c == '=': | ||
vars.append(c) | ||
# print(c, vars) | ||
# print(vars) | ||
return vars | ||
|
||
cores = ['blue', | ||
'green', | ||
'yellow', | ||
'red', | ||
'white'] | ||
|
||
|
||
def formatar(num, conta) -> dict: | ||
formatado = list() | ||
|
||
|
||
print(conta) | ||
vars = get_vars(conta) | ||
for i, v in enumerate(vars): | ||
p1 = conta.find(v) | ||
p2 = p1 +1 | ||
# print('i', 'v', 'p1 p2') | ||
# print(i, v, p1, p2) | ||
d = { | ||
'nome':v+str(num), | ||
'p1':p1, | ||
'p2':p2, | ||
'fg':cores[i] | ||
} | ||
formatado.append(d) | ||
|
||
# mostrar | ||
|
||
return formatado | ||
if __name__ == '__main__': | ||
conta2x2 = 'x2y=5\n3x-5y=4' | ||
conta = conta2x2.split('\n') | ||
print(conta) | ||
formatado = list() | ||
for i, c in enumerate(conta): | ||
formatado.append(formatar(i, c)) | ||
print() | ||
print(formatado) |
31 changes: 31 additions & 0 deletions
31
06-sistemaLinear/sistemaLinear_v11-emDev/teste/cores copy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from tkinter import * | ||
from sys import exit | ||
|
||
conta2x2 = 'x2y=5\n3x-5y=4' | ||
root = Tk() | ||
text = Text(root, width=20, height=10) | ||
text.config(font='arial 20 bold') | ||
text.insert(END, conta2x2) | ||
text.pack() | ||
|
||
def q_evento(event): | ||
exit() | ||
root.bind('q', q_evento) | ||
|
||
cs = conta2x2.split('\n') | ||
print('cs', cs) | ||
posicao = cs[0].find('y') | ||
print('posicao:', posicao) | ||
|
||
p1 = p2 = '1.' | ||
p1 += str(posicao) | ||
p2 += str(posicao+1) | ||
|
||
print('p1:', p1, 'p2:', p2) | ||
|
||
|
||
text.tag_add("y1", p1, p2) | ||
text.tag_config("y1", background="black", foreground="green") | ||
|
||
text.tag_config('1', foreground="green") | ||
root.mainloop() |