0
如何根據窗口標題長度計算並設置基於窗口標題長度的tkinter.Frame
衍生窗口的寬度? 也就是說,有人可以幫我用width = ???
-expression在下面的代碼? (心知肚明的結果取決於字體被使用,系統按鈕等)根據標題長度計算tkinter窗口寬度
在此先感謝 /哈拉爾
import Tkinter as tkinter #Python 2
class MyFrame(tkinter.Frame):
def __init__(self, title, *args, **kw):
tkinter.Frame.__init__(self, *args, **kw)
# Calculate the frame width ensuring that the entire title is shown
# using len(title)
width = ???
self.master.config(width = width)
self.master.title(title)
mf = MyFrame("Some Frame Title")
mf.mainloop()