wmの罠。



最近業務でTkinter使ってるのでメモ書きと陥ったところ。


そもそもTkinterって何よ?


TkinterはPythonの標準モジュールで、Tk/Tclをラップしてるモジュール。


TkはGUIツールキット(Tool Kit)の一種でSun Microsystemsが開発していたライブラリ。


環境



  • Mac OS 10.5

  • Python2.6.2


wmに引っかかった...


自身の知識不足でひっかかった所は、ウィンドウのアイコンに.icoを設定しようと考えていた。


調べたところwm_iconbitmapというメソッドを発見。このメソッドに.icoへのファイルパスを設定。


実行したところ...



return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "star.ico" not defined


エラーがでる。


調べた結果...



> I know that in a normal windows python Tkinter app you would use:


>


> root.wm_iconbitmap("/Icons for App/Windows.ico")


>


> to make an icon in the title bar. However, when you do that in mac OSX you


> can't see it. I am not sure if it is because the x - and+ are on the left


> side, or because it just doesn't support MacOSX. Looking at other programs


> none of them have it either. I am just wondering is it possible to put an


> icon in the top title bar.


>


... [show rest of quote]


No, OS X doesn't support this, as far as I know.



あちゃー。Macはサポート外ですが...残念。


という事で、下記に修正し完了。



import sys

if sys.platform == "win32":
root.wm_iconbitmap("star.ico")


細かな所だけど、Macでも設定したいな...


参考


トップレベルのウィンドウの制御 トップレベルのウィンドウ


Re: Icon on title bar in macOSX


トラックバック(0)

このブログ記事を参照しているブログ一覧: wmの罠。

このブログ記事に対するトラックバックURL: http://www.rokujyouhitoma.com/mt/mt-tb.cgi/124

あわせて読みたい

  • あわせて読みたいブログパーツ

Lingr java-ja

ウェブページ

Powered by Movable Type 4.1