我一直在使用一个c ++包装器,用于在Linux上将函数导出到python一段时间.现在我想让我的同事使用Windows.但是,我无法在cygwin中为此创建一个可用的boost_python dll.当我尝试将依赖模块链接到另一个dll时,如果我将依赖源编译到它按预期工作的相同dll中,则会出现问题.
我创建了一个显示问题的最小示例:
设置:
moduleB/moduleB.cpp#boost包装器代码
#include <python2.7/Python.h>
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "submodule.hpp"
using namespace boost::python;
using namespace testspace;
using namespace std;
struct cModuleB : public SubModuleClass {
cModuleB(string name, bool boolVar) : SubModuleClass(name, boolVar) {
}
void printFunc(string strVar, list listVar, int nIntVar=-1) {
vector<int> vecList;
for (int l=0; l < len(listVar); l++) {
vecList.push_back(extract<int>(listVar[l]));
}
bool bMoreThanHalf = subModuleFunction(vecList);
if (bMoreThanHalf) {
cout << "More than half elements are more than 1";
}
return;
}
};
BOOST_PYTHON_MODULE(moduleB) …Run Code Online (Sandbox Code Playgroud) 我已经安装和二者试图wxpython-3.0和wxpython-2.8用于python2.7从标准cygwin回购(64位,运7).但是,当我启动Cygwin X服务器并尝试从wxPython教程运行最简单的"Hello World"脚本时:
# test.py
import wx
app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True) # Show the frame.
app.MainLoop()
Run Code Online (Sandbox Code Playgroud)
我得到一个Gtk-WARNING **: Screen for GtkWindow not set最终以a结尾segmentation fault.
该DISPLAY变量被设置为:0(export DISPLAY=:0),对应于所启动的X服务器.
在cygwin使用wxPython启动脚本之前,wxPython是否已被破坏或是否需要其他一些过程?
我想创建一个简单的“关于”对话框,但是注意到QMessageBox::about并没有将其大小调整为标题的长度(由于字体较大而通常更长,至少在我的桌面环境中这样),仅针对内容。有没有办法确保对话框足够大以显示所有标题?我当然可以在aboutText上添加空格,但是我希望找到一种更简洁的解决方案。
例:
QString titleText("Some title which is slightly longer");
QString aboutText("Short about text");
QMessageBox::about(this,titleText,aboutText);
Run Code Online (Sandbox Code Playgroud)
目前,上面的代码仅给我提供“ Some ...”作为标题字符串。我已经在Qt 4.7的Ubuntu上的Eclipse中构建了该程序。