tkinterのwindow拡大したときの処理(python)
tkinterのwindow拡大したときの処理(python)
frame1:ボタン等
frame2:テキスト枠
としたときに、window拡大時、テキスト枠だけ拡大するように設定したいです。
テキスト枠上側を移動させないようにするにはどうしたらよいでしょうか。
現状のコード
from tkinter import *
from tkinter import ttk
from tkinter.font import Font
root = Tk()
root.title("test")
root.minsize(100, 100)
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
def btn1():
root.destroy()
def btn2():
root.destroy()
# ボタン用
frame1 = ttk.Frame(root, padding=10)
frame1.rowconfigure(1, weight=0)
frame1.columnconfigure(0, weight=0)
frame1.grid(sticky=(N, W, S, E))
# テキスト入力・スクロールバー用
frame2 = ttk.Frame(root, padding=10)
frame2.rowconfigure(1, weight=1)
frame2.columnconfigure(0, weight=1)
frame2.grid(sticky=(N, W, S, E))
# Button
button1 = ttk.Button(
frame1, text="ボタン1", command=btn1)
button1.grid(
row=0, column=0, columnspan=2, sticky=(N, W))
button2 = ttk.Button(
frame1, text="ボタン2", command=btn2)
button2.grid(
row=1, column=0, columnspan=2, sticky=(N, W))
# Text
f = Font(family='Helvetica', size=16)
v1 = StringVar()
txt = Text(frame2, height=15, width=70)
txt.configure(font=f)
txt.insert(1.0, "テキスト")
txt.grid(row=3, column=0, sticky=(N, W, S, E))
# Scrollbar
scrollbar = ttk.Scrollbar(
frame2,
orient=VERTICAL,
command=txt.yview)
txt['yscrollcommand'] = scrollbar.set
scrollbar.grid(row=3, column=1, sticky=(N, S))
windowを引っ張って拡大した際に、以下矢印部分が開いてしまいます。
要望としては、矢印部分が動かず、テキスト枠とスクロールバーのみがwindow拡大に追従し広がるようにしたい次第です。
0 likes