Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasht committed Mar 2, 2022
1 parent 50cb75d commit dd842a7
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 8 deletions.
45 changes: 45 additions & 0 deletions 06-sistemaLinear/sistemaLinear_v11-emDev/corFunc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

cores = ['blue',
'green',
'yellow',
'red',
'cyan',
'gray',
'light green',
'white']


def formatar(line, conta) -> list:
line += 1
line = str(line)

formatado = list()
contador = 0

for i, c in enumerate(conta):
if c.isalpha() and c != '=':

p1 = i
p2 = p1 + 1

p1 = str(p1)
p2 = str(p2)

nome = c+line+p1

if contador == len(cores):
contador = 0
d = {
'nome': nome,
'p1': line+'.'+p1,
'p2': line +'.'+p2,
'fg': cores[contador]
}
formatado.append(d)
contador += 1

return formatado


if __name__ == '__main__':
formatar(line=0, conta='33xcx8x=safsafsfasfasfsf')
4 changes: 4 additions & 0 deletions 06-sistemaLinear/sistemaLinear_v11-emDev/exemplo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# 2x-y+3z=10
# '''

conta1x1 = '''
2x=30
'''

conta2x2 = '''
x 2y = 5
3x -5y = 4
Expand Down
48 changes: 40 additions & 8 deletions 06-sistemaLinear/sistemaLinear_v11-emDev/fr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from re import S
from tkinter import BOTTOM, END, LEFT, N, NSEW, RIGHT, Tk, ttk, Text

from tkinter import ttk
from tkinter import *
import uteis as u
import exemplo as ex

from corFunc import formatar

class Fr(ttk.Frame):
def __init__(self, parent, con):
Expand All @@ -27,10 +28,12 @@ def __init__(self, parent, con):
# label frame
self.lbfr = ttk.Labelframe(self, text='exemplo')

self.bt_e1x1 = ttk.Button(self.lbfr, text='1x1', command=self.bt_1x1evento)
self.bt_e2x2 = ttk.Button(self.lbfr, text='2x2', command=self.bt_2x2evento)
self.bt_e3x3 = ttk.Button(self.lbfr, text='3x3', command=self.bt_3x3evento)
self.bt_e4x4 = ttk.Button(self.lbfr, text='4x4', command=self.bt_4x4evento)

self.bt_e1x1.grid(padx=8, pady=6)
self.bt_e2x2.grid(padx=8, pady=6)
self.bt_e3x3.grid(padx=8, pady=6)
self.bt_e4x4.grid(padx=8, pady=6)
Expand All @@ -39,34 +42,63 @@ def __init__(self, parent, con):
self.lbfr.grid(row=0, column=1, padx=12)
self.lb_solucao.grid(row=1, column=0, columnspan=3)

self.lb_solucao.config(font='helvetica 15 bold')
self.lb_solucao.config(font='arial 15 bold')

self.txt.bind('<KeyRelease>', self.txt_event)


def txt_event(self, event):

if self.txt.get(1.0, END):
self.put_color()
# text
def put_color(self):
conta = self.txt.get('1.0', END)
conta = conta.split('\n')
formatado = list()

# pegando informacoes
for i, c in enumerate(conta):
formatado.append(formatar(i, c))

# colocando
for f1 in formatado:
for f in f1:
self.txt.tag_add(f['nome'], f['p1'], f['p2'])
self.txt.tag_config(f['nome'], foreground=f['fg'])

def delete_evento(self):
self.txt.delete(1.0, END)
self.lb_solucao.config(text='')

def bt_1x1evento(self):
self.delete_evento()
self.txt.insert(1.0, ex.conta1x1)
self.put_color()

def bt_2x2evento(self):
self.delete_evento()
self.txt.insert(1.0, ex.conta2x2)
self.put_color()


def bt_3x3evento(self):
self.delete_evento()
self.txt.insert(1.0, ex.conta3x3)
self.put_color()


def bt_4x4evento(self):
self.delete_evento()
self.txt.insert(1.0, ex.conta4x4)
# self.txt.insert(1.0, ex.conta5x5)
self.put_color()

def calcular_evento(self):
conta = self.txt.get(1.0, END)
print(conta)
solve = u.calcular(conta)
print(solve)
lb_solve = ''

for c, v in solve.items():
print(c, v)
lb_solve += f'{c.upper()} = {v}\n'

self.lb_solucao.config(text=lb_solve)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@



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',
'cyan',
'gray',
'light green',
'white']

def mostrar(n):
for nn in n:
print(nn)
def formatar(line, conta) -> list:
line += 1
line = str(line)

print(conta)

formatado = list()
contador = 0

for i, c in enumerate(conta):
if c.isalpha() and c != '=':

p1 = i
p2 = p1 + 1

p1 = str(p1)
p2 = str(p2)
# print('p1:', type(p1), p1)

nome = c+line+p1
print(nome)
if contador == len(cores):
contador = 0
d = {
'nome': nome,
'p1': line+'.'+p1,
'p2': line +'.'+p2,
'fg': cores[contador]
}
formatado.append(d)
contador += 1
# mostrar
# print()
# mostrar(formatado)

return formatado
if __name__ == '__main__':
formatar(line=0, conta='33xcx8x=safsafsfasfasfsf')
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import imp
from tkinter import *
from sys import exit
from corFunc import formatar

conta2x2 = 'x2y=5\n3x-5y=4'
class App(Tk):
def __init__(self):
super().__init__()

self.text = Text(self, width=20, height=10)
self.text.config(font='arial 20 bold')
# self.text.insert(END, conta2x2)
self.text.pack()
self.text.config(background='black', foreground='white')

# evento sair
self.bind('q', self.q_evento)

#
self.bind('<KeyRelease>', self.event)


def event(self, event):
if self.text.get(1.0, END):
self.put_color()
def put_color(self):
conta = self.text.get('1.0', END)
print('c:', conta)
conta = conta.split('\n')
print(conta)
formatado = list()

# pegando informacoes

for i, c in enumerate(conta):
formatado.append(formatar(i, c))
print('f:', formatado)
# colocando
for f1 in formatado:
for f in f1:
self.text.tag_add(f['nome'], f['p1'], f['p2'])
self.text.tag_config(f['nome'], foreground=f['fg'])

def q_evento(self, event):
exit()





if __name__ == '__main__':
root = App()
root.mainloop()

0 comments on commit dd842a7

Please sign in to comment.