概要
はい、自分用のメモです。
thinkerにおいて、ボタンが押された状態を戻す方法
https://suzutaka-programming.com/tkinter-ttk-button-bind/
コールバック関数の終わりをreturn "break"にする。
こんなん思いつかん。
別ファイルのクラスを継承するには
https://www.sejuku.net/blog/68040
pythonの関数ポインタ(というかコールバック関数)
pythonには「関数ポインタ」はなくて、関数だろうとインスタンスだろうと数値だろうとすべてオブジェクトで「オブジェクトID」が割り当てられていて、オブジェクトIDが辞書に登録されます。
https://qiita.com/moroku0519/items/315cd25d3eaae3217103のコメント欄より
tkinter を使ってPythonのフォームが表示されるプログラムをpyinstallerでexe化する場合
--noconsole オプションを付けないとフォームが表示されないことに注意する
よって、testForm.pyをexe化する場合は、以下のようなコマンドを実行する
pyinstaller testForm.py --onefile --noconsole
cv2で画像を表示したあとに、Tkinterで表示しようとした際にぶつかる壁
「PIL.ImageTk.PhotoImage ndarray 変換」で検索
その結果、できたメンバ関数↓
def whenUseTkinter(self):
# BGRからRGBへ変換
CV_im_RGB = self.img_resized[:, :, ::-1].copy()
# 変換
self.img2 = Image.fromarray(CV_im_RGB)
self.imgTk = ImageTk.PhotoImage(self.img2)
#print("img2・・・{}".format(type(self.img2))) # <class 'PIL.Image.Image'>
#print("imgTk・・・{}".format(type(self.imgTk))) # <class 'PIL.ImageTk.PhotoImage'>
結局、ndarray型をPIL.ImageTk.PhotoImage型に変換するということですが、画像のリサイズとか、補助矩形の追加しているうちに、なんかもう大変になる。
テストでimageを表示したあとに、Tkinterにimageを表示させようとすると色がおかしくなる対策
http://tatabox.hatenablog.com/entry/2013/07/21/231751
BGRからRGBへ変換する