Electronで挫折した
GUIアプリケーションを作りたいと思って、Electronで作ってたんですけど
文字化け問題をどうやっても解消できなくて、結局Pythonに戻ってきました。
Pythonはまぁまぁできるので、簡単にできるやろってことでやってみたいと思います。
インストール
とりあえず、Pythonは入っているものとします。
インストール方法は
ここを参照
まずは
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m tkinter |
これで
だめだったらPythonをもう一度インストールしてください。
触ってみる
まずはモジュールのインポートから
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import tkinter |
3.xのPythonはtkinterになります。
2.xの場合はTkinterをインポートしてください。
そうしたらプログラムを書いていきます。
ちなみにここから先はPython 3.x用に書いているので、2.x用はググってください。
こんな感じで書きました。
HelloWorldとめっちゃちっちゃい画面で表示されます。
そしたら今度はウィンドウのタイトルを変更します。
Tkinterだよ~が該当部分。
こんな感じになります。
そうしたらプログラムを書いていきます。
ちなみにここから先はPython 3.x用に書いているので、2.x用はググってください。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import tkinter | |
root = tkinter.Tk() | |
Static1 = tkinter.Label(text=u'Hello world!') | |
Static1.pack() | |
root.mainloop() |
こんな感じで書きました。
HelloWorldとめっちゃちっちゃい画面で表示されます。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import tkinter | |
root = tkinter.Tk() | |
root.title(u"Tkinterだよ~") | |
Static1 = tkinter.Label(text=u'Hello World!') | |
Static1.pack() | |
root.mainloop() |
そしたら今度はウィンドウのタイトルを変更します。
Tkinterだよ~が該当部分。
こんな感じになります。
どうだった?
個人的にはめっちゃ使いやすいなぁと思いました。
ソフトかなんか作れたらまたご紹介します。
0 件のコメント:
コメントを投稿