Configure CMake to use GTK

First install libgtk-3-dev and libgtkmm-3.0-dev then :

cmake_minimum_required(VERSION 3.7)
project(project1)

include(FindPkgConfig)
pkg_check_modules(GTK REQUIRED "gtk+-3.0")

include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})

set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTK3_LIBRARIES})

References :

http://stackoverflow.com/questions/27514291/how-to-add-compiler-arguments-using-cmake

AUTOCOMPLETE WITH PYGOBJECT3 IN PYCHARM

I recently started learning pygobject as part of my gsoc project and a major problem that I faced was not having autocomplete working with the gobject-introspection library in pycharm. No matter how much we deny it autocompletion helps us developers in not repetitively referring to documentation and guides and increases productivity at the same time.

Here is a solution for people faced with the same problem. First we need to edit the pyCharm idea.properties file:

  1. Navigate to the /bin folder.
  2. Locate the idea.properties file and open it for editing. (Chances are you will need to change the permissions.)
  3. Edit the line “idea.max.intellisense.filesize=1024” and make the value something like 10000.
  4. Save it!
  5. Restart pyCharm.

The above steps were done because all the modules in the Gobject-introspection library are binary modules and we need to generate stubs for it in order to have autocompletion. Gtk.py inside the library is too big for the initial buffer size of pyCharm that is 1024 and hence we increase it.

The next steps are fairly simple:

  1. Go to any existing pyGobject project or create a new python file and type or locate the following line:
    from gi.repository import Gtk
  2. Take your cursor to “Gtk” and press alt+enter and click on “Generate stubs for binary module”.
  3. Wait for the processes to finish.

Tada! You will have autocompletion working with Gobject-introspection library. This method can also be used for any other library with a similar problem.

References :

https://udayantandon.wordpress.com/2015/04/28/hello-world/