我一直在使用tkinter和ttk与python一段时间,但仍然相当新。我有一段代码生成一个tkinter窗口。在那个窗口我放了一个笔记本对象,我打算在那个笔记本上添加很多标签,并且想知道是否有办法在笔记本上添加一个滚动条。
到目前为止,这是我的代码:
from tkinter.filedialog import askopenfilename
import tkinter as tk
from tkinter import ttk
import sys
import time
def browseL():
filename=askopenfilename()
ent1.insert(0,filename)
def browseR():
filename=askopenfilename()
ent2.insert(0,filename)
root=tk.Tk()
root.config(width=1350,height=550, bg='grey')
button=ttk.Button(root,text='Browse',command=browseL)
button.place(x=500,y=130)
button2=ttk.Button(root,text='Browse',command=browseR)
button2.place(x=700,y=130)
ent1=ttk.Entry(root)
ent2=ttk.Entry(root)
ent1.place(x=480,y=100)
ent2.place(x=680,y=100)
lab1=ttk.Label(root, text='Enter path to settings file #1', background='white')
lab2=ttk.Label(root, text='Enter path to settings file #2', background='white')
lab1.place(x=470,y=80)
lab2.place(x=670,y=80)
notebook=ttk.Notebook(root)
notebook.place(x=1000,y=100)
tab1=tk.Frame(root)
tab1.config(width=100,height=100,background='white')
notebook.add(tab1,text='tab1')
root.mainloop()
请注意带有一个标签的记事本,如果可能的话,我想要添加滚动条。
如果有帮助,我正在使用python 3.4
提前致谢!