

JohnLM
Members-
Content Count
350 -
Joined
-
Last visited
Everything posted by JohnLM
-
Okay, by now, I know this topic is old, but whatever. I had a look at the Day-10 puzzle and I'm a bit confused with how they are detecting the asteriods. The following example grid is given as: .#..# ..... ##### ....# ...## Then, it says the following: The best location for a new monitoring station on this map is the highlighted asteroid at 3,4 because it can detect 8 asteroids, more than any other location. (The only asteroid it cannot detect is the one at 1,0; its view of this asteroid is blocked by the asteroid at 2,2.) ..and goes on to say [2,2] is blocking [1,0]. Q1) So how come it does not say [4,0] is blocked by [3,2] or [4,2]? Q2) Where is the 8th asteroid? Is it counting itself as an asteroid? I drew the following grid in MS Excel and then pasted it into the website, Excalidraw and drew some lines to connect the asteroids. I have follow-up questions as to the other examples they give, but I will wait at first.
-
Cannot debug delphi code in the Python4Delphi Demo1 project - [Solved]
JohnLM posted a topic in Python4Delphi
Specs: Delphi XE7, VCL, Win7, Python4Delphi v3.8.10 (the last official build for windows 7) In one of my projects that includes P4D, I discovered that I can not debug the code. Note, I am not debugging the Python aspects, just the Delphi code only, such as when you put a breakpoint at the line aString="ABCDEFG", as seen below. Note also, that I am giving a simplified example, (where you see the breakpoint) just to show the issue. Note: this is for any projects that include Python4Delphi. And the final result after pressing F9 (compile with debug). . . And, when I switch to 32-bit target and compile via F9, I get the following different issue: [dcc32 Fatal Error] Demo01.dpr(7): F2048 Bad unit format: 'Unit1.dcu' - Expected version: 28.0, Windows Unicode(x86) Found version: 28.0, Windows Unicode(x64) I do not know how to resolve this. I would like to do some debugging in my P4D projects but can't. Any advice would be greatly appreciated, thanks!- 2 replies
-
- delphi xe7
- python4delphi
-
(and 2 more)
Tagged with:
-
Cannot debug delphi code in the Python4Delphi Demo1 project - [Solved]
JohnLM replied to JohnLM's topic in Python4Delphi
Another update. . . solved!! Okay. I believe I have resolved the issue with getting the debugger working in projects with Pytho4Delphi. My particular issue was with having a TFrame in the Python4Delphi project. I had it as a 32-bit, while the main app was 64-bit. And, when I changed both to 32-bit and recompiled via "Build-All Projects", then the debugger would work. If I had just only did a regular compile, the debugger would not work. Note, but still no debugger for 64-bit apps. I did not know this was the case for XE7 because most my apps were 32-bit. Oh well.- 2 replies
-
- delphi xe7
- python4delphi
-
(and 2 more)
Tagged with:
-
Cannot debug delphi code in the Python4Delphi Demo1 project - [Solved]
JohnLM replied to JohnLM's topic in Python4Delphi
Delphi XE7 -- After some further investigation and research, it turns out that the debugger is not active in *any* 64-bit VCL and FMX applications. I have the same error message shown in my first post, shown in the second image. Only 32-bit apps have debugging working. But the issue with the 32-bit debugging indicated in the previous post, 3rd example, is a separate issue with the P4D, I guess.- 2 replies
-
- delphi xe7
- python4delphi
-
(and 2 more)
Tagged with:
-
Specs: Delphi XE7, VCL, Win7 64Bit - current version of Python v2.7.9rc1 as of today 2/1/2025 Friday -- edit: will update it to latest for win7, to v3.8.10 As part of my learning of Python and using Python4Delphi as the learning real-time GUI tool, I came across a youtube tutorial video where the person was calling the following Import libraries: import pandas as pd import matplotlib.pyplot as plt import networkx as nx In other learning python projects I have imported some libraries successfully. The ones above are not avail on my laptop. So I am guessing that I have to download them. 1. Where can I download them from? 2. and where (hdd folder) do I download them to on my laptop? Please note: that I am not using any official Python IDE GUI app. I am using Python4Delphi and building a small IDE for it and am using that as the IDE GUI app to run python code and/or test and run python lessons with.
-
Update on this endeavour. . . success !! Wow! What a pain in the legs, searching the web and trying to debug and resolve this issue. But I am very happy to say that I can now import and use Pandas, Numpy, and other libraries, including graphing and what-not, using my micro IDE for Python app.
-
update on this issue. . . not resolved. This issue must be related to the older version (3.8.10) and Windows 7, not to mention the different updates made to the packages over time. I went to the website you linked to and have been going through the steps, (plus doing other research of my own). And I have not been able to get these steps working. For example: 1. python -m venv c:\myenv # i decided to make it easier to navigate to, so I made the folder at the c:\ root instead. 2. Then, activate the virtual environment: 2b. source myenv/bin/activate <-- does not work There is no program called source. But, after a while I came to realize that maybe they are saying to CD over into the folder? ..in order to use PIP and Python.exe Anyway. That folder does not exist in step 2b. It is called myenv/scripts/ and all the .exe files are in there. I will come back to this an try to figure out how to redirect the PATH to the myenv folder so I can run test via my app. Or else I will have to figure a way to rename the folders temporarely. I got the folder renamer working. I Just have to do some additional hacks to get it to "swap" back and forth once I figure out the issue with the numpy part. So, if I want my ide 4 python to work with the myenv/script folder, I will have to swap the original Python folder and myenv/script folder. This is the method that I started working first instead of figuring out how to change the env PATH string. I don't know. I'm not knowledge in Python and all its trouble-shooting, so I am hacking. okay. am late for work. will give an update later.
-
Update on this endeavor. . . I believe I have properly installed all the necessary libraries as mentioned in my first post. However, I seem to be having trouble with Python4Delphi issuing the following error due to some issue with this library in this line: "import matplotlib.pyplot as plt" AttributeError: partially initialized module 'numpy' has no attribute '__version__' (most likely due to a circular import) and the full errors as reported by Python4Delphi: python script: import matplotlib.pyplot as plt import numpy as np Python run output results: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\dell\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py", line 255, in <module> _check_versions() File "C:\Users\dell\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py", line 250, in _check_versions if parse_version(module.__version__) < parse_version(minver): AttributeError: partially initialized module 'numpy' has no attribute '__version__' (most likely due to a circular import) I am trying to learn how to produce charts and graphs, like you can do in Excel. I have tried several different lessons that use import libraries and so far, the only library giving me trouble is "matplotlib.pyplot". I am failing miserably in this Python4Delphi endeavor!! Does anyone here know how I can resolve this?
-
Apparently, I did have v3.8.10 installed, but the installation must have missed some things I did not tick at the time of initial installation. I proceeded to uninstall it and reinstall it and making sure I tic the part about adding it the search path. Afterwards, the installation went successfully and I type in PIP and the process worked. Below is a run-through of the process for the command line: PIP install pandas C:\Users\dell>pip install pandas Collecting pandas Downloading pandas-2.0.3-cp38-cp38-win_amd64.whl (10.8 MB) |████████████████████████████████| 10.8 MB 1.3 MB/s Collecting python-dateutil>=2.8.2 Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB) |████████████████████████████████| 229 kB 1.7 MB/s Collecting numpy>=1.20.3 Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB) |████████████████████████████████| 14.9 MB 1.6 MB/s Collecting pytz>=2020.1 Downloading pytz-2025.1-py2.py3-none-any.whl (507 kB) |████████████████████████████████| 507 kB 1.3 MB/s Collecting tzdata>=2022.1 Downloading tzdata-2025.1-py2.py3-none-any.whl (346 kB) |████████████████████████████████| 346 kB 1.3 MB/s Collecting six>=1.5 Downloading six-1.17.0-py2.py3-none-any.whl (11 kB) Installing collected packages: six, tzdata, pytz, python-dateutil, numpy, pandas Successfully installed numpy-1.24.4 pandas-2.0.3 python-dateutil-2.9.0.post0 pyt z-2025.1 six-1.17.0 tzdata-2025.1 WARNING: You are using pip version 21.1.1; however, version 25.0 is available. You should consider upgrading via the 'c:\users\dell\appdata\local\programs\pyth on\python38\python.exe -m pip install --upgrade pip' command. C:\Users\dell> I am not sure that it installed in the correct place. I mean, I did not give it a folder/path name. I just opened a comand line prompt via CMD and the default folder showed, thus, c:\users\dell I am not a Python guru. Can anybody confirm that I performed this operation correctly?
-
Thanks. Okay, I found the last version of Python being made for Windows 7 is v3.8.10 - After that version, only Windows 10 and onward - 😞 link --> https://www.python.org/downloads/release/python-3810/ download link 64b --> https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe download link 32b --> https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe
-
pip is not on my machine. I searched around for it. Also, after some time searching some more, I found out how to tell which version of Python I have installed, which is currently at version 2.7.9rc1 and I must have installed it back in 2014 since the date of the folder "Python27" shows that year it was created. To the best of my memory, I got interested in it when I heard about and watched a youtube video on Python4Delphi by Jim Mckeeth and I must have installed to try it out back then and then forgot about it until around now. But the version I have seems to work fine, and I've tried many lessons successfully. Just basic stuff. But now I want to get into it more deeper. Oh, and I searched around for "pandas" or a folder at least, and I did not find any. It looks like I have a bit of research to do.
-
Specs: Delphi XE7, VCL, windows 7, Dell laptop (i3 core, 2.40GHz) I have been playing around with the Listview control, (via ViewStyle=vsReport) learning how to add items at runtime through code (not using a database/binder), for 100 to a few thousand items. Again, just playing around with throwing together a quick listview of data, and seeing if there is use for it versus going the database dataset route. Note, because I was self-learning about listview from scratch, I did have a lot of trouble figuring out how to populate the listview. And now that I know how to, I am also sharing it here for reference for others struggling to do the same. Below, is the code snippet of how I created the initial fields and then populate them. The ViewStyle should be set to vsReport in the properties section in order to show a table column layout at run time. It works and that's all that matters at this point in this indeviour. procedure TForm1.btnAddClick(Sender: TObject); var itm : TListItem; Col : TListColumn; s : string; et : int64; SW : TStopwatch; begin Col := lv1.Columns.Add; Col.Caption := 'LN'; Col.Alignment := taLeftJustify; Col.Width := 30; Col := lv1.Columns.Add; Col.Caption := 'ItemNo'; Col.Alignment := taLeftJustify; Col.Width := 60; Col := lv1.Columns.Add; Col.Caption := 'Desc'; Col.Alignment := taLeftJustify; Col.Width := 160; setlength(ary,10); // create the array length (1,2,3,4,5,6,7,8,9,0) chars beep; SW := TSTopWatch.StartNew; // start timing it lv1.Items.BeginUpdate; for i := 0 to 25000 do begin // ary := genRandValues; // generate random numbers ie (2,9,8,4,7,5,6,0,1,3) s:=listtostr(ary); // convert array list into a string var ie ('2984756013') itm:=lv1.Items.Add; // create a row itm.Caption := i.ToString(); // add the major field, ie 'LN', thus the populate with variable i as line numbers itm.SubItems.Add(''); itm.SubItems[0]:= s; // itemno ie '2984756013', and so on. itm.SubItems.Add(''); itm.SubItems[1]:= s; // desc ie same, ... end; lv1.Items.EndUpdate; SW.Stop; // finish timing eb1.text:=(intToStr(SW.ElapsedTicks)+' ticks / '+intToStr(SW.ElapsedMilliseconds)+' ms'); beep; end; But the problem I am having is that even when using the .BeginUpdate/.EndUpdate the speed is still a bit slow. For example, to fill a listview with 10,000 elements, it costs me about aprox 1.6 seconds run time, or for 25,000 elements, 7.6 seconds. I had a look at the earlier part of the for/loop, where I am generating the random numbers and then converting them to strings. I REM'ed them out and the time was still the same or ever-so-slightly less, maybe 1.5 seconds for instance. So that does not seem to be a major issue in slowing the listview down. Is this the maximum throughput I can expect from listview? or Is there anything else I can do to speed this up a lot more?
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
After loading the project into Delphi 12.2, the issue is still present. And setting Doublebuffered=true resolves it. Note, these are win32 bit app.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
I am confirming that the issue is also reproducible under Windows 10. I copied the XE7 compiled app over to a usb flash drive and inserted in my Win10 tablet and ran three versions: debugged/released gave issue while the app with dubblebuffered=true gave no issues. Again, the app was developed under Win7/XE7. Next, I will bring the whole project source code over to the Win10/D12.2 tablet and recompile to see if the issue is still present.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
Remy, I am not sure that this issue is in other OS's. My main development system is still Windows 7 and Delphi XE7, though I do have a Win10 laptop with D11.2 and a Win10 tablet with D12.2 but I have never developed projects utilizing the Listview for those OS's/Devices to date. But Win7/XE7 is what I use daily. I very rarely use Windows 10, and never have Win11. I don't even have any devices with Win11. Anyway. All apps I create are under Win7. Maybe the issue does not exist in Win10/11? and/or with D11/12+? I should probably test and see because now I am curious.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
Update on the issue with the Listview artifacts. . . This has been resolved by setting Doublebufferd to true. And now for the checkboxes.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
Remy - no, I am not. I believe it has to do with Rowselect set to True. 1) When I move the mouse around to select a row, the last selected row leaves residual "vertical" outlines of the edges. And, if I just move the mouse cursor across them all (without clicking anywhere on the Listview it will remove the artifacts. 2) When it is set to False, there is no artifacts. Only one cell is highlighted and clean. But I prefer the whole row to show as highlighted when scrolling up/down or clicking into it. So far, I've tried removing the Listview and adding a new one with default criteria and only changing the ownerDraw to True. But no difference. Still shows artifacts. And the Checkboxes no longer show. I'm investigating that as well.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
Update on this endeavour. . . a solution has been found and is working, thanks to Alexander S. and Remy for their help. After some time, I managed to get the suggested virtual method posted by Remy working successfully, thank you. But my listview is showing some artifacts in the drawing of the rows. I will have to research that later. I will study this method further in order to understand how it works. Oh, and the run time on my old Dell laptop is now 38ms for the 25k, and 72ms for 100k. A huge difference! Thank you @Alexander Sviridenkov, for first suggesting it to me. I did do some research into it right after your post and was trying but failing to figure out how to put it all together. And also to @Remy Lebeau, for the posted code snippet that showed me the way. Much appreciated!!
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
Thank you, I will look into it.
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
I was wondering if there was a program or tool or whatever you want to call it, for taking a VCL project and converting its components over to an FMX project and be able to open and continue working on it in the FMX environment. I have over time been in this situation, where I start out with VCL but later decide I could use this in Android. Today I'm in that situation. I mainly have tbuttons, tmemos, tpanels, tedits, and ttabs.
-
properties Is it possible to copy all properties from one TMemo to a dynamically created TMemo?
JohnLM posted a topic in VCL
Specs: XE7, VCL, Win7 I have a Panel with a TabControl in it and a Memo inside the first TabSheet on a Form that was all created and configured during design time. And, on the Form in another Panel, I have a [Add] button to dynamically create a new TabSheet and Memo. The main Memo is the default with all the settings that I would like the dynamically created Memos to have. But setting up all the necessary properties would be tedious and if I change something in the main Memo at design-time, I may not remember to update that to the dynamic ones. var Form1: TForm1; idx: integer=0; // index numb, for adding new tabs to the pagecontrol. procedure TForm1.btnAddClick(Sender: TObject); var TabSheet: TTabSheet; memo: TMemo; begin inc(idx); TabSheet := TTabSheet.Create(PageControl1); TabSheet.Caption := 'Untitled-'+idx.ToString; TabSheet.PageControl := PageControl1; memo := tmemo.Create(pagecontrol1); // settings section memo.Color := $0017110D; memo.Align := alClient; . . . // end of settings section memo.Parent := tabsheet; memo.Show; memo.SetFocus; end; note: I have a lot more properties than what is posted above. Is there a better way to copy all the properties of the main Memo to the dynamically created ones and how can I do this?- 15 replies
-
- delphi xe7
- copy
-
(and 1 more)
Tagged with:
-
Creating irregularly shaped multi-dim dynamic arrays
JohnLM posted a topic in Algorithms, Data Structures and Class Design
Is it possible to set variable size multi-dimentional arrays dynamically at runtime? Or, do I have to be clever about it in another way? My usual ways to create m-a's are the typical triangle shape, not irregularly shaped. I want to create the irregularly shaped, like the examples listed below. I have been playing around with run-time dynamic arrays via SetLength() and then realized I can't create them dynamically with different size Columns. I have been using for/next and repeat/until loops of various kinds to attempt to do the irregularly shapped arrays but when I come to create a new Row and reset the C to 1, the data is wiped or I get strange behavior, which leads me to realize this route is not possible, and that I have to do something really clever, maybe to simulate multi-dim dynamic arrays. I have a string list that I want to parse as values--text for strings, numbers for integers. The multi-dim array can look something like the following examples below: where s=string, n=number, r=row, c=column So, using ex 1, as I parse my string list, (a single column list), R is set to 1 for row 1, and C is set to 1, and as I parse through the list, I inc(C) for row 1, thus, ( 1 [n, n, n] ) When I create row 2, I inc(R), and is now row 2, thus ( 2 [n, n, n, n, n] ), . . ., and so on, for row 3, . . . etc. ex 1 ==== R | C - - - > ----------------- 1 [n, n, n] 2 [n, n, n, n, n] 3 [n, n] 4 [n, n, n, n] 5 [n] ex 2 ==== R | C - - - > ----------------------------------------- 1 [n, n, n, n, n, n, n, n, n, n, n, n, n] 2 [s, s, s] 3 [n, n] 4 [s, s, s, s, s, s, s, s] ex 3 ==== R | C - - - > -------------------------------------------------------------- 1 [s, s] 2 [s] 3 [s, s, s, s, s] 4 [s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s] 5 [s, s, s] 6 [n, n, n, n, n, n, n] -
Creating irregularly shaped multi-dim dynamic arrays
JohnLM replied to JohnLM's topic in Algorithms, Data Structures and Class Design
Update. . . Okay, I have finally figured it out. Am running to work but may post an update with a solution or explanation later. . . -
Creating irregularly shaped multi-dim dynamic arrays
JohnLM replied to JohnLM's topic in Algorithms, Data Structures and Class Design
@PeterBelow -- that is my idea too. I just realized now, that you had said this earlier--I missed that part. But yes, I believe that is what I have to do, thanks. -
Creating irregularly shaped multi-dim dynamic arrays
JohnLM replied to JohnLM's topic in Algorithms, Data Structures and Class Design
I don't know why I am having so much trouble with something that seems too easy to accomplish, yet I am. I just got up and saw these posts, and decided to sketch out an illustration of what I am trying to accomplish. Please forgive me if I seem too slow at all this. I am a very slow person these days in my old age. Okay. I have simplified this in an Excel sheet to help illustrate the basic process. * in the finished product, the "irregularly" shaped array should look like what's shown in blue in fig 4. I believe the main part of my problem is that I am doing this setlength() inside the parser routine and that I have to build the irregularly shaped array afterwards once I have the (R,C) criteria in fig 4. Also, I found this link that may help: https://docwiki.embarcadero.com/RADStudio/Athens/en/Structured_Types_(Delphi)#Multidimensional_Dynamic_Arrays PS: I've just updated the grid in fig 4 to show that they are individual elements in the array, not one string.