0

I've made a GUI from tkinter and are then trying to pass values entered into Entry widgets when a button is pressed to a separate module which is carrying out calculations.

An extract of the separate module calling the input is below:

# Calculation Module
xf = Extract_Inputs(self,'xf')

The function this refers to in the GUI is:

# GUI Module
def Extract_Inputs(self,x):     

      xf_In = float(self.e_xf.get()) 

      if x == 'xf':
          x = xf_In/100 

Where e_xf refers to the Entry widget

This brings up the error: name 'self' is not defined when xf = Extract_Inputs(self,'xf') is used.

How do I go about getting round this without making the first part into a function which I pass self into?

The complete files can be found here: https://github.com/AyrtonB/McCabe-Thiele/tree/master/MT%20v1.2

Ayrton Bourn
  • 365
  • 5
  • 16
  • Simply remove `self` from `xf = Extract_Inputs(self,'xf')`. I think you need to read [this](https://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self) – Billal Begueradj May 30 '17 at 03:45
  • However, `self` is needed for `Extract_Inputs()` as an input so it knows which frame to refer to? – Ayrton Bourn May 30 '17 at 09:47
  • Looking at your full code, `Extract_Inputs(self,x)` is not inside a class therefore the use of `self` is not warranted. – scotty3785 May 30 '17 at 16:48
  • would you recommend just writing values to a .csv file and using that between the two modules or making a class for Extract_Inputs(self,x)? – Ayrton Bourn May 30 '17 at 16:51
  • Make a class. Have a top level class, your application, that refers to an instance of your 'backend' class. Then you might have something inside your application class methods that does something like `self.backend.write(data)` – scotty3785 May 31 '17 at 16:22

0 Answers0