It includes
- the object explorer
- the script editor with interactive console
- the error handler
- the source checker
- and an example script which shows to main window in full-screen mode
name =
title =
description =
icon =
menu = ScripterNG
shortcut = # A valid QKeySequence as a string, see Qt4-docs
filename = # name of script file
subroutine = # additional entry point?
author =
contact =
homepage =
version =
copyright = # GPL2
scribus_version =
redraw = True
mode = interactive # allowed: batch, interactive, extension
language = python # allowed: python, qtscript
separator_before = False # in menu
separator_after = False # in menu
background_mode = False # threaded execution only for non-gui scripts
# -*- coding: utf-8 -*-
## name = about
## title = About ScripterNG
## shortcut = Esc,a
# ScripterNG is a builtin and does not need to be imported
ScripterNG.aboutScripterNG()
/// name = aboutqts
/// title = About ScripterNG from QtScript
ScripterNG.aboutScripter();
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class DockDialog(QDockWidget):
def __init__(self, dlg, area=Qt.RightDockWidgetArea):
QDockWidget.__init__(self, dlg.windowTitle())
self.setObjectName(dlg.objectName() or i18n(dlg.windowTitle()))
self.resize(dlg.size())
dlg.parent().addDockWidget(area, self)
dlg.setParent(self)
dlg.move(0, 0)
self.setWidget(dlg)
self.show()
dlg.installEventFilter(self)
def eventFilter(self, obj, event):
return False
if isinstance(event, QCloseEvent) or isinstance(event, QHideEvent):
obj.hide()
self.hide()
return True
elif isinstance(event, QShowEvent):
self.show()
return QDockWidget.eventFilter(self, obj, event)
dockables = ["Properties", "Outline", "Layers", "Arrange Pages",
"Scrapbook", "Bookmarks", "Align and Distribute"]
docks = qApp.docks = {}
for tlw in qApp.topLevelWidgets():
if isinstance(tlw, QDialog):
title = str(tlw.windowTitle())
if i18n(title) in dockables:
docks[title] = DockDialog(tlw)
PyObject *scribus_opendoc(PyObject* /* self */, PyObject* args)
{
char *Name;
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
return NULL;
bool ret = ScCore->primaryMainWindow()->loadDoc(QString::fromUtf8(Name));
if (!ret)
{
PyErr_SetString(ScribusException, QObject::tr("Failed to open document.","python error").toLocal8Bit().constData());
return NULL;
}
return PyBool_FromLong(static_cast(true));
}
bool ScripterNGImpl::openDocument(const QString & filename)
{
bool ret = ScCore->primaryMainWindow()->loadDoc(filename);
if (!ret)
{
RAISE("Cannot open " + filename);
return NULL;
}
return ret;
}
That's all :-)
You only have to make sure the method is defined as a slot or as invokeable. Parsing, checking and converting parameters is not needed anymore. For a more complex method you will save a lot of overhead.
Less code is easier to understand and to modify.
So I hope this will motivate others to contribute to this plug-in.