self.pack(fill=BOTH, expand=1)
self.ratio1 = Entry(self, width=30).pack(side=TOP, padx=10, pady=10)
self.doenSom = Button(self, text="Doen Som",
command=self.data_prossesering)
self.doenSom.place(x=155, y=40)
self.uiset = Entry(self, width=20).pack(side=TOP, padx=50, pady=50)
def data_prossesering(self):
e = self.ratio1.get()
e.split()
r1 = float(e[0]) * float(e[1])
r2 = float(e[2]) * float(e[3])
a = r1/r2
return TkmessageBox.showInfo(math.sqrt(a)
root = Tk()
root.geometry("400x300")
app = frame(root)
root.mainloop()the objective of this program is to solve the following mathematical problem: the square root of the answer of 4 cross-multiplied numbers which are separated in pairs and divided by each other. the numbers are entered by the user in a text field, then when the button is clicked the square root appears in another text field below it. however, when i click the button, the following error appears:
Error:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
return self.func(*args)
File "/complete/path/to/file.py", line 42, in data_prossesering
e = self.ratio1.get()
AttributeError: 'NoneType' object has no attribute 'get'
Does anyone know how to fix this?
The grid, pack, and place methods of every Tkinter widget operate in-place and always return None. This means that you cannot call them on the same line as you create a widget. Instead, they should be called on the line below:
self.ratio1 = Entry(self, width=30)
self.ratio1.pack(side=TOP, padx=10, pady=10)
getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY'
EarthAndMoon
2,529
Oct-03-2023, 02:00 PM
Last Post
:
deanhystad
Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att
Melcu54
3,305
Jun-28-2023, 11:13 AM
Last Post
:
Melcu54