1

As you know, tkinter ttk.Notebook tabs stays on frames and left to right. But I want to organize tabs on the left side of frames and orientation of tab headers from bottom to up. Is there a way to change orientation of tabs?

Fatih1923
  • 2,665
  • 3
  • 21
  • 28
  • Related: http://stackoverflow.com/q/20822553/3001761 – jonrsharpe Dec 02 '14 at 14:01
  • That is good. But I actually want bottom-up version of this. Thanks for comment – Fatih1923 Dec 02 '14 at 14:38
  • idlelib/tabbedpages.py, written years ago, defines, with python tkinter code, a notebook widget. It is used in the two options config dialogs (one not released yet). If you can get text rotated the way you want, you might be able to adapt this code to get what you want. – Terry Jan Reedy Dec 03 '14 at 03:12

1 Answers1

1

I know I am late to this and doubt my answer will help, but for anyone stumbling onto this question like I did, this is a simple answer.

You can use ttk's Style class to configure the position of your Notebook.

s = Style()
s.configure('TNotebook', tabposition='w')

Options for Style.configure.tabposition are n,s,e,w for north, south, east, west. You can also anchor the tabs to the relative left or right of the Notebook component by specifying a second coordinate, for example nw would be top left, sw would be bottom left.

Here is an example implementation.

from tkinter.ttk import Notebook, Frame, Label, Style
from tkinter import Tk


root = Tk()
frame = Frame(root)
frame.pack()
s = Style()
s.configure('TNotebook', tabposition='w')
tabControl = Notebook(frame)
first_tab = Frame(tabControl)
second_tab = Frame(tabControl)
third_tab = Frame(tabControl)
tabControl.add(first_tab, text='tab 1')
tabControl.add(second_tab, text='tab 2')
tabControl.add(third_tab, text='tab 3')
tabControl.pack()
first_tab_label = Label(first_tab, 
          text ="First tab text")  
second_tab_label = Label(second_tab,
          text ="Second tab text")
third_tab_label = Label(third_tab,
          text ="Third tab text")
first_tab_label.pack()
second_tab_label.pack()
third_tab_label.pack()     
root.mainloop()
Olivier Neve
  • 299
  • 10