Python debugger, python editor

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

Turning this into a FreeCAD-Addon https://github.com/FreeCAD/FreeCAD-addons/issues/30 that can be downloaded through the Addon Manager makes sense so people can test it in a more streamlined way.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Python debugger, python editor

Post by sgrogan »

Kunda1 wrote: Tue May 30, 2017 1:18 pm Turning this into a FreeCAD-Addon https://github.com/FreeCAD/FreeCAD-addons/issues/30 that can be downloaded through the Addon Manager
I think this would be rather difficult. The code is in C++ so it needs to be compiled. It seems most of the code is in src/Gui so probably not so simple to split out. If there are interested Win users I can probably make some win test builds but the branch hasn't been rebased on master in a while.
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

sgrogan wrote:
Kunda1 wrote: Turning this into a FreeCAD-Addon https://github.com/FreeCAD/FreeCAD-addons/issues/30 that can be downloaded through the Addon Manager
I think this would be rather difficult. The code is in C++ so it needs to be compiled. It seems most of the code is in src/Gui so probably not so simple to split out. If there are interested Win users I can probably make some win test builds but the branch hasn't been rebased on master in a while.
mumme wrote: Wed May 17, 2017 6:37 pm Sorry for the late response, is currently busy with other stuff (real life commitments)
@mumme would you mind rebasing your branch to master so we could run tests on this ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Python debugger, python editor

Post by sgrogan »

Kunda1 wrote: Tue May 30, 2017 9:24 pm @mumme would you mind rebasing your branch to master so we could run tests on this ?
No problem rebasing, branch here: https://github.com/sgrogan/FreeCAD/commits/editor_fixes
(Travis will fail on my repo as timed out)
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

sgrogan wrote: Tue May 30, 2017 9:57 pm
Kunda1 wrote: Tue May 30, 2017 9:24 pm @mumme would you mind rebasing your branch to master so we could run tests on this ?
No problem rebasing, branch here: https://github.com/sgrogan/FreeCAD/commits/editor_fixes
(Travis will fail on my repo as timed out)
Oh cool. Good news!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

sgrogan wrote: Tue May 30, 2017 9:57 pm
Kunda1 wrote: Tue May 30, 2017 9:24 pm @mumme would you mind rebasing your branch to master so we could run tests on this ?
No problem rebasing, branch here: https://github.com/sgrogan/FreeCAD/commits/editor_fixes
(Travis will fail on my repo as timed out)
@sgrogan I think you should build it for win and I'll advertise it so we can get testers. Would it be difficult to build for Linux?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
mumme
Posts: 35
Joined: Sun Jun 21, 2015 4:52 pm

Re: Python debugger, python editor

Post by mumme »

Well I realize that I been quiet some maybe to long, apologize for that. I was somewhat overworked on my daytime job as teacher..

In any case, I have now managed to find some more time during my vacation. So I have do some more changes, learning as I go.

Currently I managed to rebase my brash from master, I am not that knoledgable about git so i hope i didn't do something wrong.
I have opened a bug /issue reporter on github as well as wiki, if anybody want to fill in...

Changes since april:
  • Debugger more stable (sure there are more issues to be found though...)
  • Debugging into a function in another file opens that file
  • Syntax errors are displayed in editor
  • Halts on the line of an exception (also has a issues browser widget)

    If python lib Jedi is installed (My code is in c++ but calls python code in another separate interpreter, avoids messing up ordinary interpreter)
  • Code completion available with documentation in tooltip
  • Due to Jedi it also makes good guess the type of of assigned variables
  • Function arguments displayed above above the line you type
if __doc__ string for function is formated as :

Code: Select all

      def myFunction(node, callback):
            '''myFunction does.....
           :param node:      Int, Which node
           :param callback: Function, Do something when done 
            '''
           ------------------------------------------------------
          | Function, Do something when done
          | myFunction(node1, callback)          
          -------------------------------------------------------
       myFunc(mynode, # <- cursor    )
    
It shows documentation for just arg1 when you type that, arg2 in its place etc.

I have not tried the code on anything other than qt 4.8 python 2.7 and ubuntu 16.10 yet.
I have python 2.7 built with debug symbols, thats why...

For you who have tested it and , thank you for that..
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

Thanks mumme!

Edit: @mumme BTW, how can we do this so that the debugger can be installed through FreeCAD-addons ? I've already opened a ticket: https://github.com/FreeCAD/FreeCAD-addons/issues/30
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
mumme
Posts: 35
Joined: Sun Jun 21, 2015 4:52 pm

Re: Python debugger, python editor

Post by mumme »

Kunda1 wrote: Wed Jul 12, 2017 6:25 pm Thanks mumme!

Edit: @mumme BTW, how can we do this so that the debugger can be installed through FreeCAD-addons ? I've already opened a ticket: https://github.com/FreeCAD/FreeCAD-addons/issues/30
Well all changes is to FreeCAD Gui so it certainly wont happen without changes to FreeCAD core
Debugger, macro editor, syntaxhighlighter etc are all part of FreeCAD core.

These classes are already there, I only enhanced them.

What would be possible is an external window script editor , like the VBA IDE for ms office or script editor for google docs.
That would be able to handle workbench development as well.

Also I was under the impression that FreeCAD addons was for python only?
All these changes are C++

My driving force behind this is to make it easier for others (and myself) to develop quality scripts, or workbenches, for FreeCAD.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python debugger, python editor

Post by Kunda1 »

FYI latest rebased branch is at:
https://github.com/mumme74/FreeCAD/tree/editor_fixes
Issues/Bugs can be opened at: https://github.com/mumme74/FreeCAD/issues
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply