Commit Graph

20 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
9fe130cd73 All: Reformat according to new standard 2025-11-11 13:49:01 +01:00
Benjamin Bræstrup Sayoc
d0acb9f483 [Gui] Make autocompletion global
Now auto complete is in all TextEdit objects. Fixes #12850
2025-01-22 06:12:43 -06:00
mwganson
40571eb683 [PythonEditor] Make converting tabs to spaces the default 2024-12-23 11:53:05 -05:00
Michael Tuma
32c5968069 Made the interval that the Python profiler runs at configurable
Added a "User parameter:BaseApp/Preferences/PythonConsole/ProfilerInterval" int
property which sets how often (in milliseconds) the Python profiler runs while
Python code is running. Setting this value to zero will totally disable it.

Also added a preference in the Python console screen which allows the user to
set the value of this property to between 0 (disabled) and 5000 (once every 5
seconds). (+1 squashed commits)

Squashed commits:

[cca88ac633] Made the Python profiler only run when the console is running code

This has two purposes. First, it prevents a performance impact from running the
profiler whenever Python code is running. Second, it prevents crashes caused by
Qt's process events function being called too frequently. When the Python code
is running in the console, it monopolizes the main thread and prevents events
from being processed. Therefore, causing events to be processed in the callback
should not force events to be processed too frequently, because the normal loop
is being prevented by the Python code. (+1 squashed commits)

Squashed commits:

[45f86917e6] Made long-running Python code not freeze the GUI without multithreading

Removed the background thread running Python code and replaced it with a custom
profiler which the Python interpreter runs frequently (at every Python opcode I
believe) on the main thread whenever Python code is running. The profiler will
make Qt process any new events every 200 ms, preventing "App not responding"
messages and making sure any Ctrl+C keypresses will be processed. This prevents
the previous issue where running anything GUI-related from Python would crash
the program (because Qt isn't thread-safe). (+1 squashed commits)

Squashed commits:

[0ef7d810b3] Made the process of getting thread IDs cross-platform compatible

Instead of using <threads.h>, now the standard <thread> header from C++
11 is used to find the thread ID, since <threads.h> is apparently not
available on Windows. (+1 squashed commits)

Squashed commits:

[74c7b867f2] # This is a combination of 2 commits.

Python from the console now runs in the background

In a nutshell, all Python code which is input from the interactive console
now runs in a seperate QThread which runs in the background, instead of
on the UI thread. This means that long operates operations will no longer
cause the app to display an "App not responding" message, because the UI
thread is now free to keep running unencumbered.

However, it is still not possible to run multiple Python statements at
the same time. If the user tries to run some Python while a previous
statement is still being processed, instead it will display an error
message in the console stating that the previous command is still
being processed.

I also added a seperate QTimer which runs once every 100ms to flush any
output from the Python code back to the console. I can't flush the output
to the console from the background thread because the relevant Qt5 code
is not thread-safe (it causes random segfaults). So I added this timer
as a work-around, since it runs in the main UI thread.

Implemented Ctrl+C keyboard interrupts in the console

This is implemented by detecting a Ctrl+C key event in the Python
console in the main Qt UI thread, and sending a keyboard interrupt
to the background thread that runs the Python code.
2023-09-08 21:45:10 +02:00
berniev
3877fc62c3 Gui: Single arg ctors must be explicit (PR #7369) 2022-08-24 15:06:03 +02:00
wmayer
c87e1cc1c2 clang: fix warnings [-Winconsistent-missing-override] 2022-08-09 17:36:25 +02:00
berniev
75fa455c5d Gui: Use override etc 2 2022-08-09 12:43:23 +02:00
berniev
3d1f70765a Gui: redundant void 2 2022-08-08 10:21:44 +02:00
wmayer
1178df06b4 Gui: modernize C++11
* use nullptr
2022-03-23 18:41:21 +01:00
wmayer
8f786ea6ef Gui: Optimize includes to reduce compile time 2022-03-07 20:29:18 +01:00
Uwe
4147337715 [Gui] Python and Property: remove unused includes 2022-03-05 03:44:45 +01:00
luz paz
38815b9550 Gui: Fix header uniformity, whitespace, and doxygen fixes 2020-11-26 10:14:56 +01:00
Yorik van Havre
b264e34083 Add Python console option to save history across sessions 2019-09-07 15:26:45 +02:00
wmayer
e3d0ccba33 0000826: reading from the python console for using pdb -- code cleanup 2013-05-14 15:20:00 +02:00
wmayer
145256b4f4 0000826: reading from the python console for using pdb 2012-09-08 13:01:02 +02:00
wmayer
3df84b35f1 0000822: Two little tweaks for the python console 2012-09-05 16:01:39 +02:00
wmayer
0c5771d392 Improve sys.stdin redirection mechanism 2012-02-28 13:20:34 +01:00
wmayer
0748b1fa77 0000530: Python Console allows editing of history
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5258 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-12-10 18:40:03 +00:00
wmayer
6ed7ad3a15 0000489: python console: "RFC"s for even more "rapid" prototyping :-)
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5253 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-12-10 14:40:44 +00:00
wmayer
120ca87015 + unify DLL export defines to namespace names
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-10-10 13:44:52 +00:00