Created
April 2, 2020 03:59
-
-
Save bykalim/8a63c76f79180b8ec5b3020f37609bed to your computer and use it in GitHub Desktop.
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
from tkinter import * | |
from tkinter import messagebox | |
class Chb: | |
def __init__(self,root): | |
label1 = Label(root, text="Model") | |
label1.pack(anchor=W) | |
frame1 = Frame(root,relief=GROOVE, borderwidth=2) | |
frame1.pack(anchor=W,expand=YES, fill=BOTH) | |
self.var1 = IntVar() | |
for text, value in [('BMW',0),('Fiat',1),('Opel',2)]: | |
Radiobutton(frame1,text=text, value=value, variable=self.var1).grid( | |
row = value, column = 0, padx = 5, pady = 5, sticky=W) | |
label2 = Label(root, text="Systems & Accesories") | |
label2.pack(anchor=W) | |
frame2 = Frame(root,relief=GROOVE, borderwidth=2) | |
frame2.pack(anchor=W,expand=YES, fill=BOTH) | |
self.vars=[] | |
for system, row, col, status in [('Parking Sensor', 3,0,NORMAL), | |
('EPS', 3,1, NORMAL), | |
('AC', 3,2,NORMAL), | |
('CL', 3,3,NORMAL), | |
('Navigation', 4,0,NORMAL), | |
('ASR',4,1,NORMAL), | |
('ABS', 4,2,NORMAL), | |
('ISA', 4,3,NORMAL)]: | |
var = IntVar() | |
Checkbutton(frame2, text=system, state=status, | |
anchor=W, variable = var).grid(row=row, column=col, | |
padx = 5, pady = 5, sticky=W) | |
self.vars.append(var) | |
btn1 = Button(root, text='Calculate Price', command = self.fun) | |
btn1.pack(side=LEFT, expand=YES, fill=BOTH) | |
def fun(self): | |
i = self.var1.get() | |
print(i) | |
p=0 | |
if(i==0): | |
p=220000 | |
elif (i==1): | |
p=65000 | |
elif (i==2): | |
p=43000 | |
result = 0 | |
acc = [1000, 1500, 800, 2000, 2600,1300,900,2100] | |
for i in range(0,len(self.vars)): | |
if(self.vars[i].get()==1): | |
result += acc[i] | |
messagebox.showinfo('Car price',str(p+result)+' zl') | |
def main(): | |
t = Tk() | |
t.title('Car Selling') | |
t.geometry("300x250") | |
rb = Chb(t) | |
t.mainloop() | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment