【发布时间】:2018-07-12 14:34:49
【问题描述】:
我真的有一个非常简单的问题。所以我正在制作一个待办事项列表,它需要一个 Tkinter Notebook 元素,该元素的一侧有标签,带有人们笔记的标题和日期,右侧是用户存储笔记的文本编辑器.
但是,我无法为每个选项卡设置相同的宽度和高度。选项卡的大小会根据用户的注释标题不断增加和减小,但我想要发生的是,当标题的文本超过选项卡宽度的大小时,只有一些标题出现和消失。否则,我想要发生的是让文本换行并增加高度(但绝不是宽度)。
在下面的代码中,标题是 one one one、two two two 和 three three three 文本。我尝试使用.grid_propagate(FALSE),但没有成功。
from tkinter import *
import datetime
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import tkinter as tk
root = Tk()
root.columnconfigure(2, weight=1)
root.rowconfigure(1, weight=1)
root.title("To - Do List")
root.geometry("1200x600")
root.configure(background = "white")
# Variable list:
style = ttk.Style()
style.configure(root, tabposition = "wn")
TasksList = ttk.Notebook(root)
Task1 = tk.Frame(TasksList, bg='white', width=600, height=500)
TasksList.add(Task1,text = 'One One One One One One')
Task1.grid_propagate(FALSE)
Task2 = tk.Frame(TasksList, bg='white', width=600, height=200)
TasksList.add(Task2, text = 'Two Two Two Two Two Two')
Task2.grid_propagate(FALSE)
Task3 = tk.Frame(TasksList, bg = "white", width = 600, height = 200)
TasksList.add(Task3, text = "Three Three Three Three Three Three Three")
Task3.grid_propagate(FALSE)
【问题讨论】:
标签: python-3.x tkinter