-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaschenrechner.py
More file actions
35 lines (27 loc) · 942 Bytes
/
taschenrechner.py
File metadata and controls
35 lines (27 loc) · 942 Bytes
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
from tkinter import *
def rechnen():
if operator.curselection() == (0,):
ausgabe["text"] = float(zahl1.get()) + float(zahl2.get())
elif operator.curselection() == (1,):
ausgabe["text"] = float(zahl1.get()) - float(zahl2.get())
elif operator.curselection() == (2,):
ausgabe["text"] = float(zahl1.get()) * float(zahl2.get())
elif operator.curselection() == (3,):
ausgabe["text"] = float(zahl1.get()) / float(zahl2.get())
window = Tk()
window.title("Taschenrechner")
zahl1 = Entry(window)
operator = Listbox(window)
operator.insert(0, "+")
operator.insert(1, "-")
operator.insert(2, "*")
operator.insert(3, "/")
zahl2 = Entry(window)
button = Button(window, command=rechnen, text="Los", bg='#FBD975')
ausgabe = Label(window)
zahl1.grid(row=0, column=0)
operator.grid(row=0, column=1)
zahl2.grid(row=0, column=2)
button.grid(row=1, column=2, sticky=E)
ausgabe.grid(row=2)
window.mainloop()