本文整理汇总了C++中py::List::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ List::begin方法的具体用法?C++ List::begin怎么用?C++ List::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py::List
的用法示例。
在下文中一共展示了List::begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ui
TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o)
{
if (dlg.hasAttr(std::string("ui"))) {
UiLoader loader;
#if QT_VERSION >= 0x040500
loader.setLanguageChangeEnabled(true);
#endif
QString fn, icon;
Py::String ui(dlg.getAttr(std::string("ui")));
std::string path = (std::string)ui;
fn = QString::fromUtf8(path.c_str());
QFile file(fn);
QWidget* form = 0;
if (file.open(QFile::ReadOnly))
form = loader.load(&file, 0);
file.close();
if (form) {
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
QPixmap(icon), form->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(form);
Content.push_back(taskbox);
}
else {
Base::Console().Error("Failed to load UI file from '%s'\n",
(const char*)fn.toUtf8());
}
}
else if (dlg.hasAttr(std::string("form"))) {
Py::Object f(dlg.getAttr(std::string("form")));
Py::List widgets;
if (f.isList()) {
widgets = f;
}
else {
widgets.append(f);
}
for (Py::List::iterator it = widgets.begin(); it != widgets.end(); ++it) {
Py::Module mainmod(PyImport_AddModule((char*)"sip"));
Py::Callable func = mainmod.getDict().getItem("unwrapinstance");
Py::Tuple arguments(1);
arguments[0] = *it; //PyQt pointer
Py::Object result = func.apply(arguments);
void* ptr = PyLong_AsVoidPtr(result.ptr());
QObject* object = reinterpret_cast<QObject*>(ptr);
if (object) {
QWidget* form = qobject_cast<QWidget*>(object);
if (form) {
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
form->windowIcon().pixmap(32), form->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(form);
Content.push_back(taskbox);
}
}
}
}
}
示例2: ui
TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o)
{
if (dlg.hasAttr(std::string("ui"))) {
UiLoader loader;
#if QT_VERSION >= 0x040500
loader.setLanguageChangeEnabled(true);
#endif
QString fn, icon;
Py::String ui(dlg.getAttr(std::string("ui")));
std::string path = (std::string)ui;
fn = QString::fromUtf8(path.c_str());
QFile file(fn);
QWidget* form = 0;
if (file.open(QFile::ReadOnly))
form = loader.load(&file, 0);
file.close();
if (form) {
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
QPixmap(icon), form->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(form);
Content.push_back(taskbox);
}
else {
Base::Console().Error("Failed to load UI file from '%s'\n",
(const char*)fn.toUtf8());
}
}
else if (dlg.hasAttr(std::string("form"))) {
Py::Object f(dlg.getAttr(std::string("form")));
Py::List widgets;
if (f.isList()) {
widgets = f;
}
else {
widgets.append(f);
}
Gui::PythonWrapper wrap;
if (wrap.loadCoreModule()) {
for (Py::List::iterator it = widgets.begin(); it != widgets.end(); ++it) {
QObject* object = wrap.toQObject(*it);
if (object) {
QWidget* form = qobject_cast<QWidget*>(object);
if (form) {
Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(
form->windowIcon().pixmap(32), form->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(form);
Content.push_back(taskbox);
}
}
}
}
}
}
示例3: setHighlightedNodes
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
{
std::set<long> res;
for( Py::List::iterator it = arg.begin(); it!= arg.end(); ++it) {
Py::Int id(*it);
if(id)
res.insert(id);
}
this->getViewProviderFemMeshPtr()->setHighlightNodes(res);
}
示例4: setA
void MatrixPy::setA(Py::List arg)
{
double mat[16];
this->getMatrixPtr()->getMatrix(mat);
int index=0;
for (Py::List::iterator it = arg.begin(); it != arg.end() && index < 16; ++it) {
mat[index++] = (double)Py::Float(*it);
}
this->getMatrixPtr()->setMatrix(mat);
}
示例5: setCommands
void PathPy::setCommands(Py::List list)
{
getToolpathPtr()->clear();
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
if (PyObject_TypeCheck((*it).ptr(), &(Path::CommandPy::Type))) {
Path::Command &cmd = *static_cast<Path::CommandPy*>((*it).ptr())->getCommandPtr();
getToolpathPtr()->addCommand(cmd);
} else {
throw Py::Exception("The list can only contain Path Commands");
}
}
}
示例6: extractTipsFromObject
void CallTipsList::extractTipsFromObject(Py::Object& obj, Py::List& list, QMap<QString, CallTip>& tips) const
{
try {
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
Py::String attrname(*it);
Py::Object attr = obj.getAttr(attrname.as_string());
CallTip tip;
QString str = QString::fromLatin1(attrname.as_string().c_str());
tip.name = str;
if (attr.isCallable()) {
union PyType_Object basetype = {&PyBaseObject_Type};
if (PyObject_IsSubclass(attr.ptr(), basetype.o) == 1) {
tip.type = CallTip::Class;
}
else {
PyErr_Clear(); // PyObject_IsSubclass might set an exception
tip.type = CallTip::Method;
}
}
else if (PyModule_Check(attr.ptr())) {
tip.type = CallTip::Module;
}
else {
tip.type = CallTip::Member;
}
if (str == QLatin1String("__doc__") && attr.isString()) {
Py::Object help = attr;
if (help.isString()) {
Py::String doc(help);
QString longdoc = QString::fromUtf8(doc.as_string().c_str());
int pos = longdoc.indexOf(QLatin1Char('\n'));
pos = qMin(pos, 70);
if (pos < 0)
pos = qMin(longdoc.length(), 70);
tip.description = stripWhiteSpace(longdoc);
tip.parameter = longdoc.left(pos);
}
}
else if (attr.hasAttr("__doc__")) {
Py::Object help = attr.getAttr("__doc__");
if (help.isString()) {
Py::String doc(help);
QString longdoc = QString::fromUtf8(doc.as_string().c_str());
int pos = longdoc.indexOf(QLatin1Char('\n'));
pos = qMin(pos, 70);
if (pos < 0)
pos = qMin(longdoc.length(), 70);
tip.description = stripWhiteSpace(longdoc);
tip.parameter = longdoc.left(pos);
}
}
tips[str] = tip;
}
}
catch (Py::Exception& e) {
// Just clear the Python exception
e.clear();
}
}
示例7: sysmod
PythonInterpreter::PythonInterpreter(Kross::InterpreterInfo* info)
: Kross::Interpreter(info)
, d(new PythonInterpreterPrivate())
{
// Initialize the python interpreter.
initialize();
// Set name of the program.
Py_SetProgramName(const_cast<char*>("Kross"));
/*
// Set arguments.
//char* comm[0];
const char* comm = const_cast<char*>("kross"); // name.
PySys_SetArgv(1, comm);
*/
// In the python sys.path are all module-directories are
// listed in.
QString path;
// First import the sys-module to remember it's sys.path
// list in our path QString.
Py::Module sysmod( PyImport_ImportModule( (char*)"sys" ), true );
Py::Dict sysmoddict = sysmod.getDict();
Py::Object syspath = sysmoddict.getItem("path");
if(syspath.isList()) {
Py::List syspathlist = syspath;
for(Py::List::iterator it = syspathlist.begin(); it != syspathlist.end(); ++it) {
if( ! (*it).isString() ) continue;
QString s = PythonType<QString>::toVariant(*it);
path.append( s + PYPATHDELIMITER );
}
}
else
path = Py_GetPath();
#if 0
// Determinate additional module-paths we like to add.
// First add the global Kross modules-path.
QStringList krossdirs = KGlobal::dirs()->findDirs("data", "kross/python");
for(QStringList::Iterator krossit = krossdirs.begin(); krossit != krossdirs.end(); ++krossit)
path.append(*krossit + PYPATHDELIMITER);
// Then add the application modules-path.
QStringList appdirs = KGlobal::dirs()->findDirs("appdata", "kross/python");
for(QStringList::Iterator appit = appdirs.begin(); appit != appdirs.end(); ++appit)
path.append(*appit + PYPATHDELIMITER);
#endif
// Set the extended sys.path.
PySys_SetPath( (char*) path.toLatin1().data() );
#ifdef KROSS_PYTHON_INTERPRETER_DEBUG
krossdebug(QString("Python ProgramName: %1").arg(Py_GetProgramName()));
krossdebug(QString("Python ProgramFullPath: %1").arg(Py_GetProgramFullPath()));
krossdebug(QString("Python Version: %1").arg(Py_GetVersion()));
krossdebug(QString("Python Platform: %1").arg(Py_GetPlatform()));
krossdebug(QString("Python Prefix: %1").arg(Py_GetPrefix()));
krossdebug(QString("Python ExecPrefix: %1").arg(Py_GetExecPrefix()));
//krossdebug(QString("Python Path: %1").arg(Py_GetPath()));
//krossdebug(QString("Python System Path: %1").arg(path));
#endif
// Initialize the main module.
d->mainmodule = new PythonModule(this);
// The main dictonary.
Py::Dict moduledict = d->mainmodule->getDict();
//TODO moduledict["KrossPythonVersion"] = Py::Int(KROSS_PYTHON_VERSION);
// Prepare the interpreter.
QString s =
//"# -*- coding: iso-8859-1 -*-\n"
//"import locale\n"
//"locale.setlocale(locale.LC_ALL, '')\n"
//"# -*- coding: latin-1 -*\n"
//"# -*- coding: utf-8 -*-\n"
//"import locale\n"
//"locale.setlocale(locale.LC_ALL, '')\n"
//"from __future__ import absolute_import\n"
"import sys\n"
//"import os, os.path\n"
//"sys.setdefaultencoding('latin-1')\n"
// Dirty hack to get sys.argv defined. Needed for e.g. TKinter.
"sys.argv = ['']\n"
// On the try to read something from stdin always return an empty
// string. That way such reads don't block our script.
// Deactivated since sys.stdin has the encoding attribute needed
// by e.g. LiquidWeather and those attr is missing in StringIO
// and cause it's buildin we can't just add it but would need to
// implement our own class. Grrrr, what a stupid design :-/
//"try:\n"
//" import cStringIO\n"
//" sys.stdin = cStringIO.StringIO()\n"
//"except:\n"
//" pass\n"
// Class to redirect something. We use this class e.g. to redirect
//.........这里部分代码省略.........