PySimpleGUI 事始め 1/22/2023 (was 7/6/2022)      

少し怠けるとすぐ基本的なことを忘れてしまいます。 忘れることは仕方のないことですので、忘れた時のために基本的なcodeやruleを書いておくことにしました。

PythonでのGUI作成は面倒なので、今後はPySimpleGUIで対応していきます。

➍ 前に書いたものが古くなった場合にそこを探して修正するのは大変なので、追記で載せておきます。 OSはWindoes11 ver 1/22/2023

・python,pip,PySimpleGUI etcのinstall方法
  C:\Users\tak>pip install python
  C:\Users\tak>pip install --upgrade pip
  C:\Users\tak>pip install PySimpleGUI

 既にinstallされていれば、次のように言われます。
  C:\Users\tak>pip install PySimpleGUI 
  Requirement already satisfied: PySimpleGUI in 
   c:\users\tak\appdata\local\programs\python\python310\lib\site-packages (4.60.1)   

*現在installされているPython関連のライブラリーを調べる。1/22/2023 7/6/2022
PS C:\Users\n1tk> pip list
Package         Version
--------------- -------
contourpy       1.0.7
cycler          0.11.0
fonttools       4.38.0
kiwisolver      1.4.4
matplotlib      3.6.3
numpy           1.24.1
packaging       23.0
Pillow          9.4.0
pip             22.3.1
pyparsing       3.0.9
PySimpleGUI     4.60.4
python-dateutil 2.8.2
setuptools      65.5.0
six             1.16.0
Wave            0.0.2

以前は下記がinstallされていたが、PCを変えたので今は上の項目がinstallされている。
Package                   Version
------------------------- -----------
altgraph                  0.17.2
beautifulsoup4            4.11.1
future                    0.18.2
MouseInfo                 0.1.3
mutagen                   1.45.1
numpy                     1.22.3
pandas                    1.4.2
pefile                    2022.5.30
Pillow                    9.1.0
pip                       22.1.2
PyAutoGUI                 0.9.53
pygame                    2.1.2
PyGetWindow               0.0.9
pyinstaller               5.1
pyinstaller-hooks-contrib 2022.7
PyMsgBox                  1.0.9
PyPDF2                    1.25
pyperclip                 1.8.2
PyRect                    0.2.0
PyScreeze                 0.1.28
PySimpleGUI               4.60.1
python-dateutil           2.8.2
pytweening                1.0.4
pytz                      2022.1
pywin32                   304
pywin32-ctypes            0.2.0
setuptools                58.1.0
six                       1.16.0
soupsieve                 2.3.2.post1
xlwings                   0.27.10

*Pythonのexe化 日本語、filenameに空白不可
    https://cafe-mickey.com/python/python-exe/
  pip install pyinstaller
  pyinstaller tqdm.py --onefile
 コンソール画面を表示させたくない場合は;
  pyinstaller tqdm.py --onefile --noconsole

・スクリプトで次のディレクトリーへ行きたいときは;
 C:\Users\tak>cd pythonとするとC:\Users\tak>pythonとなります
・スクリプトで前のディレクトリーへ戻りいときは;
 C:\Users\tak>python>cd..エンターで-->C:\Users>と戻れます。  

・iOSは多分この方法でinstallすると思います。
 $ sudo pip3 install pysimplegui 

❸ printは普通は一段改行されるが、他の理由で空白行が追加される場合がある。
 その時は;
       print(f"{line}", end = "")
 とend=""とすれば通常の一段改行となる。
➋ 従来codeをここへ書くと、空白、tabなどがあるとそのままではコピペでPythonを動作させるのに苦労をしていました。

*最近code書き込みに最適なプラグイン(Highlighting Code Block)を見つけましたので、今後はcodeをそれを使います。

install関連

◎ Pygameのインストール
①コマンドプロンプトを起動し、「python -m pip install pygame」と打ちます。 
②「python」コマンドを打ったあと、「import pygame」と入力し、エラーが表示されなければ成功です。

◎ pip.exeのfull path 何かをinstallするアプリのpathを知りたいとき。
C:\Users\~\AppData\Local\Programs\Python\Python310\Scripts\pip.exe

◎ PILのinstallするときのpath PILは画像ライブラリです。
C:\Users\~>C:\Users\~\AppData\Local\Programs\Python\Python310\Scripts\pip.exe install pillow

◎ install pillow 画像ライブラリです。
C:\Users\~>AppData\Local\Programs\Python\Python310\Scripts\pip.exe install pillow
 Collecting pillow
   Downloading Pillow-9.1.0-cp310-cp310-win_amd64.whl (3.3 MB)
 Installing collected packages: pillow
 Successfully installed pillow-9.1.0
●PIL/Pillowはコンパクトで高速なPython用の画像ライブラリです。

◎ install pygame pygameは画像ゲーム処理に必要なライブラリーです。
C:\Users\tak>python -m pip install pygame
Collecting pygame
  Downloading pygame-2.1.2-cp310-cp310-win_amd64.whl (8.4 MB)
 Installing collected packages: pygame
 Successfully installed pygame-2.1.2

◎ install mutagen や numpy のinstall
C:\Users\~>python -m pip install mutagen とか numpy と書く 4/24/2022
 Collecting mutagen
   Downloading mutagen-1.45.1-py3-none-any.whl (218 kB)
 Installing collected packages: mutagen
 Successfully installed mutagen-1.45.1

◎ pipのinstallでエラーになった場合
 https://gammasoft.jp/support/pip-install-error/

◎ Excel 特定の文字を消す
 =SUBSTITUTE(D2,":","")
◎ Excel 特定の文字が何個あるか
 元のセルの個数(Len)と=SUBSTITUTE(D2,":","")後の個数の差が特定文字の数となる


➊ 現在何がinstallされているかを調べたいときに使う:

C:\Users\xxx>python -m pip list
Package         Version
--------------- -----------
beautifulsoup4  4.11.1
mutagen         1.45.1
numpy           1.22.3
pandas          1.4.2
Pillow          9.1.0
pip             22.1.2
pygame          2.1.2
PyPDF2          1.25
PySimpleGUI     4.60.1
python-dateutil 2.8.2
pytz            2022.1
pywin32         304
setuptools      58.1.0
six             1.16.0
soupsieve       2.3.2.post1
xlwings         0.27.10