[참고]


import tkinter as tk

from tkinter import ttk


#create instance

win = tk.Tk()


#add a title

win.title("Python GUI")


tabControl = ttk.Notebook(win)  #create tab control


tab1 = ttk.Frame(tabControl)             #create a tab

tabControl.add(tab1, text = 'Tab 1')     #add the tab

tab2 = ttk.Frame(tabControl)             #add a second tab

tabControl.add(tab2, text = 'Tab 2')     #make second tab visible


tabControl.pack(expand = 1, fill = "both") #pack to make visible


#LabelFrame using tab1 as the parent

mighty = ttk.LabelFrame(tab1, text = 'Mighty Python')

mighty.grid(column = 0, row = 0, padx = 8, pady = 4)


#Label using mighty as the parent

a_label = ttk.Label(mighty, text = "Enter a name:")

a_label.grid(column = 0, row = 0, stick = 'W')


#start GUI

win.mainloop()



[결과]



+ Recent posts