Guide:Mod Organizer/Python Plugins

From Step Mods | Change The Game
< Guide:Mod Organizer
Revision as of 03:33, January 2, 2023 by Z929669 (talk | contribs) (Z929669 moved page Guide:Mod Organizer/PythonPlugins to Guide:Mod Organizer/Python Plugins)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


requirements for user interface (optional)

PyQt4 comes with pyuic

Location: Python27/Lib/site-packages/PyQt4/uic/ 

it generates .py commands from a Qt4 .ui file: YOURDESIGN.ui >

Hello World app

still got a bug in there, but the source gives you an idea how a simple plugin will work:

	import os
	import sys
	from PyQt4 import QtCore, QtGui
	from PyQt4.QtCore import Qt, pyqtWrapperType, pyqtSlot, pyqtSignal
	from PyQt4.QtGui import QDialog, QHeaderView, QMessageBox, QColorDialog, QPalette, QTreeWidgetItem,/
	QComboBox, QPushButton, QDoubleSpinBox, QHBoxLayout, QWidget, QSlider, QSpinBox, QLineEdit
	pyqt5 = False

	if not "mobase" in sys.modules:
		import mock_mobase as mobase

	class YourHelloWorldPlugin(mobase.IPluginTool):
		def init(self, organizer):
			#self.__organizer = organizer
			self.__parentWidget = None
			return True

		def name(self):
			return "HelloWorld"

		def author(self):
			return "plugin creator"

		def description(self):
			return "Hello World-Plugin to show you how it's done."

		def version(self):
			#return mobase.VersionInfo(0, 0, 1, mobase.ReleaseType.prealpha)
			return True

		def isActive(self):
			return True

		def settings(self):
			return []
		def displayName(self):
			return "HelloWorld"

		def tooltip(self):
			return "Modify game Configuration"

	def createPlugin():
			return YourHelloWorldPlugin()

if you place a file with a similiar structure inside the /plugins/ dir, MO will automatically find it and add it to the tools list.