From 55301cd2396cdc19ade1ac97ed23e969284fadea Mon Sep 17 00:00:00 2001 From: eXcript Date: Wed, 21 Feb 2024 11:02:00 -0300 Subject: [PATCH] Feature that allows passing parameters when creating delphivcl objects --- .gitignore | 3 +- delphivcl/__init__.py | 2 + delphivcl/delphivclhack.py | 117 +++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 delphivcl/delphivclhack.py diff --git a/.gitignore b/.gitignore index 5bc46d5..4679c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.bak *.dcu *.local -\__pycache__ \ No newline at end of file +\__pycache__ +.idea \ No newline at end of file diff --git a/delphivcl/__init__.py b/delphivcl/__init__.py index 0e1436b..20eaaa2 100644 --- a/delphivcl/__init__.py +++ b/delphivcl/__init__.py @@ -56,3 +56,5 @@ def new_import(): # Import the extension module package = new_import() + +import delphivclhack diff --git a/delphivcl/delphivclhack.py b/delphivcl/delphivclhack.py new file mode 100644 index 0000000..0900a77 --- /dev/null +++ b/delphivcl/delphivclhack.py @@ -0,0 +1,117 @@ +import delphivcl + +comps = [ + delphivcl.Action, + delphivcl.ActionList, + delphivcl.ActivityIndicator, + # delphivcl.# Application, + delphivcl.BasicAction, + delphivcl.Bevel, + delphivcl.BitBtn, + delphivcl.Bitmap, + delphivcl.BoundLabel, + delphivcl.Button, + delphivcl.Canvas, + delphivcl.CheckBox, + delphivcl.Collection, + delphivcl.ColorBox, + delphivcl.ComboBox, + delphivcl.Component, + delphivcl.ContainedAction, + delphivcl.ContainedActionList, + delphivcl.Control, + delphivcl.ControlBar, + # delphivcl.# CreateComponent, + delphivcl.CustomAction, + delphivcl.CustomActionList, + delphivcl.CustomActivityIndicator, + delphivcl.CustomControl, + delphivcl.CustomDrawGrid, + delphivcl.CustomEdit, + delphivcl.CustomForm, + delphivcl.CustomGrid, + delphivcl.CustomMemo, + delphivcl.CustomStyleServices, + delphivcl.CustomTabControl, + delphivcl.CustomToggleSwitch, + delphivcl.DateTimePicker, + delphivcl.DelphiDefaultContainer, + delphivcl.DelphiDefaultIterator, + delphivcl.DelphiMethod, + delphivcl.DrawGrid, + delphivcl.Edit, + delphivcl.FileOpenDialog, + delphivcl.Form, + delphivcl.Graphic, + delphivcl.GroupBox, + delphivcl.Header, + delphivcl.Icon, + delphivcl.Image, + delphivcl.Label, + delphivcl.LabeledEdit, + delphivcl.ListBox, + delphivcl.MainMenu, + delphivcl.Memo, + delphivcl.Menu, + delphivcl.MenuItem, + delphivcl.Metafile, + delphivcl.Monitor, + delphivcl.Notebook, + delphivcl.Object, + delphivcl.OpenDialog, + delphivcl.Page, + delphivcl.PageControl, + delphivcl.PaintBox, + delphivcl.Panel, + delphivcl.PascalInterface, + delphivcl.PascalRecord, + delphivcl.Persistent, + delphivcl.Picture, + delphivcl.Point, + delphivcl.PopupMenu, + delphivcl.RadioButton, + delphivcl.RadioGroup, + delphivcl.Rect, + # delphivcl.# Screen, + delphivcl.ScrollBar, + delphivcl.Shape, + # delphivcl.# ShowMessage, + delphivcl.Size, + delphivcl.SpeedButton, + delphivcl.SpinButton, + delphivcl.SpinEdit, + delphivcl.Splitter, + delphivcl.StaticText, + delphivcl.StringGrid, + delphivcl.Strings, + delphivcl.StyleInfo, + delphivcl.StyleManager, + # delphivcl.# StyleServices, + delphivcl.TabControl, + delphivcl.TabSheet, + delphivcl.Timer, + delphivcl.ToggleSwitch, + delphivcl.ToolBar, + delphivcl.ToolButton, + delphivcl.TrackBar, + delphivcl.VarParameter, + delphivcl.WinControl +] + + +def main(self, *args, **kwargs): + + for key, value in kwargs.items(): + setattr(self, key, value) + + +def change_types(): + for c in comps: + newc = type(c.__name__, + (c,), + {"__init__": main}) + + setattr(delphivcl, c.__name__, newc) + + +change_types()