Skip to content

Instantly share code, notes, and snippets.

@rhoit
Last active December 23, 2015 04:59
Show Gist options
  • Select an option

  • Save rhoit/6583664 to your computer and use it in GitHub Desktop.

Select an option

Save rhoit/6583664 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# this code works has been corrected as suggested by Bhaskar Chaudhary <bha100710@gmail.com>
from tkinter import *
from tkinter import ttk
if __name__ == '__main__':
root=Tk()
nb = ttk.Notebook()
nb.pack(expand=YES, fill=BOTH )
f1=Frame(width=200, height=200, bg="red")
f2=Frame(width=200, height=200, bg="blue")
f3=Frame(width=200, height=200, bg="green")
nb.add(f1, text="red", padding=3)
nb.add(f2, text="blue", padding=3)
nb.add(f3, text="green", padding=3)
tablst=nb.tabs()
root.bind('<Alt-KeyPress-1>', lambda event: nb.select(tablst[0]))
root.bind('<Alt-KeyPress-2>', lambda event: nb.select(tablst[1]))
root.bind('<Alt-KeyPress-3>', lambda event: nb.select(tablst[2]))
root.bind('<Key-Escape>', lambda event: quit())
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment