DelphiVCL4Python icon indicating copy to clipboard operation
DelphiVCL4Python copied to clipboard

Load Form Props from memory

Open zwm88 opened this issue 2 years ago • 3 comments

Currently the LoadProps only supports loading a pydfm file. It's better to add a function to load props from a file object or a string. Therefore, we don't need to ship the pydfm file with the software release.

zwm88 avatar Apr 12 '22 09:04 zwm88

Well, I'm not sure if this is really useful. Having the properties configuration in a separated file makes code cleaner and it is much easier to format.

lmbelo avatar Apr 12 '22 15:04 lmbelo

Yes, that .pydfm could be changed to a .py file which contains just a string for TForm.LoadPropsFromString(TFrmTool_UI) to use:

TfrmTool_UI = 
"""
object frmTool: TfrmTool
  Left = 0
  Top = 0
  BorderStyle = bsDialog
  Caption = 'Calibration'
  ClientHeight = 685
  ClientWidth = 1145
  Color = clBtnFace
  Constraints.MinHeight = 640
  Constraints.MinWidth = 1100
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poScreenCenter
  PixelsPerInch = 96
  TextHeight = 13
end
"""

The .py file can be compiled into the release EXE by Pyinstaller. Leave no separated pydfm file that allows the end user to easily see the UI design or even change it. The Delphi4PythonExporter could be improved accordingly with such an option.

This also allows developers to hand write the UI in the code easily.

zwm88 avatar Apr 12 '22 20:04 zwm88

Thank you for your suggestion @zwm88. I will put some work on it.

lmbelo avatar Apr 14 '22 21:04 lmbelo