1

How can you increase the size of the button used to access the tab?

I've tried adding padding, changing the font size, and editing height/width, but none of these affect the physical size of the button used to switch tabs.

jrixie
  • 13
  • 4
  • sounds similar to https://stackoverflow.com/questions/36024635/changing-the-tab-sizes-of-a-notebook-widget-in-python-3 – Reedinationer Feb 13 '19 at 23:28
  • When I tried to implement that, it changed the tabs rather than the tab buttons – jrixie Feb 13 '19 at 23:31
  • *"it changed the tabs rather than the tab buttons"*: [Edit] your Question and explain in detail the difference between `tabs` and `tab buttons`? – stovfl Feb 14 '19 at 08:02

1 Answers1

2

Change the style like:

customed_style = ttk.Style()
customed_style.configure('Custom.TNotebook.Tab', padding=[12, 12], font=('Helvetica', 10))

Then use this style to your tab like:

tab_control = ttk.Notebook(self.master, style='Custom.TNotebook')

Here is a full example:

import tkinter as tk
from tkinter import ttk

class MainWindow:
    def __init__(self, master):
        self.master = master
        self.master.title("Large Tab Example")

        self.createTabs()

    def createTabs(self):
        self.tab_control = ttk.Notebook(self.master, style='Custom.TNotebook')

        self.tab_one = ttk.Frame(self.tab_control)
        self.tab_control.add(self.tab_one, text="Tab One")
        self.frame_one = ttk.Frame(self.tab_one)
        self.frame_one.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')
        self.label_one = ttk.Label(self.frame_one, text="Tab One", font=('Helvetica', 24, 'bold'))
        self.label_one.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')

        self.tab_two = ttk.Frame(self.tab_control)
        self.tab_control.add(self.tab_two, text="Tab Two")
        self.frame_two = ttk.Frame(self.tab_two)
        self.frame_two.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')
        self.label_two = ttk.Label(self.frame_two, text="Tab Two", font=('Helvetica', 24, 'bold'))
        self.label_two.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')

        self.tab_three = ttk.Frame(self.tab_control)
        self.tab_control.add(self.tab_three, text="Tab Three")
        self.frame_three = ttk.Frame(self.tab_three)
        self.frame_three.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')
        self.label_three = ttk.Label(self.frame_three, text="Tab Three", font=('Helvetica', 24, 'bold'))
        self.label_three.grid(row=0, column=0, padx=16, pady=16, sticky='nesw')

        self.tab_control.grid(row=0, column=0, sticky='nesw', padx=4, pady=4)

def main():
    root = tk.Tk()

    customed_style = ttk.Style()
    customed_style.configure('Custom.TNotebook.Tab', padding=[12, 12], font=('Helvetica', 10))
    customed_style.configure('Custom.TNotebook', tabposition='wn')

    app = MainWindow(root)
    root.mainloop()

if __name__ == '__main__':
    main()
Nuno André
  • 4,739
  • 1
  • 33
  • 46
Partho63
  • 3,117
  • 2
  • 21
  • 39
  • 2
    That worked perfectly. My problem was misunderstanding the difference between TNotebook.Tab and TNotebook in the Style. Thank you for the help! – jrixie Feb 19 '19 at 01:39