Python Forum
[Tkinter] Troubles with accessing attr from other class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Troubles with accessing attr from other class
#2
You should only use Comments_Tab when creating an instance of Comments_Tab. Comments_Tab does not have any class or static resources, so everything should be called/referenced using an instance.

test_button = Button(self, text="Show Data", command=lambda: Comments_Tab.test(self))
should be
test_button = Button(self, text="Show Data", command=self.test)
def test(self):
        Comments_Tab(self).historical_entry_market.insert(0, "asd")
should be
def test(self):
        self.historical_entry_market.insert(0, "asd")
Why are you doing this
        page1 = Rents_Tab(self.notebook)
        self.notebook.add(page1, text="Rents")
        page2 = Comments_Tab(self.notebook)
        self.notebook.add(page2, text="Comments")
instead of this?
        self.notebook.add(Rents_Tab(self.notebook), text="Rents")
        self.notebook.add(Comments_Tab(self.notebook), text="Comments")
Or better yet add the pages in the tab classes:
# in main.py
        Rents_Tab(self.notebook, "Rents")
        Comments_Tab(self.notebook, "Comments")

#in comments.py
class Comments_Tab(tk.Frame):
    def __init__(self, parent, title, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        parent.add(self, text=title)
Reply


Messages In This Thread
RE: [Tkinter] Troubles with accessing attr from other class - by deanhystad - Aug-20-2020, 11:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Using Tkinter With Concurrent.Futures / ThreadPoolExecutor Class AaronCatolico1 1 1,491 Dec-14-2022, 08:01 PM
Last Post: deanhystad
Lightbulb [Tkinter] Tkinter Class Import Module Issue AaronCatolico1 6 3,155 Sep-06-2022, 03:37 PM
Last Post: AaronCatolico1
  [Tkinter] Redirecting all print statements from all functions inside a class to Tkinter Anan 1 2,669 Apr-24-2021, 08:57 AM
Last Post: ndc85430
  tkinter moving an class object with keybinds gr3yali3n 5 3,303 Feb-10-2021, 09:13 PM
Last Post: deanhystad
  [Tkinter] Use function from other class (Tkinter) zarize 8 4,877 Aug-17-2020, 09:47 AM
Last Post: zarize
  Unable fetch fucntion data in class in tkinter jenkins43 2 3,903 Nov-30-2019, 09:47 PM
Last Post: jenkins43
  Tkinter Class pythonenthusiast2 1 2,649 Nov-24-2019, 03:51 AM
Last Post: Larz60+
  tkinter button not accessing the command when clicked jhf2 1 3,600 Nov-23-2019, 10:17 PM
Last Post: DT2000
  Tkinter Gui ScrolledText Insert From Different Class whisperquiet 1 4,349 Jan-08-2019, 09:25 PM
Last Post: Larz60+
  Using a class to create instances of Tkinter Toplevel() windows nortski 2 11,020 Mar-27-2018, 11:44 AM
Last Post: nortski

Forum Jump:

User Panel Messages

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