Customize The User Interface

The Rumba user interface is done with Qt 5 and Pyside 2.

You can simply access the different elements of the user interface and modify them or create new user interface elements.

Access the main Qt Widgets

Here is how you can access some of the main Qt widgets:

  • python
import rumbapy
main_window = rumbapy.widget("MainWindow")
main_viewport = rumbapy.widget("MainViewport")

See also

The rumbapy.widget() for more information.

Create custom menus and toolbars

  • python
import rumbapy
from PySide2 import QtWidgets
main_window = rumbapy.widget("MainWindow")

# Add a new menu
my_menu = main_window.menubar.addMenu("&My Menu")

# Create an action using the rumbapy module, you can also use regular Qt actions.
# Using rumbapy actions, the user will be able to choose the shortcut with the Shortcut Editor.
# Store your custom icons in a path registered in the RUMBA_USER_RESOURCES environment variable
action = rumbapy.action.new(name="My Action", widget=main_window, trigger=lambda: print("Action!"), icon="asset", shortcut=None)

# Add the action to the menu
my_menu.addAction(action)

# Create a toolbar with the same action
toolbar = main_window.addToolBar("My Toolbar")
toolbar.addAction(action)

See also

The rumbapy.action.new() for more information.

Create a floating window

  • python
import rumbapy
from PySide2 import QtWidgets
main_window = rumbapy.widget("MainWindow")
window = QtWidgets.QMainWindow(main_window)
window.setWindowTitle('MyWindow')
window.show()

See also

The Qt documentation: https://doc.qt.io/qt-5

Writing a GUI plug-in called at Rumba start

Here is how to register a GUI plug-in. This plug-in will be run at Rumba start-up to customize the GUI.

  • python
import rumbapy
from rumbapy.WidgetPlugins import register_ui, UIPluginOptions
from PySide2 import QtWidgets, QtCore

class MyTools(QtCore.QObject):

    def __init__(self, parent):
        super(MyTools, self).__init__(parent)

        main_window = rumbapy.widget("MainWindow")

        # Add A new menu
        my_menu = main_window.menubar.addMenu("&My Menu")
        action = rumbapy.action.new(name="My Action", widget=main_window, trigger=doIt, icon="asset", shortcut=None)

        # Add the action to the menu
        my_menu.addAction(action)

    def doIt(self):
        main_window = rumbapy.widget("MainWindow")
        QtWidgets.QMessageBox.information(main_window, 'Here', 'Congrats!')

register_ui(MyTools, "MyTools", UIPluginOptions(auto_create=True))

Put your code in a Python file in a plug-in directory.

See also