0

I am creating a login form in which the user enters their customer ID and forename to login. I need to use the customer ID that is entered in this form in another file. Here is my code for the first file (the login form)

def customer_login():
    global CustomerID, Forename
    master = Tk()
    Label(master, text="Customer Login", fg='black', bg='turquoise', font=('comicsans', 14)).grid(row=0)
    Label(master, text="Please enter your Customer ID", fg='black', bg='turquoise', font=('comicsans', 12)).grid(row=1)
    Label(master, text="Please enter your forename", fg='black', bg='turquoise', font=('comicsans', 12)).grid(row=2)

    CustomerID = Entry(master)
    Forename = Entry(master)

    CustomerID.grid(row=1, column=1)
    Forename.grid(row=2, column=1)
    CustomerIDSave=CustomerID.get()

I then need to use the CustomerIDSave variable in another. I tried to import the file as a module but this didn't work. Any ideas on what I could do? I can't have the program all in one large file, as it would be far too big.

martineau
  • 119,623
  • 25
  • 170
  • 301
brenda
  • 73
  • 1
  • 2
  • 9
  • 1
    Indent your code properly – Mohammad Yusuf Jan 11 '17 at 17:17
  • 1
    Possible duplicate of [Importing variables from another file (python)](http://stackoverflow.com/questions/17255737/importing-variables-from-another-file-python) – bouletta Jan 11 '17 at 17:18
  • in this function you should use `return CustomerIDSave` and `result = custom_login()`. And after you import another file you should use `another_file.another_function(result)` – furas Jan 11 '17 at 17:37
  • okay thanks! I will try that, but what do you mean by the last bit? – brenda Jan 11 '17 at 17:41

1 Answers1

0

from yourfilename import *, and this will import all methods and objects.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 1
    PEP8 discourages wildcard imports. – Bryan Oakley Jan 11 '17 at 17:26
  • Wildcard imports work, but are not good code practice. It's too hard for people reading your code to understand where a particular imported variable comes from. You should always make your imports explicit when possible. – JCC Jan 11 '17 at 17:40