procedure TForm1.FormCreate(Sender: TObject);
var
//Python39-32へのPath
AppDataDir:string;
begin
・・・
if DirectoryExists(AppDataDir) then
begin
//フォルダが存在したときの処理(コメント化)
//MessageDlg('Embeddable Pythonが利用可能です。',
// mtInformation, [mbOk] , 0);
PythonEngine1.AutoLoad:=True;
GitHubのPython4Delphiのダウンロードページには「The project is licensed under the MIT License.」とある。これは「改変・再配布・商用利用・有料販売すべてが自由かつ無料」であること、及び使用するにあたっての必須条件はPython4Delphiの「著作権を表示すること」と「MITライセンスの全文」or 「 MITライセンス全文へのLink」をソフトウェアに記載する、もしくは、別ファイルとして同梱しなさい・・・ということを意味する。
procedure TForm1.CMShowingChanged(var Msg: TMessage);
begin
inherited; {通常の CMShowingChagenedをまず実行}
if Visible then
begin
Update; {完全に描画}
//Formの表示終了時に以下を実行
Panel1.Height:=intPH;
intPH:=Panel1.Height;
intFH:=Form1.Height;
end;
end;
Formが生成される際に、Panel1とFormの高さをプログラムから指示して決定。
procedure TForm1.FormCreate(Sender: TObject);
begin
//Panel1とFormの高さを記憶する変数を初期化
intPH:=200;
intFH:=480;
end;
Formの大きさの変更イベントに合わせて、Panel1の高さを計算して決定。
procedure TForm1.FormResize(Sender: TObject);
begin
//比率を維持してPanel1の高さを変更
Panel1.Height:=Trunc(Form1.Height * intPH/intFH);
end;
procedure TForm1.CMShowingChanged(var Msg: TMessage);
begin
inherited; {通常の CMShowingChagenedをまず実行}
if Visible then
begin
Update; {完全に描画}
//Formの表示終了時に以下を実行
Memo1.Width:=intMW;
intMW:=Memo1.Width;
intFW:=Form1.Width;
end;
end;
Formが生成される際に、MemoとFormの大きさをプログラムから指示して決定。
procedure TForm1.FormCreate(Sender: TObject);
begin
//MemoとFormの幅を記憶する変数を初期化
intMW:=480;
intFW:=640;
end;
Formの大きさの変更イベントに合わせて、Memoの幅を計算して決定。
procedure TForm1.FormResize(Sender: TObject);
begin
//比率を維持してMemoの幅を変更
Memo1.Width:=Trunc(Form1.Width*intMW/intFW);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
//PythonのScriptを入れる
strScrList:TStringList;
//Pythonから送られたデータを保存する
strAnsList:TStringList;
begin
end;
最初に、Memo1を初期化し、データの入れ物をそれぞれ準備する。
begin
//初期化
Memo1.Clear;
//Scriptを入れるStringList
strScrList:=TStringList.Create;
//結果を保存するStringList
strAnsList:=TStringList.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
//PythonのScriptを入れる
strScrList:TStringList;
//Pythonから送られたデータを保存する
//strAnsList:TStringList; //コメント化してしまう
begin
GitHubのPython4Delphiのダウンロードページには「The project is licensed under the MIT License.」とある。これは「改変・再配布・商用利用・有料販売すべてが自由かつ無料」であること、及び使用するにあたっての必須条件はPython4Delphiの「著作権を表示すること」と「MITライセンスの全文」or 「 MITライセンス全文へのLink」をソフトウェアに記載する、もしくは、別ファイルとして同梱しなさい・・・ということを意味する。
「python -m pip list」で「python.exe: No module named pip」が返る場合は、 pythonNN._pthファイルの修正(# import siteの前にある記号#(ナンバー)とその後ろの半角スペースを削除して import site だけにするコメント化の解除手続き)が正しく行われていない可能性が高い。 また、複数のライブラリのインストールを行うと、 pythonNN._pthファイル が修正前の状態に戻されてしまうこともあるようだ。要確認。
4.Numpyのインストール
続いて「愛しのNumpy」をインストール。
>python -m pip install numpy と入力してEnter!
「生きていてよかった」と思える至福の一瞬がここに。
警告:Consider adding this directory to PATH (このディレクトリをPATHに追加することを検討してください) は、まったく気にしない。Numpyが入ればいいのだ。わはは*(^_^)*♪
5.OpenCVのインストール
さらに、視力0.01かつ老眼&緑内障の恐れありと診断(2万ン千円も払ったのにイタいことばかり言いやがって:チ○ショー!「我が愛と哀しみの人間ドック2021年の記録」より抜粋)された私の眼に代わるSecret Weapon、目にも止まらぬ 走召 高速!でマークシートを読んでくれる機械の眼という意味がほぼない長い前置きを乗り越え、今、怒涛のクライマックス。「OpenCV」ライブラリがいよいよ My PC へ!
FILES: Readme.txt This file. Python.txt Infos about Python, and further references. Changes.txt List of all changes since the first release. Tutorial.txt A simple tutorial to use the PythonEngine To do.txt A to do list. Deploying P4D.pdf Notes on the Deployment of your applications using Python for Delphi. C++ Builder Notes.txt Notes on using C++Builder with the Python for Delphi components. PythonAtom.hlp A help file explaining the use of TPythonAtom Demos A folder containing several demos of Python for Delphi. Components\Python.* The “Python for Delphi” packages. Components\Sources\Core The source folder of the core “Python for Delphi”. Lib Library of Python modules. PythonIDE A Python developpment environment written in Delphi. See PythonIDE\Readme.txt for the required components. Modules Contains the Delphi\Delphi.dpr project that creates the Modules\Delphi.pyd Python module that allows you to interact with Delphi VCL objects from Python.
INSTALLATION: install the Python for Windows distribution (http://www.python.org/).
1) Install the core components For recent versions of Delphi, install the “Python_d” package located in the Components folder and add the folder “…\Components\Sources\Core” to the library path.
For recent versions of Delphi, install the “PythonVCL_d” package located in the Components folder and add the folder “…\Components\Sources\Core” to the library path.
2) this is optional ・・・とあるので、オプションならやらなくてもいいか!ということで実行しない。
3) Build Modules\Delphi\Delphi.dpr (This is optional and unsupported)
Once the project is build you can either extend the Python path with ..\Modules or copy ..Modules\Delphi.pyd to C:\Python24\DLLs, to be able to import the Delphi module from Python.
Note that you can try this module by invoking the ..\Modules\TestApp.py script.
3) This is optional and unsupported ・・・とあり、オプションである上にサポートなしとあるので、これも実行しない。
GitHubのPython4Delphiのダウンロードページには「The project is licensed under the MIT License.」とある。これは「改変・再配布・商用利用・有料販売すべてが自由かつ無料」であること、及び使用するにあたっての必須条件はPython4Delphiの「著作権を表示すること」と「MITライセンスの全文」or 「 MITライセンス全文へのLink」をソフトウェアに記載する、もしくは、別ファイルとして同梱しなさい・・・ということを意味する。
RAD Studio 12.0(Delphi 12.0 Athens)のリリースに合わせ、Python4Delphi も更新されました。 RAD Studio 12.0(Delphi 12.0 Athens)へのインストールに対応した Python4Delphi (20231109版)のインストール記事は、以下のリンク先にあります。
RAD Studio 12.0(Delphi 12.0 Athens)に Python4Delphi をインストールされる場合は、こちらをご参照ください。
Use for Delphi Seattle (10.4) or later to install all packages in one step.
Clone or copy the Python4Delphi git repository to a folder of your choice. The setup.ini file assumes that the folder is called “P4D”. If you chose to name your folder differently then modify the “Folder” option in setup.ini.
Close all Delphi IDEs running.
Run MultiInstaller.exe
Select the packages you want and press Next
In the dialog box specify the parent folder of “P4D” (i.e. the folder containing the directory to which you have copied Python4Delphi) and the Delphi target version. Then press Next to install the components
GitHubのPython4Delphiのダウンロードページには「The project is licensed under the MIT License.」とある。これは「改変・再配布・商用利用・有料販売すべてが自由かつ無料」であること、及び使用するにあたっての必須条件はPython4Delphiの「著作権を表示すること」と「MITライセンスの全文」or 「 MITライセンス全文へのLink」をソフトウェアに記載する、もしくは、別ファイルとして同梱しなさい・・・ということを意味する。