Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
self def
#3
You have a few things happening.

One is that on line42 you've passed in the command as graph. But the graph name is for your class. If you want to call the method, that would begraph.graph. But the method expects an instance passed in as self, so you can't call the method directly.

You could create an instance and then pass the method of that instance as your command:
g_obj = graph(a_entry.get(), b_entry.get())
 
graph_button = Button(root, text="Graph", command=g_obj.graph)
The call would work, but the problem now is that the values are read only at object initialization time, before the values in the label widgets are populated. So you'd need to get the object to read the values at a later point. Perhaps instead of passing in the current value of the widgets, pass in the widgets themselves. Then at graph time, you can read the current state of the label widgets.
Reply


Messages In This Thread
self def - by Agusben - May-05-2020, 05:28 AM
RE: self def - by Larz60+ - May-05-2020, 06:05 AM
RE: self def - by bowlofred - May-05-2020, 06:11 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020