Python Forum
Tkinter object scope
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter object scope
#4
Thank you so much for the very quick reply. As soon as I saw it, I knew, "I should have thought of that", but I didn't Shy Now to the bad news...
I made those changes but still have the same problem.

The error is:
  File "D:\Projects\Pycharm\DSAFinalProject\EnterBook.py", line 27, in SaveBook
    book = Book(self.entBookTitle.get(), self.entBookISBN.get(), self.entBookAuthor.get(), self.entBookYear.get())
                ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
What am I missing?


My updated code:

from tkinter import *
from tkinter import ttk
from Book import *

class EnterBookWindow(Toplevel):

    def __init__(self):
        Toplevel.__init__(self)
        self.title("Enter a Book in xx Data Structure")
        self.geometry('400x400')
        frameLeft = Frame(self, width=40, padx=20, pady=20)
        frameLeft.pack(side=LEFT)
        frameRight = Frame(self, width=40, padx=20, pady=20)
        frameRight.pack(side=RIGHT)

        lblTitle = ttk.Label(frameRight, text="Title:").pack(padx=10, pady=0)
        self.entBookTitle = ttk.Entry(frameRight, font=('Helvetica', 12), width=20).pack(padx=10, pady=10)
        lblISBN = ttk.Label(frameRight, text="ISBN:").pack(padx=10, pady=0)
        self.entBookISBN = ttk.Entry(frameRight, font=('Helvetica', 12), width=20).pack(padx=10, pady=10)
        lblAuthor = ttk.Label(frameRight, text="Author:").pack(padx=10, pady=0)
        self.entBookAuthor = ttk.Entry(frameRight, font=('Helvetica', 12), width=20).pack(padx=10, pady=10)
        lblYear = ttk.Label(frameRight, text="Year:").pack(padx=10, pady=0)
        self.entBookYear = ttk.Entry(frameRight, font=('Helvetica', 12), width=20).pack(padx=10, pady=10)
        btnSave = ttk.Button(frameRight, text="Save Data", command=self.SaveBook).pack(padx=20, pady=10)

    def SaveBook(self):
        book = Book(self.entBookTitle.get(), self.entBookISBN.get(), self.entBookAuthor.get(), self.entBookYear.get())
Reply


Messages In This Thread
Tkinter object scope - by riversr54 - Feb-16-2023, 07:40 PM
RE: Tkinter object scope - by riversr54 - Feb-16-2023, 07:41 PM
RE: Tkinter object scope - by Gribouillis - Feb-16-2023, 07:55 PM
RE: Tkinter object scope - by riversr54 - Feb-16-2023, 08:14 PM
RE: Tkinter object scope - by Gribouillis - Feb-16-2023, 08:54 PM
RE: Tkinter object scope - by riversr54 - Feb-16-2023, 09:19 PM
RE: Tkinter object scope - by deanhystad - Feb-17-2023, 05:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter AttributeError: 'GUI' object has no attribute pfdjhfuys 3 1,719 May-18-2023, 03:30 PM
Last Post: pfdjhfuys
  Key Binding scope angus1964 1 1,266 Jun-30-2022, 08:17 PM
Last Post: deanhystad
  tkinter moving an class object with keybinds gr3yali3n 5 3,404 Feb-10-2021, 09:13 PM
Last Post: deanhystad
  Scope of variable when using two classes AyJay 2 2,226 Jan-23-2020, 10:09 AM
Last Post: AyJay

Forum Jump:

User Panel Messages

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