-windows
This demo shows how you can use cvui in an application that uses more than one OpenCV window. When using cvui with multiple OpenCV windows, you must call cvui component calls between cvui.contex(NAME) and cvui.update(NAME), where NAME is the name of the window. That way, cviu knows which window you are using (NAME in this case), so it can track mouse events, for instance. E.g. # Code for window 'window1'. cvui.context('window1') cviu.text(frame, ...) cviu.button(frame, ...) cviu.update('window1') # somewhere else, code for 'window2' cvui.context('window2') cviu.printf(frame, ...) cviu.printf(frame, ...) cviu.update('window2') # Show everything in a window cv2.imshow(frame) Pay attention to the pair cvui.context(NAME)/cviu.update(NAME), which encloses the component calls for that window. You need such pair for each window of your application. After calling cvui.update(), you can show the result in a window using cv2.imshow(). If you want to save some typing, you can use cvui.imshow(), which calls cvui.update() for you and then shows the frame in a window. E.g. # Code for window 'window1'. cvui.context('window1') cviu.text(frame, ...) cviu.button(frame, ...) cviu.imshow('window1') # somewhere else, code for 'window2' cvui.context('window2') cviu.printf(frame, ...) cviu.printf(frame, ...) cviu.imshow('window2') In that case, you don't have to bother calling cvui.update() yourself, since cvui.imshow() will do it for you. Copyright (c) 2018 Fernando Bevilacqua <dovyski@gmail.com> Licensed under the MIT license.