Source code for

from PyQt5.QtWidgets import QDockWidget, QMainWindow
import json

[docs]class GAPlugin(object): """ The GAPlugin is the Base-Class for all Plugins. For creating your own Plugin, subclass GAPlugin an overwrite the GAPlugin.get_window() function. Access current Project by using GAPlugin.get_project(). """
[docs] def __init__(self, main_window, plugin_name = "Plugin", windowtype = GAPLUGIN_WNDTYPE_MAINWINDOW): """ Initializes a Plugin. :param main_window: The VIAN MainWindow. :param plugin_name: The Name of the Plugin :param windowtype: The returned WindowType, specified in This should be a variant of GAPLUGIN_WNDTYPE_* """ self.plugin_name = plugin_name self.main_window = main_window self.windowtype = windowtype
[docs] def get_window(self, parent): """ This function should be overwritten shows your Plugin-Window. This can either be an EDockWidget or a WMainWindow. (Specified accordingly to the GAplugin.windowtype) :param parent: """ wnd = QMainWindow(self.main_window) wnd.setWindowTitle(self.plugin_name)
def get_project(self): return self.main_window.project def store_plugin_settings(self, plugin_dict): with open(self.main_window.settings.DIR_PLUGINS + self.plugin_name.replace(" ", "_") + ".json", "w") as file: json.dump(plugin_dict, file) def load_plugin_settings(self): try: with open(self.main_window.settings.DIR_PLUGINS + self.plugin_name.replace(" ", "_") + ".json", "r") as file: return json.load(file) except: return None