Created
September 2, 2020 15:02
-
-
Save MrGibus/9f3ad86989e2c5fd064a511e937e1eed to your computer and use it in GitHub Desktop.
Basic form, inputs and an output
This file contains hidden or 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
| import PySimpleGUI as sg | |
| sg.theme("DarkBlue") | |
| def deflection(l, e, i, w): | |
| d = 5 / 384 * w * l**4 / e / i | |
| return f'{d:0.3f}' | |
| def main(): | |
| layout = [[sg.Text("L:"), sg.Input(key='-LENGTH-')], | |
| [sg.Text("E:"), sg.Input(key='-E-')], | |
| [sg.Text("I:"), sg.Input(key='-I-')], | |
| [sg.Text("w:"), sg.Input(key='-LOAD-')], | |
| [sg.Button('Calculate')], | |
| [sg.Text("δ"), sg.Input(key='-OUTPUT-')]] | |
| window = sg.Window('Simple Deflection Calculator', layout) | |
| while True: | |
| event, values = window.read() | |
| print(event, values) | |
| if event == 'Exit' or event == sg.WIN_CLOSED: | |
| break | |
| if event == 'Calculate': | |
| l = float(values['-LENGTH-']) | |
| e = float(values['-E-']) | |
| i = float(values['-I-']) | |
| w = float(values['-LOAD-']) | |
| d = deflection(l, e, i, w) | |
| print(d) | |
| window.FindElement('-OUTPUT-').update(d) | |
| window.close() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment