Guide:Mod Organizer/Python Plugins: Difference between revisions

From Step Mods | Change The Game
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="margin-top:-2px">< [[Guide:Mod_Organizer|Guide:Mod Organizer]]</div>
[[Category:Deprecated Guides]]{{TOC}}
__TOC__


=How to add Python plugins to Mod Organizer=
==Requirements==
 
==requirements==
* MS Windows and MO ^^
* MS Windows and MO ^^
* python 2.7 programming language (32 Bit): http://www.python.org/download/releases/2.7.6/
* python 2.7 programming language (32 Bit): https://www.python.org/download/releases/2.7.6/
** [http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi direct link]
** [https://www.python.org/ftp/python/2.7.6/python-2.7.6.msi direct link]


===requirements for  user interface (optional)===
===requirements for  user interface (optional)===


* [http://download.qt-project.org/archive/qt/4.8/4.8.4/ Qt Framework] - includes the Qt Designer (creates .ui files)
* [https://download.qt-project.org/archive/qt/4.8/4.8.4/ Qt Framework] - includes the Qt Designer (creates .ui files)
** [http://download.qt-project.org/archive/qt/4.8/4.8.4/qt-win-opensource-4.8.4-mingw.exe direct link (mingw version)]
** [https://download.qt-project.org/archive/qt/4.8/4.8.4/qt-win-opensource-4.8.4-mingw.exe direct link (mingw version)]
** an IDE (like VisualC, MinGw) is not necessary for this purpose and can be skipped during install
** an IDE (like VisualC, MinGw) is not necessary for this purpose and can be skipped during install
* [http://www.riverbankcomputing.com/software/pyqt/download PyQt4] - dev files for Qt usage in python 2.7
* [https://www.riverbankcomputing.com/software/pyqt/download PyQt4] - dev files for Qt usage in python 2.7
** [http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.3/PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe direct link]
** [https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.3/PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe direct link]


PyQt4 comes with '''pyuic'''
PyQt4 comes with '''pyuic'''
  Location: Python27\Lib\site-packages\PyQt4\uic\pyuic.py  
  Location: Python27/Lib/site-packages/PyQt4/uic/pyuic.py  


it generates .py commands from a Qt4 .ui file:
it generates .py commands from a Qt4 .ui file:
Line 33: Line 30:
from PyQt4 import QtCore, QtGui
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt, pyqtWrapperType, pyqtSlot, pyqtSignal
from PyQt4.QtCore import Qt, pyqtWrapperType, pyqtSlot, pyqtSignal
from PyQt4.QtGui import QDialog, QHeaderView, QMessageBox, QColorDialog, QPalette, QTreeWidgetItem,\
from PyQt4.QtGui import QDialog, QHeaderView, QMessageBox, QColorDialog, QPalette, QTreeWidgetItem,/
QComboBox, QPushButton, QDoubleSpinBox, QHBoxLayout, QWidget, QSlider, QSpinBox, QLineEdit
QComboBox, QPushButton, QDoubleSpinBox, QHBoxLayout, QWidget, QSlider, QSpinBox, QLineEdit
pyqt5 = False
pyqt5 = False
Line 78: Line 75:


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.
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.
[[Category:Advanced_Topics]]

Latest revision as of 03:33, January 2, 2023

Requirements

requirements for user interface (optional)

PyQt4 comes with pyuic

Location: Python27/Lib/site-packages/PyQt4/uic/pyuic.py 

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

pyuic.py YOURDESIGN.ui > YOURDESIGN.py


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.