Question
This is my program so far. import tkinter import tkinter.messagebox class Calls: def __init__(self): #main window self.main_window = tkinter.Tk() #Create the frames self.main_frame = tkinter.Frame(self.main_window)
This is my program so far.
import tkinter import tkinter.messagebox
class Calls: def __init__(self): #main window self.main_window = tkinter.Tk() #Create the frames self.main_frame = tkinter.Frame(self.main_window) self.daytime_frame = tkinter.Frame(self.main_window) self.evening_frame = tkinter.Frame(self.main_window) self.peak_frame = tkinter.Frame(self.main_window) self.button_frame = tkinter.Frame(self.main_window) #Create IntVar object to be used with the Radio butttons. self.radio_var= tkinter.IntVar() #Set the IntVar object to 1 self.radio_var.set(1) self.main_Label = tkinter.Label(self.main_frame, \ text = 'Select rate Category') self.main_Label2 = tkinter.Label(self.main_frame, \ text = '----------------------------------------------------') #RadioButtons self.rb1 = tkinter.Radiobutton(self.daytime_frame, \ text='Daytime (6:00 am through 5:59 pm)', variable=self.radio_var, \ value=1) self.rb2 = tkinter.Radiobutton(self.evening_frame, \ text='Evening (6:00 pm through 11:59 pm)', variable=self.radio_var, \ value=2) self.rb3 = tkinter.Radiobutton(self.peak_frame, \ text='Off-Peak (midnight through 5:59 pm)', variable=self.radio_var, \ value=3) #Entry box self.minutes_enter = tkinter.Entry(self.button_frame, \ width=4) #pack main frame and label self.main_frame.pack() self.main_Label.pack(side = 'top') self.main_Label2.pack(side = 'bottom') #Pack Entry box self.minutes_enter.pack(side='bottom') #pack the buttons self.rb1.pack(side='right') self.rb2.pack(side='right') self.rb3.pack(side='right') #Create an OK and Quit button self.ok_button = tkinter.Button(self.button_frame, \ text='Convert', command=self.show_choice) self.quit_button = tkinter.Button(self.button_frame, \ text='Exit', command=self.main_window.destroy) #packing the buttons self.ok_button.pack(side='left') self.quit_button.pack(side='right') #packing the frames self.daytime_frame.pack() self.evening_frame.pack() self.peak_frame.pack() self.button_frame.pack() #mainloop tkinter.mainloop() def show_choice(self): self.num = int(self.radio_var.get()) self.data = float(self.minutes_enter.get()) if self.num == str(1): self.data *= 0.07 elif self.num ==2: self.data *= 0.12 elif self.num ==3: self.data *= 0.05 my_gui = Calls()
Whenever I run it, I get the dialogue box I want
Of course I'm having a hard time multiplying the number of minutes with the charging costs. Whenever I type in "2" into the Entry box and click on "Convert" button, I can't get another dialogue box to open with the total charge of minutes.
How can I do an if-else statement in order for my program to work and convert.
I want it to work like the dialogue box below...
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started