I would like to display my graph by clicking the button "Most Active Author" and "Most Active Day" on the #WhatsApp Analyser page 2 user interface. However when I click the buttons, the graphs seem to appear on my first GUI which is #WhatsApp Analyser page 1. How can I solve this problem?
#WhatsApp Analyser page 2
def main():
# Creating the window
window = Tk()
# getting screen width and height of display
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
# setting tkinter window size
window.geometry("%dx%d" % (width, height))
window.title('WhatsApp Analyser page 2')
window.configure(bg='blue')
# Creating a Label
houseLabel = Label(window, text="WhatsApp Analyser", font=('Arial', 15))
houseLabel.place(x=700, y=20)
trainingA_button = Button(window, text=" MOST ACTIVE AUTHOR", height=2, width=35, command=ACTIVE_DAY, fg='blue')
trainingA_button.place(x=30, y=130)
trainingM_button = Button(window, text=" MOST ACTIVE DAY", height=2, width=35, command=ACTIVE_AUTHOR, fg='red')
trainingM_button.place(x=30, y=180)
testingA_button = Button(window, text="RETURN", height=2, width=35, command=root.withdraw, fg='black')
testingA_button.place(x=30, y=230)
#WhatsApp Analyser page 1
root = Tk()
root.title("WhatsApp Analyser page 1")
root.geometry("420x230")
root.configure(bg='blue')
root.eval('tk::PlaceWindow . center')
root.resizable(False, False)
redbutton = Button(root, text='Analyse Graphs',
command=main, fg='blue',
height=2, width=35)
redbutton.place(x=88, y=20)
### Mostly Active Author in the Group
def ACTIVE_AUTHOR():
print("MOST ACTIVE USER IN THE GROUP")
A = plt.figure(figsize=(6, 8), dpi=70)
#plt.figure(figsize=(8, 5))
mostly_active = data['sender'].value_counts()
### Top 10 peoples that are mostly active in our Group is :
m_a = mostly_active.head(10)
bars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
x_pos = np.arange(len(bars))
m_a.plot.bar()
plt.xlabel('Sender', fontdict={'fontsize': 14, 'fontweight': 10})
plt.ylabel('No. of messages', fontdict={'fontsize': 14, 'fontweight': 10})
plt.title('Mostly active user in the Group', fontdict={'fontsize': 20, 'fontweight': 8})
plt.xticks(x_pos, bars)
#plt.show()
canvas = FigureCanvasTkAgg(A)
canvas.draw()
canvas.get_tk_widget().place(x=350,y=60)
print("")
#### Mostly Active day in the Group
def ACTIVE_DAY():
print("MOST ACTIVE DAY IN THE GROUP")
B = plt.figure(figsize=(6,8), dpi=70)
#plt.figure(figsize=(8, 5))
active_day = data['Day'].value_counts()
### Top 10 peoples that are mostly active in our Group is :
a_d = active_day.head(10)
a_d.plot.bar()
plt.xlabel('Day', fontdict={'fontsize': 12, 'fontweight': 10})
plt.ylabel('No. of messages', fontdict={'fontsize': 12, 'fontweight': 10})
plt.title('Mostly active day of Week in the Group', fontdict={'fontsize': 18, 'fontweight': 8})
#plt.show()
canvas = FigureCanvasTkAgg(B)
canvas.draw()
canvas.get_tk_widget().place(x=780,y=60)
root.mainloop()