ParthJadhav / Tkinter-Designer

An easy and fast way to create a Python GUI 🐍
BSD 3-Clause "New" or "Revised" License
8.87k stars 817 forks source link

Is it possible to support tabs #242

Closed ascitegong closed 1 year ago

ascitegong commented 2 years ago

Many thanks for the fantastic project. Is it possible to support creating Tabs?

HackingAllYT commented 2 years ago

Hello @ascitegong

I'm afraid this repo can not suppor tabs, but if you want to create tabs for TabPane (or NoteBook) you can easily insert them with the code generated using this tool.

Small example:

class Master(tk.Frame):

    def __init__(self, parent, controller, *args, **kwargs):
        tk.Frame.__init__(self, parent, background='#FFFFFF')

        self.controller = controller
        self.pageTwoFrames = []

        self.notebook = ttk.Notebook(self, *args, **kwargs)
        self.notebook.place(
            x=0.0,
            y=60.0,
            width=1024.0,
            height=660.0
        )

        self.canvas = Canvas(
            self,
            bg="#FFFFFF",
            height=55,
            width=1024,
            bd=0,
            highlightthickness=0,
            relief="ridge"
        )
        # You can call this function outside init of the class 
        self.addFrame(PaneForNotebook, 'Example - 0 ')

    def addFrame(self, frameType, name: str):
        self.aux = frameType(self.notebook, self.controller, self)
        self.pageTwoFrames.append(self.aux)
        self.notebook.add(self.aux, text=name, padding=5)
        self.notebook.place(
            x=0.0,
            y=60.0,
            width=1024.0,
            height=699.0
        )
        self.notebook.select(self.aux)

class PaneForNotebook(tk.Frame):

    def __init__(self, parent, controller, classParent):
        tk.Frame.__init__(self, parent)

        self.controller = controller
        self.parent = parent
        self.classParent = classParent

        self.canvas = Canvas(
            self,
            bg="#FFFFFF",
            height=650,
            width=1024,
            bd=0,
            highlightthickness=0,
            relief="ridge"
        )

class AnotherPaneForNotebook(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        # Your code below

Any extra help ask for it, HackingAll

ParthJadhav commented 1 year ago

Thanks @HackingAllYT for the help. I'll close this issue @ascitegong