Python Forum
AttributeError: '_tkinter.tkapp' object has no attribute 'username'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: '_tkinter.tkapp' object has no attribute 'username'
#4
Still too late, You must assign username before making all the frames.
        self.frames = {}
        for F in (home, register, login, menu, store, retrieve):
            page_name = F.__name__
            frame = F(parent=container, controller=self)    # <-- Error happens here
            self.frames[page_name] = frame
            frame.grid(row=0, column=0, sticky="nsew")
 
        self.show_frame("home")  
        self.bind('<Escape>', lambda x: self.destroy())
        global username       # <-- This does nothing
        self.username = ""    # <-- You don't assign value to username until here
Thinking is required when programming. You get an error saying that the object does not have an attributed named "username", but obviously the class assigns an instance variable of that name. How is this possible? What sequence of events can result in getting this error? Sit down and look carefully at your code, focusing on where the error is reported and where you are assigning a value to "username". You are doing this:
x = username
username = "a name"
Here the problem is clear. Through careful analysis you can make the problem in your program just as clear. It just requires some thought.
Konstantin23 likes this post
Reply


Messages In This Thread
RE: AttributeError: '_tkinter.tkapp' object has no attribute 'username' - by deanhystad - Aug-04-2023, 11:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 897 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,699 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 846 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,305 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 845 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,107 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,627 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 6,071 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  Hiding username and password on sql tantony 10 3,162 Oct-21-2022, 07:58 PM
Last Post: wavic
  Pulling username from Tuple pajd 21 3,774 Oct-07-2022, 01:33 PM
Last Post: pajd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020