#๐Ÿ”’ How do I call this function for another class?

18 messages ยท Page 1 of 1 (latest)

elfin pecan
#

This is a simple calculator i made for simulating entity movement in minecraft (the functions are all working, I just need to call the function and insert values into the table)

I want to call the calc_function and insert values into the treeview that i created in Right.table(). How do I do this? I couldn't figure out for my life how to do this across classes

I hope I have selected the right tags

hazy tulipBOT
#

@elfin pecan

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

scenic flame
elfin pecan
scenic flame
#

yes, pretty much. Your calc_function accepts a Treeview as its parameter, so you just need to access whatever you named the Treeview in your Right class from an instance

#
right = Right()

calc_function(right.tree_table)
#

I don't know all the details of your classes, but it would be roughly like this

elfin pecan
#

or is there a way to global the function?

#

and I put the calc function inside the right class and then call it from left class

#

basically like this instead

#

and call the calc_function (which is in the Right class) from the Left class

scenic flame
#

you would ideally put the calc_function inside the Calculate class

#

then do self.calc_function(self.right.results) from the calc class

elfin pecan
#

oh wow, it works! thanks so much!!!

#

!close

hazy tulipBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.