Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:57:55+00:00 2026-06-04T02:57:55+00:00

I’m trying create a gui using Tkinter that grabs a username and password and

  • 0

I’m trying create a gui using Tkinter that grabs a username and password and connects to a remote server and does a function. I slapped together some messy code and it more or less worked, but when I tried to recreate it in a tidy module, it broke. Its probably a newbie python error, but I can’t spot it. EDIT: to clarify, when it worked, the only class was setupGui and any methods were under that class. Now that I’ve separated the gui from the methods, its not working.

class setupGui(object):
   def __init__(self, parent):
      ##omited general frame stuff 

       self.userIn = ttk.Entry(self.topFrame, width = 20)
       self.userIn.grid(row = 1, column = 1)
       self.passIn = ttk.Entry(self.topFrame, width = 20, show ="*")
       self.passIn.grid(row = 2, column = 1)

       #Buttons
       self.setupbtn = ttk.Button(self.topFrame, text = "Start Setup", command = setup().startSetup())
       self.setupbtn.grid(row = 3, column = 0, pady = 10)

class setup(object):
   def__init__(self):
      self.userName = setupGui.userIn.get()
      self.userPass = setupGui.passIn.get()
   def startSetup(self):
      self.another_related_fucntion # about 4 related functions actually

if __name__ == '__main__':
root = Tk()
gui = setupGui(root)
root.mainloop()

And if I don’t have the command attached to the button, everything works fine (but obviously does diddly squat except look pretty). And when I attached the command, I get this error:

Traceback (most recent call last):
 File "macSetup.py", line 211, in <module>
 gui = setupGui(root)
 File "macSetup.py", line 45, in __init__
self.setupbtn = ttk.Button(self.topFrame, text = "Start Setup", command = setup().startSetup())
File "macSetup.py", line 69, in __init__
self.userName = setupGui.userIn.get()
AttributeError: type object 'setupGui' has no attribute 'userIn'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:57:58+00:00Added an answer on June 4, 2026 at 2:57 am

    In your code, userIn is set up as an instance variable of setupGui objects, not as an attribute of the setupGui class itself.

    The simplest solution would be to merge the setupGui and setup classes to move startSetup in as a method of setupGui, then use command=self.startSetup when you initialize setupbtn—this calls startSetup as a bound method, and self should thus refer to the setupGui object, which you can then use e.g. self.userIn.get() and self.passIn.get() on.

    If you’d rather keep the logic you have in the setup class out of the setupGui class, you can separate it out like this:

    class setup(object):
        def __init__(self, username, userpass):
            self.userName = username
            self.userPass = userpass
    
        def startSetup(self):
            # as before
    

    then add this method to the setupGui class:

    def dosetup(self):
        setup(self.userIn.get(), self.passIn.get()).startSetup()
    

    and instantiate the Button with command=self.dosetup. (I would personally make the setup class a standalone function, but I don’t know how complicated your startSetup routine actually is, so I assume you have a good reason for making it a class.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.