Apr-22-2021, 10:35 AM
Hello everyone :)
While doing my homework I came across the following problem:
We have to develop a GUI with PyQt - this task was not a problem.
The variables come from the QLineEdit and are always the same. Our professor wants us to write
a file named 'vars.py' and import the file into our 'main.py' - now I'm in trouble
Generally it wasn't a problem to import and use vars in other tasks before. But since the vars are coming from the GUI,
I don't know how to handle it. Using the (quoted) variables inside the main.py works perfectly.
I have tried this solution:
main.py
Hope you can understand where the problem is.
Thank you very much in advance :)
While doing my homework I came across the following problem:
We have to develop a GUI with PyQt - this task was not a problem.
The variables come from the QLineEdit and are always the same. Our professor wants us to write
a file named 'vars.py' and import the file into our 'main.py' - now I'm in trouble



Generally it wasn't a problem to import and use vars in other tasks before. But since the vars are coming from the GUI,
I don't know how to handle it. Using the (quoted) variables inside the main.py works perfectly.
I have tried this solution:
main.py
from vars import Incoming # more code def ShowStock(self): """sep = "-" vendor = self.inhersteller.text().upper() size = self.ingr.text().upper() quant = self.inanz.text() extension = ".hand" directory = "base" filename = vendor + "." + size + extension savefolder = os.path.join(directory, filename) """ Incoming(self) if not vendor or not size: Empty() else: if not os.path.isfile(savefolder): NoFile() else: # much more codevars.py
def Incoming(self): sep = "-" vendor = self.inhersteller.text().upper() size = self.ingr.text().upper() quant = self.inanz.text() extension = ".hand" directory = "base" filename = vendor + "." + size + extension savefolder = os.path.join(directory, filename)Error message is: builtins.NameError: name 'vendor' is not defined
Hope you can understand where the problem is.
Thank you very much in advance :)