'Having issue in tkinter calling another class

I am working on python exe application, I made a single class and methods inside single class, application working perfectly but when to add new implements track the code and implementing becomes clumsy so can any one give idea

My initial code presently working is:

from tkinter import *
from ttkthemes import themed_tk as tk
import tkinter as tkn

class Main_page:
    """Main Window this is configuration that exist when opens"""

    def __init__(self, window):

        # aligning the window details
        self.window = window
        self.window.geometry("1366x768+0+0")
        self.window.title("Admin Page")
        self.window.config(bg="gray")

        # window assigning to full screen
        self.window.attributes("-fullscreen", True)
        self.window.bind('<Escape>', lambda event: self.window.attributes("-fullscreen", False))
        self.window.bind('<F11>', lambda event: self.window.attributes("-fullscreen", True))

        self.m_top_fra()
        self.m_lef_fra()
        self.m_body_fra()

    def m_top_fra(self):
        """This is top Frame in exist on all pages"""
        m_top_frame = Frame(self.window, height=70, width=1340)
        m_top_frame.place(x=10, y=10)

    def m_lef_fra(self):
        """This is side frame where the main handling buttons are placed
        as billing, transaction details , settings"""

        m_lef_frame = Frame(self.window, height=610, width=125, borderwidth=0)
        m_lef_frame.place(x=10, y=85)

        # Billing Button for left side
        m_billing_but = Button(m_lef_frame, text="Billing", width=10, height=5, bg="#C6C1B9",
                               command=self.b_billing_page)
        m_billing_but.place(x=25, y=20)

        # manage Button for left side
        m_manage_but = Button(m_lef_frame, text="Bill \n Manage", width=10, height=5, bg="#C6C1B9",
                              command=self.bm_bill_manage)
        m_manage_but.place(x=25, y=140)
        # view Button for left side
        m_view_but = Button(m_lef_frame, text=" All\n View", width=10, height=5, bg="#C6C1B9",
                            command=self.v_view_page)
        m_view_but.place(x=25, y=260)

        # transactions Button for left side
        m_transactions_but = Button(m_lef_frame, text="Transactions \n Settings", width=10, height=5, bg="#C6C1B9",
                                    command=self.t_transaction_page)
        m_transactions_but.place(x=25, y=380)

        # exit Button for left side
        m_exit_but = Button(m_lef_frame, text="Exit", width=10, height=5, bg="#C6C1B9",
                            command=self.exit_window)
        m_exit_but.place(x=25, y=500)

    def m_body_fra(self):
        """This is body frame where the initial info handles"""
        self.body_frame = Frame(self.window, width=1210, height=610, bg="white")
        self.body_frame.place(x=140, y=85)

    # ________________Billing_____________

    def b_billing_page(self):
        """when billing button is selected , the initial view of the page is opened"""

        # this is for body frame to create the data in it
        self.body_frame = Frame(self.window, width=1210, height=610, bg="#d4cfcf")
        self.body_frame.place(x=140, y=85)

        # top frame for some values to place
        self.b_billing_top_frame = Frame(self.body_frame, width=1190, height=30)
        self.b_billing_top_frame.place(x=10, y=10)

        # body frame for the another wides
        self.b_billing_body_frame = Frame(self.body_frame, width=1190, height=550, bg="white")
        self.b_billing_body_frame.place(x=10, y=50)


def win():
    """initial initialization the page to view"""
    master = tk.ThemedTk()
    master.get_themes()
    master.set_theme("clam")
    Main(master)
    master.mainloop()


if __name__ == "__main__":
    win()

Same like billing, manage transactions and bill manager works.

But presently I am working as converting billing, manage, trans to different classes

from tkinter import *
from ttkthemes import themed_tk as tk
import tkinter as tkn


class Main:
    def __init__(self, master):
        self.master = master
        self.master.geometry("1366x768+0+0")
        self.master.title("Admin Page")
        self.master.config(bg="gray")

        # window assigning to full screen
        self.master.attributes("-fullscreen", True)
        self.master.bind('<Escape>', lambda event: self.master.attributes("-fullscreen", False))
        self.master.bind('<F11>', lambda event: self.master.attributes("-fullscreen", True))

        self.top_frame = Frame(self.master, height=70, width=1340)
        self.top_frame.place(x=10, y=10)

        self.lef_frame = Frame(self.master, height=610, width=125, borderwidth=0)
        self.lef_frame.place(x=10, y=85)

        self.body_frame = Frame(self.master, width=1210, height=610, bg="white")
        self.body_frame.place(x=140, y=85)

        self.value_buttons()

    def value_buttons(self):
        m_billing_but = Button(self.lef_frame, text="Billing", width=10, height=5, bg="#C6C1B9")
        m_billing_but.place(x=25, y=20)

        # manage Button for left side
        m_manage_but = Button(self.lef_frame, text="Bill \n Manage", width=10, height=5, bg="#C6C1B9",
                              command=self.billing)
        m_manage_but.place(x=25, y=140)

        # view Button for left side
        m_view_but = Button(self.lef_frame, text=" All\n View", width=10, height=5, bg="#C6C1B9")
        m_view_but.place(x=25, y=260)

        # transactions Button for left side
        m_transactions_but = Button(self.lef_frame, text="Transactions \n Settings", width=10, height=5, bg="#C6C1B9")
        m_transactions_but.place(x=25, y=380)

        # exit Button for left side
        m_exit_but = Button(self.lef_frame, text="Exit", width=10, height=5, bg="#C6C1B9")
        m_exit_but.place(x=25, y=500)

    def billing(self):
        Billing(self.master)


class Billing(Main):
    def __init__(self, master):
        super().__init__(master)
        self.master = master

        print("billing called")

        self.body_frame = Frame(self.master, width=1210, height=610, bg="white")
        self.body_frame.place(x=140, y=85)

        self.b_top_frame = Frame(self.body_frame, width=1190, height=30, bg="gray")
        self.b_top_frame.place(x=10, y=10)

        # body frame for the another wides
        self.b_body_frame = Frame(self.body_frame, width=1190, height=550, bg="Gray")
        self.b_body_frame.place(x=10, y=50)


def win():
    """initial initialization the page to view"""
    master = tk.ThemedTk()
    master.get_themes()
    master.set_theme("clam")
    Main(master)
    master.mainloop()


if __name__ == "__main__":
    win()

In the code shown here, when clicking billing button nothing happening.

Can anyone please help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source