Last week during our Python for Delphi webinar, there was some questions about how to get
everything installed, set up.
So I'm going to walk you through installing a Python4Delphi, Python, and SynEdit.
So we'll start with SynEdit.
It's available in GetIt, and eventually Python4Delphi will be in there, but we're not installing
it from there today.
Accept the EULA it's now going to download SynEdit and then build all the packages for
windows.
So it's installed in the IDE and ready to go.
That's it we're done.
So now I'm going to install Python4Delphi.
To do that I have to come in here and get the URL for the repository right here.
And then go to RAD Studio, Open from Version Control, Git, source, destination, make a
folder to put it in.
And now it's going to ask you what project I want to a project or project group.
I want to install or want to open after installation.
And so I'm going to go ahead and open the package.
Right there, Python4Delphi.
Now I can build this, in theory.
Yup.
Builds it just fine and install it.
There's only one package right now.
And everything's been installed.
But in order to run anything, I need to install Python for Windows.
Now it recommends the.
Uh, Python 3.
Now there was some question redistributing Python.
So if you want to redistribute Python, um, you can just redistribute the, download the
embeddable right here in embeddable zip file.
And that would be the middle and that's like seven megabytes for that one.
I think it's eight, actually.
It's eight for that seven for that possibly.
Um, I'm going to go ahead and do the full installer though.
And you want Python 3, not Python 2.
Python 2 is very old at this point and he recommended you get Python 3.
So Python 3 finished installing or finished downloading so I'm going to run the installer.
And I think actually you can install it from the Windows store as wall, but I'm not positive.
And install now.
Yes.
And I am installing the 64-bit version.
The, um, I could install the 32-bit version as well, but I'm going to just build Win64
applications and use a 64 bit version.
So the bittiness of Python has to match the bittiness of the program you are building.
And if you want to deploy it for macOS or Linux, you would need to install the Python
for those platforms as well.
You could embed the embeddable version for all three platforms in there.
Although I think most, like I was going to say, I think most Linux distros have it by
default, but that's not true.
They don't it's, it's optional.
You can install it through, uh, the Linux package manager.
So PIP is the Python package manager that you can use to install Python packages.
If you wanted to install like num PI or TensorFlow or something like that.
Apparently my path is getting long.
So we'll go ahead and disable that limit.
So I don't run out of path space, always running out of path space.
OK, so now I'm in RAD Studio.
So I'm going to go ahead and open the Demos and demo 31 is the one that he showed off
during the webinar.
And, uh, yeah I'll go ahead and save change to that.
So this is SynEdit.
Actually, this is a memo.
Oh, this doesn't have SynEdit on here.
This is just using memos.
Actually, if we go back to here and go to demos.
See if one of these as using?
Nope.
None of these SynEdit haha so SynEdit gives you the syntax highlighting, but um, none
of these are using SynEdit.
Interestingly.
I thought they did while we were running this and uh, error.
Definition.Inc.
File not found definition.Inc.
So I want to explore.
I'm guessing it's in source ... definition.inc.
Yep.
Copy.
Uh, I need to go tools, options.
All of my Python for Delphi libraries, needs to be added to my path go the library path
and it's got SynEdit.
Added.
Automatically, but because I didn't install it from GetIt, which it's not, in GetIt yet.
So add, there we go.
And now, it should build.
Okay, so I'll run this execute.
Yeah, there we go.
So this is the, okay.
This is the one that shows how to use Python to, um, build a GUI application.
Can close, close dialogue.
Alright.
Yeah, that was the last one I showed.
So let's open up a different project demos, demo1, we'll start with one.
Okay.
Again, this is just a memo and a memo.
Yeah.
Execute script for.
So that's just a really simple one there.
Although let's go to replace this with a Senate.
Not that I can't rewrite that and we'll go SynEdit and we need to say.
It is spelled right: python, we need Python Behavior, and Python Syntax highlighting.
And then here we say, we want highlighter is Python and the behavior needs to point
to the editor SynEdit there.
So now we see we've got the blue on the numbers there and.
Um, we're just going to actually, let's just do this.
I'm going to cheat and just renamed this guy to memo1 and now cross our fingers.
Let's see if it works.
Okay.
Yep.
So not all works.
So I've just replaced that with SynEdit.
So SynEdit gives you the syntax highlighting also gives it the behavior.
So it knows how to do the indentation and stuff like that.
So if you had multiple versions of Python on your system, notice I'm building Win64.
If I was trying to do, Win32 let's go ahead and do that, now it should fail.
Let's see.
Oh, um, Library path add, there.
Save.
Now, it should build, but it shouldn't run.
Now it's failed because it can't find Python32.DLL.
So, and that gives me an error message and that's because I didn't install Python 32
I only installed Python 64.
So I've wanted to install both.
I would have to put both of them on there, or if I wanted to build Win32 ones.
But then also if we go into design, oops, I accidentally closed that if we go in here
into the designer, here is the Python engine, OK.
And the Python engine is where you can specify things.
So use last known version is what the default is.
If you wanted to, you could use, uh, a specific version of Python in here, a DLL name, so
right, here is where a specific version of the DLL and specific path, et cetera.
So there are go quick introduction to setting up and using Python for a Delphi.
Uh, if you don't have.
Git installed on your computer.
So you have to go install, Git options.
So you have to have Git installed.
And, uh, the path set up in here.
If you don't have that, then from here, you can just, um, download.
The zip file or use GitHub for Desktop to do it.
And for some reason, they've now got a GitHub command-line interface.
Instead of it used to have, they had to Git command line.
I don't know when they change that.
And now I get this weird, strange pink error box at the top.
So yeah, you can just download the zip file.
If you don't have Git installed on your computer.
There you go.
That's a quick introduction to setting up and using Python4Delphi.