Recent

Author Topic: Is there some use python as the logic part, and use pascal as ui part?  (Read 1653 times)

wytwyt02

  • Jr. Member
  • **
  • Posts: 83
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?
« Last Edit: November 15, 2019, 01:09:02 pm by wytwyt02 »

tr_escape

  • Sr. Member
  • ****
  • Posts: 411
  • sector name toys | respect to spectre
    • Github:
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #1 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

However also you can use this package too:

https://github.com/Alexey-T/Python-for-Lazarus
« Last Edit: November 15, 2019, 01:20:17 pm by tr_escape »

Thaddy

  • Hero Member
  • *****
  • Posts: 10606
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #2 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....
« Last Edit: November 15, 2019, 03:20:45 pm by Thaddy »

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #3 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
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

Zoran

  • Hero Member
  • *****
  • Posts: 1611
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #4 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?

Thaddy

  • Hero Member
  • *****
  • Posts: 10606
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #5 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.

del

  • Full Member
  • ***
  • Posts: 185
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #6 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).

wytwyt02

  • Jr. Member
  • **
  • Posts: 83
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #7 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?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8903
  • FPC developer.
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #8 on: November 16, 2019, 12:10:54 am »
How to configure the ide?

For what ?

winni

  • Hero Member
  • *****
  • Posts: 2018
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #9 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


wytwyt02

  • Jr. Member
  • **
  • Posts: 83
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #10 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

kupferstecher

  • Sr. Member
  • ****
  • Posts: 407
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #11 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.

del

  • Full Member
  • ***
  • Posts: 185
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #12 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.

devEric69

  • Sr. Member
  • ****
  • Posts: 384
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #13 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 (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;
« Last Edit: November 16, 2019, 11:27:02 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8903
  • FPC developer.
Re: Is there some use python as the logic part, and use pascal as ui part?
« Reply #14 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.

 

TinyPortal © 2005-2018