title: Python tkinter Entry box and function accessing outside the class
body: <p>I have been searching a lot and I still don't know how you access variables from different classes in python. I have to access the variable inside the class named Forget_PW (variable = user_input_resendCode). Then, I also want a button to access a function outside the class (named OTP). The function (sendingSMS) will get the input from the user in (user_input_resendCode). How can I access the entrybox outside the class and also how can I access the command (function) outside the class? Thank you</p>
  <p>Here is my code.</p>
  <pre><code>**class Forget_PW:**
  def __init__(self, top=None):
      self.background = Label(forget)
      self.background.place(relx=0, rely=0, width=1366, height=768)
      self.bg_img = PhotoImage(file=&quot;./images/bg.png&quot;)
      self.background.configure(image=self.bg_img)
  
      # ============================================
      # Sign-in Form (Admin)
      # ============================================
      self.forgetpw_form = Label(forget)
      self.forgetpw_form.place(relx=0.1, rely=0.190, width=450, height=550)
      self.forgetpw_form_Image = Image.open(&quot;./images/forgetPasswordForm_first.png&quot;)
      forgetpw_form_ImageResized = self.forgetpw_form_Image.resize((450, 550), Image.ANTIALIAS)
      self.forgetpw_form_Image = ImageTk.PhotoImage(forgetpw_form_ImageResized)
      self.forgetpw_form.configure(image=self.forgetpw_form_Image)
  
      # ============================================
      # Logo (Company)
      # ============================================
      self.logo = Label(forget, bg=&quot;black&quot;)
      self.logo.place(relx=0.22, rely=0.05, width=100, height=100)
      self.logo_image = Image.open(&quot;./images/Logo1.png&quot;)
      resized = self.logo_image.resize((100, 100), Image.ANTIALIAS)
      self.logo_image = ImageTk.PhotoImage(resized)
      self.logo.configure(image=self.logo_image)
  
      # ============================================
      # Image Slideshow
      # ============================================
      def start():
          global i, show
          if i &gt;= (len(images) - 1):
              i = 0
              slide_image.config(image=images[i])
          else:
              i = i + 1
              slide_image.configure(image=images[i])
          show = slide_image.after(2000, start)
  
      image1 = Image.open(&quot;./images/milktea4.png&quot;)
      resized1 = image1.resize((650, 800), Image.ANTIALIAS)
      image1 = ImageTk.PhotoImage(resized1)
      image2 = Image.open(&quot;./images/milktea5.jpg&quot;)
      resized2 = image2.resize((650, 800), Image.ANTIALIAS)
      image2 = ImageTk.PhotoImage(resized2)
      image3 = Image.open(&quot;./images/milktea6.jpg&quot;)
      resized3 = image3.resize((650, 800), Image.ANTIALIAS)
      image3 = ImageTk.PhotoImage(resized3)
      # label1.configure(image=new_pic)
  
      # create list of images
      images = [image1, image2, image3]
      # configure the image to the Label
      i = 0
      slide_image = Label(forget, image=images[i])
      slide_image.place(relx=0.56, rely=0, width=650, height=800)
  
      if i &gt;= (len(images) - 1):
          i = 0
          slide_image.config(image=images[i])
      else:
          i = i + 1
          slide_image.configure(image=images[i])
      show = slide_image.after(2000, start)
  
      # ============================================
      # User Input (OTP)
      # ============================================
      **self.user_input_resendcode** = EntryWithPlaceholder(forget, 'Enter Username or Email')
      self.user_input_resendcode.place(relx=0.135, rely=0.477, width=300, height=24)
      self.user_input_resendcode.configure(font=(&quot;Corbel&quot;, 15))
      self.user_input_resendcode.configure(relief=&quot;flat&quot;)
  
  
  **class OTP:**
  def __init__(self, top=None):
      top.geometry(&quot;1366x768&quot;)
      top.resizable(0, 0)
      top.title(&quot;Invoices&quot;)
      # ============================================
      # Yellow background
      # ============================================
      self.background_otp = Label(otp1)
      self.background_otp.place(relx=0, rely=0, width=1366, height=768)
      self.bg_img_otp = PhotoImage(file=&quot;./images/bg.png&quot;)
      self.background_otp.configure(image=self.bg_img_otp)
  
      # ============================================
      # Sign-in Form (Admin)
      # ============================================
      self.forgetpw_form = Label(otp1)
      self.forgetpw_form.place(relx=0.1, rely=0.190, width=450, height=550)
      self.forgetpw_form_Image = Image.open(&quot;./images/forgetPasswordForm.png&quot;)
      forgetpw_form_ImageResized = self.forgetpw_form_Image.resize((450, 550), Image.ANTIALIAS)
      self.forgetpw_form_Image = ImageTk.PhotoImage(forgetpw_form_ImageResized)
      self.forgetpw_form.configure(image=self.forgetpw_form_Image)
  
      # ============================================
      # Logo (Company)
      # ============================================
      self.logo = Label(otp1, bg=&quot;black&quot;)
      self.logo.place(relx=0.22, rely=0.05, width=100, height=100)
      self.logo_image = Image.open(&quot;./images/Logo1.png&quot;)
      resized = self.logo_image.resize((100, 100), Image.ANTIALIAS)
      self.logo_image = ImageTk.PhotoImage(resized)
      self.logo.configure(image=self.logo_image)
  
      # ============================================
      # Image Slideshow
      # ============================================
      def start():
          global i, show
          if i &gt;= (len(images) - 1):
              i = 0
              slide_image.config(image=images[i])
          else:
              i = i + 1
              slide_image.configure(image=images[i])
          show = slide_image.after(2000, start)
  
      image1 = Image.open(&quot;./images/milktea4.png&quot;)
      resized1 = image1.resize((650, 800), Image.ANTIALIAS)
      image1 = ImageTk.PhotoImage(resized1)
      image2 = Image.open(&quot;./images/milktea5.jpg&quot;)
      resized2 = image2.resize((650, 800), Image.ANTIALIAS)
      image2 = ImageTk.PhotoImage(resized2)
      image3 = Image.open(&quot;./images/milktea6.jpg&quot;)
      resized3 = image3.resize((650, 800), Image.ANTIALIAS)
      image3 = ImageTk.PhotoImage(resized3)
      # label1.configure(image=new_pic)
  
      # create list of images
      images = [image1, image2, image3]
      # configure the image to the Label
      i = 0
      slide_image = Label(otp1, image=images[i])
      slide_image.place(relx=0.56, rely=0, width=650, height=800)
  
      if i &gt;= (len(images) - 1):
          i = 0
          slide_image.config(image=images[i])
      else:
          i = i + 1
          slide_image.configure(image=images[i])
      show = slide_image.after(2000, start)
  
      # ============================================
      # User Input (OTP)
      # ============================================
      self.user_input_resendcode1 = EntryWithPlaceholder(otp1, 'Enter OTP')
      self.user_input_resendcode1.place(relx=0.135, rely=0.477, width=300, height=24)
      self.user_input_resendcode1.configure(font=(&quot;Corbel&quot;, 15))
      self.user_input_resendcode1.configure(relief=&quot;flat&quot;)
  
      # ============================================
      # Resend Code Button
      # ============================================
      self.resend_code = Button(otp1)
      self.resend_code.place(relx=0.333, rely=0.550, width=100, height=15)
      self.resend_code.configure(relief=&quot;flat&quot;,
                                  overrelief=&quot;flat&quot;,
                                  activebackground=&quot;white&quot;,
                                  cursor=&quot;hand2&quot;,
                                  bg=&quot;white&quot;,
                                  # foreground=&quot;#ffffff&quot;,
                                  # background=&quot;#ffffff&quot;,
                                  borderwidth=&quot;0&quot;)
      self.resend_code_Image = Image.open(&quot;./images/resendCode.png&quot;)
      resend_code_ImageResized = self.resend_code_Image.resize((100, 15), Image.ANTIALIAS)
      self.resend_code_Image = ImageTk.PhotoImage(resend_code_ImageResized)
      self.resend_code.configure(image=self.resend_code_Image)
      self.resend_code.configure(**command=sendingSMS**)
  
  **def sendingSMS():**
  find_user = &quot;SELECT * FROM employee WHERE username = %s OR email_address = %s&quot;
  **cur.execute(find_user, [user_input_resendcode.get(), user_input_resendcode.get()])**
  results = cur.fetchall()
  if results:
      if results[0][10] == &quot;Admin&quot;:
          client = Client('AC544a74e1519b84282c6d22e90d4dbe12', 'a85d7a3f765b109c3982269961eb6d49')
  
          client.messages.create(from_='+19546211198', to=results[0][3], body=&quot;Your OTP is:&quot; + otp)
  
          messagebox.showinfo(&quot;info&quot;, &quot;OTP sent to your registered mobile number&quot;)
  
      else:
          messagebox.showerror(&quot;Oops!!&quot;, &quot;You are not an admin.&quot;)
  
  else:
      messagebox.showerror(&quot;Error&quot;, &quot;Incorrect username or password.&quot;)
      
  </code></pre>