はじめに
記事をあまり書いたことがないのでご容赦を、、
警告
私はコーヒーを飲むのと犬をなでたり見まくるのが趣味の変態なのでなにかしらが
プログラム、プロジェクトに影響する可能性があります。
作った意図
自分が大学の授業中に先生が軽く言った重要なこと
(書き取り妨害術?いにしえの技?)
をメモするためにメモ帳を使っていたのですが。。。
ノートパソコンだと使いづらい!!
CAD使ったり、zoom開きながらだとサイズの調整とかで戸惑っている間に積む、、、
消すのめんどくさい、、、
画面半分より小さいサイズがデフォルトで
すぐに書いた言葉を消せるホワイトボードみたいな
メモ帳があればな、、、
pythonのtkinterを使って作れないかな、トホホ
(使ってなんか作りたかったんだよ、、、)
magic_word.py
import tkinter #魔法の言葉
書いたコード
whb.py
import tkinter as tk
# グローバル変数
text_content = ""
def convert_text():
global text_content
tex.delete(1.0, tk.END)
def convert_text2():
global text_content
text_content = tex.get(1.0, tk.END)
tex.delete(1.0, tk.END)
def convert_text3():
global text_content
tex.insert(1.0,text_content)
test = tk.Tk()
test.title('記憶型ホワイトボードver3.09.11')
test.geometry('300x400')
tex = tk.Text(background='white')
tex.place(x=10, y=10, width=230, height=300)
bt = tk.Button(text=u'消す', background='white', command=convert_text)
bt.place(x=60, y=325, height=40)
bt2= tk.Button(text=u'メモリ', background='white', command=convert_text2)
bt2.place(x=110, y=325, height=40)
bt3= tk.Button(text=u'呼ぶ', background='white', command=convert_text3)
bt3.place(x=170, y=325, height=40)
test.mainloop()
exe化する
cmdでpyinstallerをダウンロードします。
1.cmd
pip install pyinstaller
そしてwhb.pyをexe化します。
2.cmd
pyinstaller --onefile --icon=dog.ico --noconsole whb.py
勝手にdog.icoになるようにしてますがご用意がない方はなしで大丈夫です。
実行画面
動かしてみるとこんな感じになると思います。
左上の羽アイコンも変えれるのでぼちぼち変更します。