Aug-20-2020, 07:35 AM
Hi Guys,
I would like to make a "big button" which would load data in several tabs in my app.
In order to do this, i wanted create a function which would load 2nd part of the data, however, i can't access it.. i don't know why.
There is no problem to call the function, in that particular way it is working, but i would like to access it from other tab and then i can't make it.
Below are the codes for files
MAIN.py
I would like to make a "big button" which would load data in several tabs in my app.
In order to do this, i wanted create a function which would load 2nd part of the data, however, i can't access it.. i don't know why.
There is no problem to call the function, in that particular way it is working, but i would like to access it from other tab and then i can't make it.
def test(self):
self.historical_entry_market.insert(0, "asd")I tried to run: def test(self):
Comments_Tab(self).historical_entry_market.insert(0, "asd")However it is not working..Below are the codes for files
MAIN.py
import tkinter as tk
from tkinter.ttk import *
import pandas as pd
from rents import Rents_Tab
from comments import Comments_Tab
class MainApplication(tk.Frame):
def __init__(self, parent, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
self.parent.geometry("700x700")
self.notebook = Notebook(self)
self.notebook.pack(fill="both", expand=True)
#Tab name
page1 = Rents_Tab(self.notebook)
self.notebook.add(page1, text="Rents")
page2 = Comments_Tab(self.notebook)
self.notebook.add(page2, text="Comments")
if __name__ == "__main__":
root = tk.Tk()
MainApplication(root).pack(side="top", fill="both", expand=True)
root.mainloop()comments.pyimport tkinter as tk
from tkinter.ttk import *
import pandas as pd
class Comments_Tab(tk.Frame):
def __init__(self, parent, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
#Headers
self.header = Label(self, text="New Cycle(Current) ")
self.header.grid(row=0, column=2)
self.entry_label_market = Label(self, text="Market Trend: ")
self.entry_label_market.grid(row=1, column=1)
self.entry_market = Entry(self, width=30)
self.entry_market.grid(row=1, column=2)
self.entry_label_location = Label(self, text="Trend: ")
self.entry_label_location.grid(row=2, column=1)
self.entry_location = Entry(self, width=30)
self.entry_location.grid(row=2, column=2)
self.entry_label_survey = Label(self, text="Sources: ")
self.entry_label_survey.grid(row=3, column=1)
self.entry_survey = Entry(self, width=30)
self.entry_survey.grid(row=3, column=2)
### Historical Data
#Headers
self.historical_header = Label(self, text="Historical ")
self.historical_header.grid(row=0, column=3)
#Labels
self.historical_entry_market = Entry(self, width=30)
self.historical_entry_market.grid(row=1, column=3)
self.historical_entry_location = Entry(self, width=30)
self.historical_entry_location.grid(row=2, column=3)
self.historical_entry_survey = Entry(self, width=30)
self.historical_entry_survey.grid(row=3, column=3)
#Buttons
test_button = Button(self, text="Show Data", command=lambda: Comments_Tab.test(self))
test_button.grid(row=5, column=3)
def test(self):
Comments_Tab(self).historical_entry_market.insert(0, "asd")
