Lazarus

Programming => General => Topic started by: wytwyt02 on November 15, 2019, 01:05:54 pm

Title: Is there some use python as the logic part, and use pascal as ui part?
Post by: wytwyt02 on November 15, 2019, 01:05:54 pm
Because the pascal syntax is not good not use, and the Lazarus Code editor seems not modern, I prefer python to do some complex logic, and use pascal to update ui.

I am new to Lazarus, Is it possible?
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: tr_escape on November 15, 2019, 01:18:27 pm
fpc is not python and python is not fpc.

But of course you can use fpc libraries in the python or python results can be use as output.

Also I recommend this article:

https://medium.com/issuehunt/13-python-gui-libraries-a6196dfb694 (https://medium.com/issuehunt/13-python-gui-libraries-a6196dfb694)

However also you can use this package too:

https://github.com/Alexey-T/Python-for-Lazarus (https://github.com/Alexey-T/Python-for-Lazarus)
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: Thaddy on November 15, 2019, 03:14:32 pm
Well, Python4fpc will do that...this is the same as Python4Delphi. But - again- why? is Pascal too difficult?
Get it here: https://github.com/pyscripter/python4delphi The official source.

Python is OK btw, and I use it too, but by itself, slow.
Quote
Because the pascal syntax is not good not use, and the Lazarus Code editor seems not modern
Come up with some examples.....< >:D >:D> because you do not know the language! ;D The language is correct and the IDE can use a "modern" style and has way more features than any Python IDE if you know how to configure it. So: Show us....
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: PaulRowntree on November 15, 2019, 03:36:18 pm
This can quickly devolve into a  religious battlefield, but ...I would say that the Lazarus gui is the one component that is perhaps a bit behind the times, but the logic and structure of ObjPascal will beat Python, hands down.  It is clean, crisp, and consistent.  And as it is compiled, it is not prone to failure because of some unforeseen formatting change to the text file the way that Python can.YMMV
$0.02 worth
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: Zoran on November 15, 2019, 04:53:02 pm
I would say that the Lazarus gui is the one component that is perhaps a bit behind the times,

What?
Unlike Python's TK GUI, which might be behind the times, LCL is a wrapper of OS GUI libraries.
Therefore Lazarus GUI is just as much with its time as native OS GUI is. What more can you expect for a desktop application?
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: Thaddy on November 15, 2019, 04:55:15 pm
This is not a religious battle:
- Python is a good language (w/o two way designer)
- Object Pascal is a good language (with several good two way designers: Lazarus and the Delphi IDE)

You can mix the two. If you feel like it? The option is there.
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: del on November 15, 2019, 06:39:28 pm
Whether or not Python is a "good" language depends on the person using it. It sure keeps our C++ guys busy. The Python guys basically "phone in" what they want and the C++ guys make it happen. At any rate just go with the fine QT "designer" utility that comes with the anaconda distributions. Lazarus is extremely attractive - but the price of admission is to learn Pascal (a great language, easy to learn). I had to learn Modula-2 (similar) for some thesis work and picked it up in a couple of hours (Top Speed IIRC).
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: wytwyt02 on November 15, 2019, 09:08:15 pm
Well, Python4fpc will do that...this is the same as Python4Delphi. But - again- why? is Pascal too difficult?
Get it here: https://github.com/pyscripter/python4delphi The official source.

Python is OK btw, and I use it too, but by itself, slow.
Quote
Because the pascal syntax is not good not use, and the Lazarus Code editor seems not modern
Come up with some examples.....< >:D >:D> because you do not know the language! ;D The language is correct and the IDE can use a "modern" style and has way more features than any Python IDE if you know how to configure it. So: Show us....

How to configure the ide?
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: marcov on November 16, 2019, 12:10:54 am
How to configure the ide?

For what ?
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: winni on November 16, 2019, 01:30:16 am
@wytwyt02

main menu --> tools --> options

Take time !!

Hey boy - the wheel is not very modern!
So stop using it!

What kind of strange religion do you hang on?

Winni

Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: wytwyt02 on November 16, 2019, 10:48:36 am
Well, Python4fpc will do that...this is the same as Python4Delphi. But - again- why? is Pascal too difficult?
Get it here: https://github.com/pyscripter/python4delphi The official source.

