All Projects → joaoventura → Pylibui

joaoventura / Pylibui

Licence: mit
Pylibui is a Python 3 wrapper for the libui library.

Programming Languages

python
139335 projects - #7 most used programming language

pylibui

Build Status

Python3 wrapper for libui. It uses ctypes to interface with the libui shared library.

Usage

from pylibui.core import App
from pylibui.controls import Window


class MyWindow(Window):

    def onClose(self, data):
        super().onClose(data)
        app.stop()


app = App()

window = MyWindow('Window', 800, 600)
window.setMargined(True)
window.show()

app.start()
app.close()

Build instructions

Clone pylibui:

$ git clone https://github.com/joaoventura/pylibui

Clone libui and build the shared library:

$ git clone https://github.com/andlabs/libui/
$ cd libui
$ mkdir build
$ cd build
$ cmake ..
$ make

The libui shared library will be inside libui/build/out. Copy the contents of out/ to pylibui/libui/sharedlibs. Now, you can use pylibui:

$ python3
>>> import pylibui

Run Tests

The tests are located in the tests folder. To run the entire test suite execute the following in the outer pylibui directory:

$ python3 -m unittest
..
----------------------------------------------------------------------
Ran 20 tests in 0.055s

Ok

To execute a single test file:

$ python3 -m unittest tests/test_window.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.033s

Ok

Contributing

The project is divided in two major sections:

  • pylibui.libui: a ctypes wrapper around the libui C shared library.
  • pylibui: an object oriented pythonic wrapper that makes calls to pylibui.libui.

If you want to contribute, these are the two places that you can implement some code and make a pull request.

If the functionality you are looking for is still not implemented in the pylibui.libui ctypes wrapper, there's two things you may need to do:

  • Implement the function if the function header is already declared (it will have a TODO in there).
  • Generate the function. Use the bindings.py script in scripts/ to generate most of the function declarations for a given section of the "ui.h" header file.

If you need to use the bindings.py file, just run it changing the section that you want to generate the bindings, copy-paste the contents to an empty file, and implement the ctypes calls. Most of them are easy, but you can check what's already done for some guidance.

I'm accepting pull requests if the code is clean and it comes with a working example.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].