title: Functions all running when class is called (tkinter)
body: <p>I am currently building an application in Tkinter, and have been putting the different pages into classes to make them easier to manage. But I have been having this problem, when I call the function I want i.e. <code>l.LoginPage(window).login(window)</code> it will automatically run the function that is meant to be triggered when the button is pressed.</p>
  <p>Please see the code bellow:</p>
  <pre><code>from tkinter import *
  import requests
  import socket
  from PIL import Image, ImageTk
  import time
  
  
  class LoginPage:
      def __init__(self, window):
          window.geometry(&quot;500x430&quot;)
          self.page = Frame(window)
          self.logo = PhotoImage(file=&quot;images\TheQALifeLogo.pgm&quot;)
  
          self.change_to = &quot;&quot;
          self.image = Label(window, image=self.logo, bg=&quot;black&quot;)
          self.text_entry_username = Entry(window, width=50, bg=&quot;white&quot;)
          self.text_entry_password = Entry(window, width=50, bg=&quot;white&quot;)
          self.Username_Label = Label(window, text=&quot;Username&quot;, bg=&quot;black&quot;, fg=&quot;white&quot;, font=&quot;none 12 bold&quot;)
          self.Password_Label = Label(window, text=&quot;Password&quot;, bg=&quot;black&quot;, fg=&quot;white&quot;, font=&quot;none 12 bold&quot;)
          self.Submit_Button = Button(window, text=&quot;SUBMIT&quot;, width=8, command=self.change_home(window))
          self.Create_Account = Button(window, text=&quot;Don't have an account?&quot;, width=18, command=self.change_create(window))
          self.login_result = Text(window, width=35, height=1, wrap=WORD, bg=&quot;black&quot;, fg=&quot;red&quot;, borderwidth=0)
  
      def change_page(self, change_to):
          username = self.text_entry_username.get()
          password = self.text_entry_password.get()
  
          hostname = socket.gethostname()
          ip_address = socket.gethostbyname(hostname)
          url = 'http://localhost:80'
          send_data = &quot;LOGIN&quot; + &quot; &quot; + username + &quot; &quot; + password + &quot; &quot; + ip_address
          print(send_data)
          x = requests.post(url, data=send_data)
          print(x.text)
  
          if x.text == &quot;LOGIN True&quot;:
              print(&quot;We are returning the value TRUE&quot;)
              response = &quot;TRUE&quot;
          elif x.text == &quot;LOGIN False&quot;:
              print(&quot;We are returning the value FALSE&quot;)
              response = &quot;FALSE&quot;
  
          if response == &quot;TRUE&quot;:
              return self.change_to
  
          elif response == &quot;FALSE&quot;:
              self.login_result.delete(0.0, END)
              self.login_result.insert(END, &quot;Username or Password is incorrect&quot;)
  
      def change_home(self, window):
          self.change_to = &quot;home&quot;
          return LoginPage(window).change_page(self.change_to)
  
      def change_create(self, window):
          self.change_to = &quot;create&quot;
          return LoginPage(window).change_page(self.change_to)
  
      def login(self, window):
          window.configure(background=&quot;black&quot;)
  
          self.image.pack(side=&quot;top&quot;)
          self.Username_Label.place(x=220, y=260)
          self.Password_Label.place(x=220, y=310)
          self.text_entry_username.place(x=107, y=285)
          self.text_entry_password.place(x=107, y=335)
          self.Submit_Button.place(x=220, y=365)
          self.Create_Account.place(x=185, y=400)
          self.login_result.place(x=107, y=230)
  
          window.mainloop()
  
  
  </code></pre>
  <p>This results in this endless loop of functions calling functions. This is the error message;</p>
  <pre><code>    return LoginPage(window).change_page(self.change_to)
    File &quot;C:\Users\Joshua Waghorn\OneDrive\GUI\loginpage.py&quot;, line 20, in __init__
      self.Submit_Button = Button(window, text=&quot;SUBMIT&quot;, width=8, command=self.change_home(window))
    File &quot;C:\Users\Joshua Waghorn\OneDrive\GUI\loginpage.py&quot;, line 52, in change_home
      return LoginPage(window).change_page(self.change_to)
    File &quot;C:\Users\Joshua Waghorn\OneDrive\GUI\loginpage.py&quot;, line 20, in __init__
      self.Submit_Button = Button(window, text=&quot;SUBMIT&quot;, width=8, command=self.change_home(window))
    File &quot;C:\Users\Joshua Waghorn\OneDrive\GUI\loginpage.py&quot;, line 52, in change_home
      return LoginPage(window).change_page(self.change_to)
  </code></pre>
  <p>(This is only a small portion of the error message, because it keeps on repeating)</p>