0

ウィンドウ タイトルを tkinter アプリケーションに追加しようとしています。.title('Mytitle') は単純な例では問題なく動作するようですが、ウィジェットをクラスにカプセル化している場所では動作しません。

これは、www.pythonware.com/library/tkinter/introduction/ の「Hello, again」チュートリアルを使用した簡単な例です。

これが機能しないのはなぜですか?ありがとう!

from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
        self.button.pack(side=LEFT)

        self.hi_there = Button(frame, text="Hello", command=self.say_hi)
        self.hi_there.pack(side=LEFT)

    def say_hi(self):
        print "hi there, everyone!"

root = Tk()

app = App(root)

root.title('blob')

root.mainloop()
4

1 に答える 1

0

Marcin Kowalczyk のコメントによると、ウィンドウ サイズが小さすぎてタイトルを表示できません。不思議なことに、ウィジェットがないとウィンドウが拡大されてタイトルが表示されます。

于 2013-05-19T09:12:48.580 に答える