我正在尝试使用Twitter的bootstrap快速几页.我在获取文本字段时遇到问题,就像在http://twitter.github.com/bootstrap/上一样
我的HTML看起来像
<div class="clearfix">
<label for="unit">unit</label>
<div class="input">
<input class="xlarge" id="unit" name="unit" type="text" value="" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这似乎是我在演示页面上看到的所有相关CSS类.但是,我的文本输入字段在输入区域垂直方向上渲染太小,因此光标和文本与输入区域的底部边框重叠.这是win7上最新的chrome.

尝试按照GIL的设计指南工作,我bits__用于我的频道数据类型.我经常将外部数据包装到GIL图像视图中.但是,即使使用bits__数据指针的类型,我也必须在我创建图像视图之前添加reinterpret_cast.请使用以下代码
int width = 3;
int height = 2;
boost::gil::bits8 data8[] = {0, 1, 100, 200, 50, 51};
boost::gil::bits8* pBits8 = data8;
boost::gil::gray8_ptr_t pGray8 = pBits8;
boost::gil::gray8_view_t v = interleaved_view(width, height, pGray8, width * sizeof(boost::gil::bits8));
Run Code Online (Sandbox Code Playgroud)
导致第6行的错误"错误C2440:'初始化':无法从'boost :: gil :: bits8*'转换为'boost :: gil :: gray8_ptr_t'1>指向的类型不相关;转换需要reinterpret_cast, C风格演员或功能风格演员阵容"
尽可能多地深入研究源代码,看起来这些类型确实是未发布的.bits8只是unsigned char,但是gray8_ptr_t指向a的指针struct pixel<bits8,gray_layout_t>.这个结构的唯一元素是单个bit8,因此reinterpret_cast看起来很安全.它也适用于我抛出的测试.
但是,我经常将外部数据包装到图像视图中,并且在每个地方都进行reinterpret_cast会产生问题.有没有更安全的方法来构建用于GIL的像素指针?
目前的解决方法:
template<class Dest, class Src>
Dest gil_safe_ptr_cast(Src src)
{
// this cast is unsafe, use reinterpret_cast
BOOST_STATIC_ASSERT(false);
}
template<> boost::gil::gray8_ptr_t gil_safe_ptr_cast(boost::gil::bits8* …Run Code Online (Sandbox Code Playgroud) 我的问题类似于如何在给定完整路径的情况下导入模块?但是,我没有导入.py源文件,而是导入了带有.pyd的程序包。
在运行时,我根据一些动态生成的c代码创建新的软件包模块。我成功生成了包含__init__.py文件和F的软件包Foo mod.pyd:
/a/temp/dir/foo/
__init__.py
bar.pyd
Run Code Online (Sandbox Code Playgroud)
我正在使用的示例代码是
import importlib.util
spec = importlib.util.spec_from_file_location("foo.bar", "/path/to/file.py")
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
foo.bar()
Run Code Online (Sandbox Code Playgroud)
如果我尝试从pyd 使用spec_from_file_location('foo.bar', '/a/temp/dir/foo/__init__.py')模块bar,则无法加载。
如果我尝试使用,spec_from_file_location('foo.bar', '/a/temp/dir/foo/')则spec_from_file_location返回None。
如果尝试使用spec_from_file_location('foo.bar', '/a/temp/dir/foo/bar.pyd'),则会出现以下错误堆栈:
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 903, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
Run Code Online (Sandbox Code Playgroud)
推荐的4行importlib解决方案的替代方法是为MetaPathFinder和创建具体的类SourceLoader。我的以下 …
我正在尝试使用Boost.Python将ac库包装在高级python接口中.c库的一个客户端契约是其中一个句柄每个进程只能分配一次.我希望我可以通过使用全局模块在python端强制执行此合同.
这是我的django组件模块__init__.py.PyGenTL每个进程只能创建一次!
import my_c_mod
import os
print "imager__init__()"
print os.getpid()
ptl = my_c_mod.PyGenTL()
Run Code Online (Sandbox Code Playgroud)
稍微相关的Boost.Python代码
BOOST_PYTHON_MODULE(my_c_mod)
{
using namespace boost::python;
// Create the Python type object for our extension class and define __init__ function.
class_<PyGenTL>("PyGenTL")
.def("sys_info", &PyGenTL::SysInfo)
.def("list_cameras", &PyGenTL::ListCameras) //
.def("start_camera", &PyGenTL::StartCamera) //
;
}
PyGenTL::PyGenTL()
{
try {
std::cout << "PyGenTL ctor(): allocating GenTL Lib." << std::endl;
Detail::ThrowError(GCInitLib());
Detail::ThrowError(TLOpen(&hTL));
} catch (boost::exception& e) {
std::cerr << "PyGenTL ERROR! ";
std::cerr << boost::diagnostic_information(e);
std::cerr << std::endl;
} …Run Code Online (Sandbox Code Playgroud) 我正在编写一个快速应用程序来查看一个带有一些AJAX样式调用的巨型XML文件viewgroup.我的问题session['groups']不是坚持下去.我有一些旧的阵列只有4个成员卡在某处(cookie?..).view调用时会出现该值.然后,我用最近打开的包含20多个成员的xml文件中的信息覆盖该会话成员.
但是,当viewgroup调用时,会话变量已恢复为旧值,数组中只有4个成员!
代码后跟输出.注意3个sessionStatus()电话
def sessionStatus():
print "# of groups in session = " + str(len(session['groups']))
@app.route('/')
def index():
cams = [file for file in os.listdir('xml/') if file.lower().endswith('xml')]
return render_template('index.html', cam_files=cams)
@app.route('/view/<xmlfile>')
def view(xmlfile):
path = 'xml/' + secure_filename(xmlfile)
print 'opening ' + path
xmlf = open(path, 'r')
tree = etree.parse(xmlf)
root = tree.getroot()
p = re.compile(r'Group')
groups = []
for g in root:
if (p.search(g.tag) is not None) and (g.attrib['Comment'] …Run Code Online (Sandbox Code Playgroud) python ×3
boost ×1
boost-gil ×1
boost-python ×1
c++ ×1
css ×1
django ×1
flask ×1
html ×1
python-3.5 ×1