Python is OK btw, and I use it too, but by itself, slow.
Quote
Because the pascal syntax is not good not use, and the Lazarus Code editor seems not modern
Come up with some examples.....< >:D >:D> because you do not know the language! ;D The language is correct and the IDE can use a "modern" style and has way more features than any Python IDE if you know how to configure it. So: Show us....

I donot like the begin end in if condition
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: kupferstecher on November 16, 2019, 11:01:21 am
I donot like the begin end in if condition
Yes, I can understand that, its nearly as crappy as the c-brakets {}.
But once you are common to begin..end it won't bother you anymore. It's only a WTF-moment in the very very beginning.
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: del on November 16, 2019, 11:02:34 am
Well, Python4fpc will do that...this is the same as Python4Delphi. But - again- why? is Pascal too difficult?
Get it here: https://github.com/pyscripter/python4delphi The official source.

Python is OK btw, and I use it too, but by itself, slow.
Quote
Because the pascal syntax is not good not use, and the Lazarus Code editor seems not modern
Come up with some examples.....< >:D >:D> because you do not know the language! ;D The language is correct and the IDE can use a "modern" style and has way more features than any Python IDE if you know how to configure it. So: Show us....

I donot like the begin end in if condition

That sounds like an excuse. You're probably not gonna like any real language. Only Python AFAIK does that silly indentation thing. Seriously, put away that kid stuff and learn what real programming is like.
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: devEric69 on November 16, 2019, 11:09:12 am
Quote
[snip]...pascal syntax is not good not use...[snip]

It's a bit "raw", as a judgment.
You can't say that Pascal's syntax is bad, since it's rich enough to, and allow you to write dll\so that can be used by other applications, and allow you to use dll\so already written in C\C++ (used\called by Python too, and Php, ...). The "price to pay" for this capacities, is probably to learn the knowledge of the pointers, present in these 2 languages (C and Pascal).
In short, who can do the most, can do less... but we can't say the opposite.

Quote
[snip]...and the Lazarus Code editor seems not modern...[snip]

I don't know exactly what you call a "modern" IDE (it's a "fuzzy" judgment), but I suggest you:
- to install this package: anchordockingdsgn.lpk .
- and read this wiki: https://wiki.lazarus.freepascal.org/Anchor_Docking (https://wiki.lazarus.freepascal.org/Anchor_Docking) (there are screenshots showing different examples of possible IDE configurations).

In doing so, you must be able to configure the IDE in the most useful way, "that maybe will suits to your needs".

Quote
I donot like the begin end in if condition

Indeed, the traditional indentation in Pascal creates "superfluous" lines, *amo*. You could indent like this (in the same way as the C):
Code: Pascal  [Select][+][-]
  1. if () and () or () then begin
  2.   .../...
  3. end
  4. else if () and () or () then begin
  5.   .../...
  6. end
  7. else begin
  8.   .../...
  9. end;
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: marcov on November 16, 2019, 11:56:04 am
I donot like the begin end in if condition

Most of the embedding of Python in native languages is for some scripting parametrization of the native app. It is not really meant to totally divide an application across two languages, and it will probably not be very productive.

If you really like Python so much, I suggest finding something similar in Python. It is one of the most popular languages out there, so I can't imagine it doesn't have some decent GUI builder somewhere.
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: schuler on November 16, 2019, 01:49:26 pm
I like coding on both object pascal (love Lazarus) and python.
It's possible to have UI in Lazarus and logic in python (I have never tried):
https://wiki.lazarus.freepascal.org/Using_Python_in_Lazarus_on_Windows/Linux

:) Wish everyone happy coding. :)
Title: Re: Is there some use python as the logic part, and use pascal as ui part?
Post by: lainz on November 16, 2019, 02:26:55 pm
LazPaint uses python to be able to use scripts, it runs the script with python and with pipes it receives the commands, then executes with Pascal code these commands.

An alternative can be using Electron JS
https://www.fyears.org/2017/02/electron-as-gui-of-python-apps-updated.html
TinyPortal © 2005-2018