Note that there are some explanatory texts on larger screens.

plurals
  1. POI would like to create a tkinter Python button that activates more than one command when I press one button
    primarykey
    data
    text
    <p>I want a button that activates two functions to calculate the tax assessment value of a property then the tax on the assessed value of the property with one button click.</p> <p>The button should say 'Calculate' and should activate a .6 * property value function and a .0064 * the value of the assessment.</p> <pre><code>import tkinter class PropertyTaxGUI: def __init__(self): self.main_window = tkinter.Tk() self.top_frame = tkinter.Frame() self.mid_frame = tkinter.Frame() self.third_frame = tkinter.Frame() self.bottom_frame = tkinter.Frame() self.prompt_label = tkinter.Label(self.top_frame, \ text='Enter the property value: $') self.property_entry = tkinter.Entry(self.top_frame, \ width=10) self.prompt_label.pack(side='left') self.property_entry.pack(side ='right') self.calc_button = tkinter.Button(self.bottom_frame, \ text = 'Calculate', \ command = self.calculate) self.quit_button = tkinter.Button(self.bottom_frame, \ text = 'Quit', \ command = self.main_window.destroy) self.value = tkinter.StringVar() self.calc_button.pack(side='right') self.quit_button.pack(side='right') self.assess_label= tkinter.Label(self.mid_frame, \ text='Assessment Value: ') self.assess_label.pack(side='left') self.value_label = tkinter.Label(self.mid_frame, \ textvariable=self.value) self.value_label.pack(side='right') self.prop_label= tkinter.Label(self.third_frame, \ text='Property Tax: ') self.prop_label.pack(side='left') self.propTax_label = tkinter.Label(self.mid_frame, \ textvariable=self.value) self.propTax_label.pack(side='right') self.top_frame.pack() self.mid_frame.pack() self.third_frame.pack() self.bottom_frame.pack() tkinter.mainloop() def calculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) self.value.set(assessVal) def taxCalculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) assessTax = str(format(float(((.64)*assessVal)), '.2f')) self.value.set(assessTax) my_gui = PropertyTaxGUI() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload