New Developer Looking For Some Code Pointers

Tags: #<Tag:0x00007f362b32ff10>

Hello All,
I recently tried MyPaint as I wanted a simple and straightforward sketching/drawing application to draw up some flow diagrams etc and although my needs are far from artistic I found MyPaint really good at doing just what I wanted to do - draw simple shapes easily and fast. Just like sketching out on paper.

There are a couple of things I would like to contribute to MyPaint as I am a programmer so I am currently attempting to grasp the MyPaint source. I come from a Java/Scala and a bit of C/C++ background and I’ve always wanted to learn Python so contributing seems a good way to go.

This is what I have achieved so far

  1. Checked out the code including the required C libraries and built them locally
  2. Built and installed MyPaint (locally) using the MyPaint setup.py script
  3. I’m an IntelliJ user so I am using PyCharm to execute MyPaint but I can also execute the latest ‘master’ from commandline.

This is what I am struggling with - would like a few pointers if possible

  1. Trying to understand how the UI is built up on application startup. I see that Glade is used in the layout and there are .po files for internationalisation but I can’t yet grasp how all these are combined to produce the UI. For example, I would like to add a ‘select region’ tool so I would want to add in a new menu item somewhere. Could someone perhaps give me a few more pointers now that I have got beyond the initial build & starting up of the application?
  2. Is there anyway I can run MyPaint without having to do the build-and-install process? As I come from a IntelliJ-Java/Scala background, I know it does a lot for me in the background when I start an application but crucially I can place breakpoints on the source code - with MyPaint and PyCharm I need to build/install for the application to even run and then I need to put break points on the installed source code - which is a bit of a pain. Is there anyway I can avoid having to do this?

Hi,

in reverse order:

2.
You can run the program from source if you copy the file _mypaintlib.so to the lib directory. Running python setup.py test will perform this copy before running the actual tests. After the build (which you have already done), you can run that in a terminal and cancel it after the copying step.

Once the .so file is in the right place, you would create a run configuration in PyCharm that simply sets mypaint.py as the script path, assuming that the working directory is the mypaint source root, which it should be by default. If you want debug-level logging to show up, you need to add MYPAINT_DEBUG=1 to the Environment variables field.

If you run that configuration in debug mode you should be able to set breakpoints directly in the editor and get a nice overview when they are hit.

1.
I would start by taking a single tool, such as the frame tool, and find out how it is set up. The kind of thing you have in mind would probably involve a separate mode, like how the fill tool is separate from the freehand brush. It would, no matter what, involve a new GtkAction (yes, they are technically deprecated), all of which are declared in the file gui/resources.xml.

Hi jpll,

Thanks for the pointers. I’ll take a look into your suggestions.

As well as ‘select tool’ (keeping it simple at first with rectangular drag-and-select-an-area) I was thinking of adding a nib/brush size palette (unless such a thing already exists). It would be handy for me to be able to quickly change between a set of defined sizes rather than having to change the size slider.