Reputation: 1
it doesn't work i want it to get a number then click those button bellow and then get the result in the message box what should i do?!
from tkinter import *
from tkinter import messagebox
from tkinter import ttk
win=Tk()
#here is my problem
def household():
global s
global math
math="multiply"
x=int(E.get())
s=(x/100)*500
b="your bill is:"+str(s)
messagebox.showinfo("result",b)
def commercial():
global s
x=int(E.get())
if x<=4000000:
s=(x/100)*750
household()
commercial()
E=Entry(win,bg="#87CEFA")
b1=Button(win,text="Household",bg="#4169E1",command=household)
b3=Button(win,text="commercial",bg="#4169E1",command=commercial)
E.place(x=100,y=85,width=100,height=20)
b1.place(x=100,y=165,width=100,height=30)
b3.place(x=150,y=165,width=100,height=30)
Upvotes: 0
Views: 144
Reputation: 386295
You're calling household()
and commercial()
before you define E. Because you are doing a wildcard import (from tkinter import *
) you're importing the constant E
from tkinter, which is defined as the string "e".
The solution is:
import tkinter as tk
and then use tk.
as a prefix for all tkinter objects (tk.Entry(...)
, tk.Button(...)
, etc)Upvotes: 2