embarcadero / delphivcl4python Goto Github PK
View Code? Open in Web Editor NEWDelphi's VCL library as a Python module for building Windows GUI
License: Other
Delphi's VCL library as a Python module for building Windows GUI
License: Other
Plz see
https://en.delphipraxis.net/topic/10675-d4p_export_demo/
Either VCL or FMX cannot make an EXE with pyinstaller.exe
On GUIPY the script runs with no problem
There was a report regarding introspection of delphivcl in PyScripter. It turns out this was due to an invalid docstring of Application.ExeName.
Docstrings should be either ascii or else utf8 encoded. The problem was fixed in https://github.com/pyscripter/python4delphi pyscripter/python4delphi@993c809.
Please fix on your side.
Hi I miss in DelphiVCL for Python, TTreeView and TListView both elements are actually standard for me and are used in almost all my projects. So DelphiVCL would be useless for me. Many say I should use a listbox or grid both is neither a TTreeView nor a TListView.
Does not belong here: Also in the DelphiFMX project there is a ListView but this has nothing to do with the normal representation more that is rather ne improved listbox.
Therefore it would be nice if these are implemented with.
Otherwise I have to bother with QT.
mfg Ark
Hi.
I tried making a LinkLabel, but seems like it doesn't exist yet. My code:
self.myLabel = LinkLabel(self)
self.myLabel.Parent = self
self.myLabel.Caption = "Hello World!"
self.myLabel.Font.Size = 85
self.myLabel.Width = 650
self.myLabel.Height = 150
self.myLabel.Left = (self.Width - self.myLabel.Width) / 2
self.myLabel.Top = (self.Height - self.myLabel.Height) / 2
self.myLabel.BevelKind = "bkTile"
NameError: name 'LinkLabel' is not defined
Python3.12 x64
C:>pip install delphivcl
Collecting delphivcl
Using cached
https://... delphivcl-0.1.24.tar.gz (12 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in delphivcl setup command: 'python_requires' must be a string containing valid version specifiers; Invalid specifier: '>=3.3<=3.10'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
I use spyder 5.x (https://www.spyder-ide.org/) a lot as my a Python IDE.
I can write a DelphiVCL program, eg the simple one below. When I run it the first time it shows correctly. If I try to run it again, the screen shows but then instantly closes. In order to get the form to show correctly, I have to restart the python kernel. Not a showstopper but a nuisance for those running code from spyder. Note that the DelpchVCL code runs fine from the command line with python myfile.py. Running Python 64bit 3.8.6 on Windows 10
from delphivcl import *
class MainForm(Form):
def __init__(self, owner):
self.Caption = "A VCL Form..."
self.SetBounds(10, 10, 500, 400)
self.Position = "poScreenCenter"
self.OnClose = self.__on_form_close
def __on_form_close(self, sender, action):
action.Value = caFree
def main():
Application.Initialize()
Application.Title = "Hello Python"
Main = MainForm(Application)
FreeConsole()
Application.Run()
Main.Destroy()
main()
Hi everyone,
Seems that there is an install problem on Delphi Rio (10.3.1) as Vcl.DBGrids.TDBGrid do not own any ScaleValue method.
Any clue or Sydney+ is mandatory to use DelphiVCL4Python ?
Thanks a lot,
Jonas
I am facing error while running sample python3 hellodelphivcl.py
:
Traceback (most recent call last):
File "hellodelphivcl.py", line 1, in <module>
from delphivcl import *
File "/home/mohi/.local/lib/python3.8/site-packages/delphivcl/__init__.py", line 22, in <module>
package = new_import()
File "/home/mohi/.local/lib/python3.8/site-packages/delphivcl/__init__.py", line 15, in new_import
ld = loader.create_module(spec)
ImportError: /home/mohi/.local/lib/python3.8/site-packages/delphivcl/DelphiVCL.pyd: cannot open shared object file: No such file or directory
Any clues?
I run setup.py with guiPY
I have this error for instalation
C:\Python\Python36-32\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'license_files'
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
could not find any info what to put in command line
ALSO TRIED python setup.py install
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\LimElect>cd G:\python\DelphiVCL4Python-main
C:\Users\LimElect>g:
G:\python\DelphiVCL4Python-main>python setup.py install
File "setup.py", line 23
retvalue = exec(opffilecontents, gbals, lcals)
^
SyntaxError: invalid syntax
G:\python\DelphiVCL4Python-main>
Hi everyone,
I wrote a small multi form program to stamp, split or combine pdfs using pikepdf:
These forms are called using:
def openStamper(self, Sender):
form_stamper = Stamper_Form(Application)
form_stamper.Show()
If I click on "PDF auswählen" an OpenDialog shows up, that lets me pick the file which should get stamped using:
def btn_openpdfClick(self, Sender):
self.OpenDialog1.Execute() # Show open dialog to pick a file
self.pdf_path = self.OpenDialog1.FileName # Get file path from open dialog
self.edit_pdf.Text = self.pdf_path # Show PDF path in disabled edit field
After choosing "open" in the dialog, the pdf_path is set correctly according to the selected file, but the stamper window loses focus and disappears behind the next open window on the desktop:
This is really annoying especially when the other program is in fullscreen mode. Is there any possibility to focus the window again after the OpenDialog closes?
Mouse wheel events are not exposed.
Se attached file with the proposed addition.
Wrapps OnMouseWheel and OnMouseWheelDown.
OnMouseWheelUp is then automatically exposed.
after install with pip in 32 environment we get :
Exception: <class 'ValueError'>: DelphiVCL module not found. Try to reinstall the delphivcl package
Solution:
copy the delphivcl.pyd (3.75 MB) and create a win32 dir in python37-32\lib\site-packages\delphivcl\win32\delphivcl.pyd
checked: eg.execStr('loader= importlib.machinery.ExtensionFileLoader("DelphiVCL",'+VCLHOME+')') 👍
Setting Color property of self works ok. Setting Color property of components placed on self does not work. True for all components that have a Color property like Panel, GroupBox aso. Does not work at runtime either. Other properties can be assigned without problem.
def __init__(self, Owner):
### object Form
self.SetBounds(310, 137, 730, 256) #self
self.Caption = 'Form1'
self.Color = clSkyBlue ###colors all components on form, even if ParentColor is set False for each component
self.Font.Color = clWindowText
self.Font.Height = -11
self.Font.Name = 'MS Sans Serif'
self.Font.Style = []
self.OldCreateOrder = False
self.PixelsPerInch = 96
self.TextHeight = 13
### object GroupBox1, parent self
self.GroupBox1 = GroupBox(self)
self.GroupBox1.Parent = self
self.GroupBox1.SetBounds(20, 20, 266, 136) #GroupBox1
self.GroupBox1.Caption = 'GroupBox1'
self.GroupBox1.Color = clRed ###does not work
self.GroupBox1.SetProps(Parent=self, Color=clRed) ###nor does this help
self.GroupBox1.Font.Color = clWindowText
I can't seem to get the VCL OnCLick event of the TListBox to fire. I'm using
self.lblProject.OnClick = self.lbProjectClick
to connect the event and this is the function for the event handler
def lbProjectClick (self, Sender):
I assume the OnClick event for a TListBox is working?
The Memo component generates an access violation error after changing the style of the application.
Example code:
import os
from delphivcl import *
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
class MainForm(Form):
def __init__(self, owner):
self.Caption = "Test Memo"
self.SetBounds(10, 10, 500, 400)
self.Position = "poScreenCenter"
# Memo component
self.txtMemo = Memo(self)
self.txtMemo.SetProps(Parent=self)
self.txtMemo.SetBounds(10, 40, 300, 100)
# Auto-load new style
self.__sm = StyleManager()
self.__load_style()
def __load_style(self):
self.__sm.LoadFromFile(os.path.join(BASE_DIR, "Windows11_Modern_Dark.vsf"))
self.__sm.SetStyle(self.__sm.StyleNames[1])
def main():
Application.Initialize()
Application.Title = "Checking DelphiVCL4Python"
Main = MainForm(Application)
Main.Show()
Application.Run()
Main.Destroy()
if __name__ == '__main__':
main()
I've noticed that the minimize window button doesn't work, either writing the application in Python from scratch or exporting the GUI from Delphi.
I noticed that there are many xml files in the doc directory of P4D. For example, Vcl.Buttons.pas is generated as Vcl.Buttons.xml. What tool are used to generate these files? Can you share this tool or code? : )
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.
...
Application.MainFormOnTaskBar = False
Application.Title = "Hello Python"
...
Application Title not showing on taskbar, attribute doesn't work.
ImportError: DLL load failed while importing DelphiVCL: The specified module could not be found.
When I try
>>> from delphivcl import *
Hi.
I am a qt user and trying to do something in vcl/fmx to evaluate the possibility of switching to this framework.
What confuses me is the explicit specification of coordinates and size for widgets.
I very rarely use explicit coordinates in qt.
Everything is done through layouts, alignment and size policy.
In VCL I didn't find layouts at all.
FMX has layouts.
I tried GridPanelLayout, but it doesn't work the same way as in qt.
Align also works in a strange way.
Here is video of comparison .
as you can see Label text has break line, but should fill all horizontal space.
Button has no minimal size and can be shrinked to zero.
Label don't restrict minimal Layout's size, thus when the Grid is reduced in size, the label is hidden behind the window.
maybe I'm doing something wrong. How can I get the same result as in qt ?
My fault, it works.
There are still some Delphi components that are not supported in the Python export, such as Windows10 -> TNumberBox, if any of these components are present in the exported unit, the application does not run or trigger any errors. It would be helpful to have the cause to quickly identify the problem.
As far as I understand, delphivcl works only with standard components. Is there a way to make it work with additional or 3rd party components? Thank you.
I have been trying to run the SampleFormDesignExport demonstration. I am using Delphi 11 and Python 3.9 (64 bit). I am a fairly experience (but not expert) Delphi programmer but a newbie to Python.
The program is loaded fairly deep on my G drive.
Everything works up through the export. I open MainForm.py in PyScripter and add the code to execute, but I get an error when I try to run:
"Remote Server is not connected. Please reinitialize or disconnect the remote server."
The error occurs somewhere in the line that starts: "self.LoadProps"
I ran using External Run and it gave me an error code "0EEDFADE."
I have tried using both Win32 and Win64 options on Delphi, and I have tried the same thing with Delphi 10.4.
I re-watched the webinar section and am doing everything the same, so maybe it is a Python configuration error.
Any assistance would be appreciated.
I made VCL for Python as shown on webinar "Introduction to Python GUI Development with Delphi for Python - Part 1: Delphi VCL for Python".
When I run thes code it works fine. VCL form is shown correctly.
But when I created a single exe-file using pyinstaller (pyinstaller -F -w --onefile testdelphivcl.py) and ran created exe-file I got the error:
Maximizing the window works fine, but minimizing doesn't work. : )
We shall be wrapping the TListView and TTreeView components to make them available for the DelphiVCL Python package.
This is an amazing project, Hope to support crossvcl framework : )
I noticed the OnMouseX events in TPaintBox are not handled.
File "frmMain.py", line 21, in init
self.PaintBox.OnMouseDown = 1#self.MouseDown
AttributeError: Error in setting property OnMouseDown
Error: You can only assign a callable to method property "OnMouseDown"
even though the field is present.
I note from
https://en.delphipraxis.net/topic/6011-onmousedownup-events/
which suggests MouseEvents are not yet handled. This seems a bit of an oversight
Tutorial of the HelloWorld Python sample:
http://www.softwareschule.ch/download/maxbox_starter92_1.pdf
Using TImage:
self.Image1.Picture.LoadFromFile(None)
The code will be failed and a Message Box will be popped up. Then, no further code will be execute.
Neither "try...except..." nor "try ... finally ..." will work.
Are there plans to develop stubs files to facilitate development and get to know the API without needing to consult the Delphi documentation?
I've been analyzing the Delphi documentation and I noticed that it is possible to automate the creation of stubs files by accessing the documentation and making a translation to the stub syntax, this would allow more than the creation of stubs files, it is a way to extract the text of the documentation from every function, method, property and event.
That is, it is possible to automate both the stubs files as well as the inclusion of the documentation extracted from Delphi for each property, function, method and etc!
I'm wondering how I can draw matplotlib plots to a Canvas?
I guess I can save plots in a memory image, then draw this image to the canvas in TPaintBox.OnPaint method.
But there will be no interaction. And I don't know if I maximize the Window, whether the image will look ugly.
Could anyone provide a matplotlib backend that uses DelphiVCL or DelphiFMX?
First of all:
I've tried to delete selected items in ListBox and to log witch items should be deleted.
Deleting works with DeleteSelected()
, but for logging I need to iterate over the list and if I use Selected[i]
-property I get an error.
Error in getting property "Selected".
Error: Unknown attribute
Here a minimal:
# from delphivcl import *
import delphivcl as vcl
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
class MyApp(vcl.Form):
def __init__(self, Owner):
self.Caption = "MyApp"
self.SetBounds(100,100,700,500)
# Button del
self.del_task_btn = vcl.Button(self)
self.del_task_btn.SetProps(
Parent=self,
Caption="Delete Task",
OnClick = self.__del_task_on_click
)
self.del_task_btn.SetBounds(150, 120, 100, 30)
# Listbox
self.list_of_tasks = vcl.ListBox(self)
self.list_of_tasks.SetProps(
Parent=self,
MultiSelect = True,
)
self.list_of_tasks.SetBounds(300, 50, 300, 350)
self.OnClose = self.__on_form_close
self.__fill_list()
def __on_form_close(self, Sender, Action):
Action.Value = vcl.caFree
def __del_task_on_click(self, Sender):
msg = f"{Sender.Caption}"
lot = self.list_of_tasks
# Delete only if at least one string in the list box is selected
if lot.SelCount > 0:
logging.debug(f"Selected items: {lot.SelCount}")
msg += ":\n\t" +'\n\t'.join([lot.Items[i] for i in range(lot.Items.Count) if lot.Selected[i]])
lot.DeleteSelected()
else:
if lot.ItemIndex > -1:
msg += f": {lot.Items[lot.ItemIndex]}"
lot.Items.Delete(lot.ItemIndex)
else:
msg += f": {lot.Items[0]}"
lot.Items.Delete(0)
logging.debug(msg)
def __fill_list(self):
lot = self.list_of_tasks
for i in range(10):
lot.Items.Add(str(i))
def main():
vcl.Application.Initialize()
vcl.Application.Title = "TODO App"
app = MyApp(vcl.Application)
app.Show()
# vcl.FreeConsole()
vcl.Application.Run()
app.Destroy()
main()
BR ramooon1
On Python3.8 pip would not install Win32 lib folder. Manual download from github would result in a small file (only 3.3MB) and "NameError: name 'FileOpenDialog' is not defined" when running the sample.
in delphi:
with DrawGrid1 do
begin
Cells[0,0] := 'ID';
Cells[1,0] := 'Name';
Cells[0,1] := '5';
Cells[1,1] := 'Marxcelo';
end;
This issue has already been raised (issue #50, on March 18th by @fansxs). I started a discussion on the same topic, and @lmbelo asked me to raise it as an issue again.
The ActivityIndicator.py demo crashes when I try to change style. The "__on_load_style_click" function crashes at line:
"valid_style, style_info = self.__sm.IsValidStyle(style_file_path)".
Python (v3.10) returns the error message "TypeError: cannot unpack non-iterable bool object".
Removing the "style_info" variable allows the line to run, but then a different error is raised at the line "self.__sm.LoadFromFile(style_file_path)" :
TypeError: Call "LoadFromFile" returned a value that could not be converted to Python
Error: Unsupported conversion from TValue to Python value
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.