Bottom Page

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()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Adding space between Notebook tabs Columbo 4 264 Jul-10-2019, 10:46 PM
Last Post: Columbo
  [Tkinter] How to create multilple tabs in tkinter from different classes Rishav 5 7,458 Jul-11-2018, 11:59 AM
Last Post: CCChris91
  Code fails on Mac, works on Windows and Raspberry Pi eugenedakin 4 998 May-30-2018, 03:49 AM
Last Post: eugenedakin
  How to create mutiple tabs in tkinter using oops Rishav 2 2,350 Jul-12-2017, 04:43 PM
Last Post: Rishav
  [Tkinter] Tkinter GUI works on Windows but not on Ubuntu danbei 8 3,658 Jun-27-2017, 08:03 PM
Last Post: danbei
  user name and password GUI works (almost) Luke_Drillbrain 3 1,423 Apr-23-2017, 05:56 AM
Last Post: Barrowman

Forum Jump:


Users browsing this thread: 1 Guest(s)