tk嵌入式xterm的大小如何是动态的?

esm*_*mit 5 python tkinter xterm

可以编写一个简单的python脚本来嵌入xtermtk框架中:

from Tkinter import *
import subprocess

root = Tk()
termf = Frame(root, height=800, width=1000)

termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
Run Code Online (Sandbox Code Playgroud)

窗口建立后

proc = subprocess.Popen('xterm -into %d -sb ' % wid,shell=True)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

在我的电脑上看起来像 嵌入式xtermtermf即使调整框架大小(通过拖动角落), 如何使嵌入式xterm动态调整大小到框架的大小?

Eth*_*eld 1

正如上面的评论所指出的,您可以.bind()Tk()窗口上使用,以便在每次配置窗口时获得回调。

from tkinter import *

root = Tk()

def callback(event):
    print(event.width, event.height)

root.bind("<Configure>", callback)

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

我无法测试如何使用它来调整 Windows 10 上的 xterm 窗口大小。因此,我将把这个答案留在这里,供任何想要编辑它或使用这个答案来构建自己的答案的人使用。