Python Calculator with GUI | PySimpleGUI | Texas Instruments DataMath II

preview_player
Показать описание
In this video, learn how to build a Python Calculator with GUI using the PySimpleGUI library. To add some style, I modeled this after the Texas Instruments DataMath II, which was manufactured around 1975. This is a great project to flex your GUI skills if you're just getting started, and also provides a challenge on the calculator functionality.

In this video:
0:00 | overview
0:52 | required libraries
1:18 | digital 7 font (link)
1:38 | design elements
2:00 | the layout
2:41 | code view of layout
3:03 | sharing common attributes
3:36 | notes on default settings
4:19 | the window element
4:33 | the event loop
5:35 | using callbacks
5:51 | updating the display
6:30 | my approach to the calc functions

Рекомендации по теме
Комментарии
Автор

As a mechanical engineer, a lot of concepts like "event loop" are missing a name for me. Until watching this video. This is super high quality stuff. Thank you.

JZ
Автор

*This is what super high quality, well planned teaching looks like.* Thanks a bunch!

nipunasudha
Автор

this explained a number of PySimpleGUI concepts in 8 minutes that I didn't get anywhere else! Just starting to learn this library and this was an incredibly well thought out approach! Thanks!

hchattaway
Автор

Hey bro, your videos are such high quality and so well thought out. Your quality is definitely noticeable, and I have no doubt it would have taken a lot of effort to do all this. It's a bummer to see that you stopped making videos. Overall, thank you so much for all the videos you've made :)

joshuakim
Автор

That was so pleasing to listen to and look at. It was short and sweet, and it really laid it all out there for me to go in and tinker/replicate it myself

drainis
Автор

Thanks so much. I'm working on a project and ended the day struggling to find out how to arrange my buttons in rows instead of the default columns. Watched your video and then bam! Rows.

kmcg
Автор

LOVE the animations! This is fantastic!!

PySimpleGUI
Автор

Hi there, this video is pretty awesome. My English is bad but I almost completely understood, thanks a lot

ivanfedorov
Автор

Thank you so much... Keep doing please!!!!

worldmusiclyrics
Автор

Bro the way you laid this out is awesome! I love this tutorial!
The animations are incredible! What program did you use to make these animations! I'd love to know!

DevAprender
Автор

This is really well done. Hope you make more.

brockk
Автор

great video and thanks a lot it was very straightforward

jaimerojas
Автор

Thanks for your usefull job, Q: every element has no index, but if i wish change p.ex. the color of a button when pushed, if i have 5 or 10 buttons, how can i address each ones? thanks a lot.

claudiotonci
Автор

Thank you. I'm looking good.
Is it possible to customize with the round(circle) button in PySimpleGUI?

snagjulee
Автор

For those who cant access pip try
py -m pip install

JimPageGD
Автор

Just curious; what code editor are you using?

cloaker
Автор

Hlw sir I want code source of this calculator can u plz share this

Artsy__
Автор

how to install in windows? any setup.exe?

vactum
Автор

import PySimpleGUI as sg

sg.popup_ok('Atenção!',
'Não utilizar pontos e vírgulas nos valores recebidos, não deixar valores em branco, pagamento não recebido colocar 0 (zero) !')

sg.theme('DarkAmber') # Add a touch of color

# All the stuff inside your window.
layout = ([sg.Text('Total recebido em Dinheiro:'), sg.Input(size=(7, 1), key=('valor0'))],
[sg.Text('Total recebido no Débito:'), sg.Input(size=(7, 1), key=('valor'))],
[sg.Text('Total recebido no Crédito a vista:'), sg.Input(size=(7, 1), key=('valor1'))],
[sg.Text('Total recebido Crédito até 6x:'), sg.Input(size=(7, 1), key=('valor2'))],
[sg.Text('Total recebido Crédito de 7x até 12x:'), sg.Input(size=(7, 1), key=('valor3'))],
[sg.Text('VALORES CARTÃO ELO', background_color='Black', justification='center4')],
[sg.Text('Total recebido Débito Elo:'), sg.Input(size=(7, 1), key=('valor4'))],
[sg.Text('Total recebido Crédito a vista Elo:'), sg.Input(size=(7, 1), key=('valor5'))],
[sg.Text('Total recebido Crédito Elo até 6x:'), sg.Input(size=(7, 1), key=('valor6'))],
[sg.Text('Total recebido Crédito Elo de 7x até 12x:'), sg.Input(size=(7, 1), key=('valor7'))],
[sg.Output(size=(80, 20))],
[sg.Button('Calcular'), sg.Button('Cancel')])

# Create the Window
window = sg.Window('Calculador porcentagem do Dentista', layout)

# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
break

# Aqui é feito o cálculo da porcentagem da maquininha a ser descontada do valor total
if event == 'Calcular':
values['valor0'] = float
values['valor'] = float
values['valor1'] = float
values['valor2'] = float
values['valor3'] = float
values['valor4'] = float
values['valor5'] = float
values['valor6'] = float
values['valor7'] = float
porcent = values['valor'] * 0.0178
porcent1 = values['valor1'] * 0.0294
porcent2 = values['valor2'] * 0.0350
porcent3 = values['valor3'] * 0.0370
porcent4 = values['valor4'] * 0.0304
porcent5 = values['valor5'] * 0.0409
porcent6 = values['valor6'] * 0.0462
porcent7 = values['valor7'] * 0.0509
desco = values['valor'] - porcent # Aqui é feito o desconto da taxa da maquininha do valor total
desco1 = values['valor1'] - porcent1
desco2 = values['valor2'] - porcent2
desco3 = values['valor3'] - porcent3
desco4 = values['valor4'] - porcent4
desco5 = values['valor5'] - porcent5
desco6 = values['valor6'] - porcent6
desco7 = values['valor7'] - porcent7
liq0 = values['valor0'] * 0.35 # Aqui é feito os 35% a ser repassado para o dentista do valor com a taxa da maquininha descontada
liq = desco * 0.35
liq1 = desco1 * 0.35
liq2 = desco2 * 0.35
liq3 = desco3 * 0.35
liq4 = desco4 * 0.35
liq5 = desco5 * 0.35
liq6 = desco6 * 0.35
liq7 = desco7 * 0.35
print('Valor liquido a receber é', liq0 + liq + liq1 + liq2 + liq3 + liq4 + liq5 + liq6 + liq7) # Aqui imprimi na tela o valor total dos 35% a ser repassado ao dentista de todos os pagamentos

window.close()
#Not working... it didn't do the calculation, what is wrong with it please?

gotas.de.terror
Автор

Please say I hindi
Hindi me bol bhai....

divyanshu
join shbcf.ru