Python Forum
[Tkinter] How to get a tabs works exactly same as google chrome
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to get a tabs works exactly same as google chrome
#1
In this GUI i have already used tabs(tkinter notebook) but what i need is that the whole window comes under a single tab and when i press new button then a new tab will open and the whole different functionality can be done in that tab.And again when i click new button the same thing will happen with new tab.
In short i need the functionality like google chrome or any other browser which have tabs.

import tkinter as tk
from tkinter import ttk
from PIL import ImageTk, Image

main = tk.Tk()
main.resizable(False , False)
main.attributes('-fullscreen', True)
main.configure(background="#253042")
rows=0
style=ttk.Style()
style.theme_create( "body", parent="alt", settings={
        "TNotebook": {"configure": {"tabmargins": [7, 5, 2, 0] , "background": "#253042" }},
        "TNotebook.Tab": {
            "configure": {"padding": [5, 1], "background": "#253042" , "foreground":"white"},
            "map":       {"background": [("selected", "black")],
                          "expand": [("selected", [2, 3, 3, 0])] }
                        },
        "TProgressbar":{"configure": {"background": "orange" , "troughcolor":"#253042","borderwidth":"5"}}
                                                    }
        )

style.theme_use("body")
while rows < 50:
    main.rowconfigure(rows,weight=1)
    main.columnconfigure(rows,weight=1)
    rows+=1
ttk.Style().configure('My.TFrame',background="#253042")
tab = ttk.Notebook(main)
tab.grid(row=2,column = 0,columnspan = 50,rowspan = 49,sticky='NESW')
tab1 = ttk.Frame(tab,style='My.TFrame')
tab.add(tab1,text='Tab1')

def new():
    tab2 = ttk.Frame(tab,style='My.TFrame')
    tab.add(tab2,text='New Tab')
    

nb = ttk.Notebook(tab1)
tk.Button(main,text="New",background='black',foreground='white',command=new).grid(row=0,column = 46,padx=2,pady=0,sticky='NESW')
tk.Button(main,text="Load",background='black',foreground='white').grid(row=0,column = 47,padx=(1,10),pady=0,sticky='NESW')
tk.Button(main,text="-",command=main.iconify,background='black',foreground='white').grid(row=0,column = 48,padx=0,pady=0,sticky='NESW')
tk.Button(main,text="X",command=main.destroy,background='black',foreground='white').grid(row=0,column = 49,padx=0,pady=0,sticky='NESW')
nb.grid(row=0,column = 0,columnspan = 50,rowspan = 49,sticky='NESW')

page1 = ttk.Frame(nb,style='My.TFrame')
nb.add(page1,text='Scanning')

rows=0
while rows < 50:
    tab1.rowconfigure(rows,weight=1)
    tab1.columnconfigure(rows,weight=1)
    rows+=1

page2 = ttk.Frame(nb,style='My.TFrame')
nb.add(page2,text='Imagine')

page3 = ttk.Frame(nb,style='My.TFrame')
nb.add(page3,text='Impurity')

page4 = ttk.Frame(nb,style='My.TFrame')
nb.add(page4,text='Marking')

main.mainloop()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Found buttonstate in tabs MacTommu 4 1,983 Sep-22-2021, 05:56 PM
Last Post: deanhystad
  TabError: inconsistent use of tabs and spaces in indentation hobbyist 3 4,881 Jun-15-2021, 10:38 PM
Last Post: davide73_italy
  [Tkinter] Vertical Tabs Alignment in Tkinter muhammadasim 2 5,979 Oct-05-2020, 08:40 AM
Last Post: Larz60+
  [Tkinter] Need help please properly putting tabs within a PanedWindow JackMack118 2 3,336 Dec-08-2019, 03:02 PM
Last Post: balenaucigasa
  Best GUI solution for embedded Chrome Ximera 4 3,433 Nov-13-2019, 01:25 PM
Last Post: Axel_Erfurt
  [PyQt] Drag items across tabs Alfalfa 5 4,748 Sep-01-2019, 11:58 PM
Last Post: Alfalfa
  [Tkinter] Adding space between Notebook tabs Columbo 4 4,499 Jul-10-2019, 10:46 PM
Last Post: Columbo
  [Tkinter] How to create multilple tabs in tkinter from different classes Rishav 5 18,253 Jul-11-2018, 11:59 AM
Last Post: CCChris91
  How to create mutiple tabs in tkinter using oops Rishav 2 6,852 Jul-12-2017, 04:43 PM
Last Post: Rishav

Forum Jump:

User Panel Messages

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