在我的C#代码中,我有一个类,它存储了一些我希望传递给List中的python代码的数据.但是,当我尝试在我的python代码中访问该类的属性时,我得到了MissingMemberException.这里有一些示例代码来说明我的意思:
C#:
class Event
{
public int EventId { get; set; }
public string EventName { get; set; }
}
//other processing here...
//this just fills the list with event objects
List<Event> eventList = GetEvents();
//this sets a variable in the ScriptScope
PythonEngine.SetVariable( "events", eventList);
PythonEngine.Execute("eventParser.py");
Run Code Online (Sandbox Code Playgroud)
eventParser.py:
for e in events:
print e.EventId, " / ", e.EventName
Run Code Online (Sandbox Code Playgroud)
该MissingMemberException说"事件中没有名为EVENTID成员"
我已经测试通过其他类型的蟒蛇,包括原始类型,如列表List< int >和List< string >他们很好地工作.
那么我如何访问这些类属性,EventId并EventName在我的python脚本中?
在<p>标签内部输入大量文本时,文本溢出模态的边界并离开屏幕,需要水平滚动条才能读取.
我已经从Bootstrap文档中复制了示例代码,只是在该modal-body部分中添加了一个长文本字符串.Bootstrap文档网站上的示例似乎正确地将文本换行,但我的代码没有.
这是我的标记:
<div class="modal fade in" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 id="myModalLabel" class="modal-title">Modal Test</h4>
</div>
<div class="modal-body">
<p>Details below:</p>
<p>TEST: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Done</button>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
你还可以看到我在这里创建的jsFiddle上的水平溢出的确切含义:http://jsfiddle.net/pX39W/11/
我确定这很简单,我只是盯着它看的时间太长了!任何帮助将非常感激.
我正在使用knockout js和所选的插件(https://github.com/harvesthq/chosen)来尝试做一个好看的多选.
我已尝试过各种方法,但无法使用多选项来处理我正在使用的数据.当我单击多选时,即使选项绑定包含正确的数据,也不会显示任何值.
HTML:
<select multiple="multiple" data-bind="options: allCustomers,
selectedOptions: event().customers, optionsText: 'name',
optionsValue: 'id', chosen: true " ></select>?
Run Code Online (Sandbox Code Playgroud)
视图模型的简化版本:
function Event()
{
this.customers = ko.observableArray();
};
//for chosen plugin
ko.bindingHandlers.chosen = {
update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
$(element).chosen();
}
}
function ViewModel()
{
this.event = ko.observable(new Event());
this.allCustomers = ko.observableArray();
};
var viewModel = new ViewModel();
$.getJSON("/get_json", function(data)
{
for (var c = 0; c < data.customers.length; c++)
{
viewModel.allCustomers.push(data.customers[c]);
}
});
ko.applyBindings(viewModel);
Run Code Online (Sandbox Code Playgroud)
PHP:
function get_json()
{
$eventData = …Run Code Online (Sandbox Code Playgroud) 试图在屏幕上显示两个图像,每个图像占据屏幕的一半.这是我正在使用的代码:
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface* pScreen = SDL_SetVideoMode(1280,720,16, SDL_FULLSCREEN );
SDL_ShowCursor(SDL_DISABLE);
//load two images
SDL_Surface* pImage1 = IMG_Load("/media/x01.JPG");
SDL_Surface* pImage2 = IMG_Load("/media/x02.JPG");
//create two rectangles for left and right of screen
SDL_Rect leftR;
SDL_Rect rightR;
leftR.x = 600;
leftR.y = 0;
leftR.w = 640;
leftR.h = 720;
rightR.x = 640;
rightR.y = 0;
rightR.w = 640;
rightR.h = 720;
//display
SDL_BlitSurface(pImage1,&leftR,pScreen,&leftR);
SDL_BlitSurface(pImage2,&rightR,pScreen,&rightR);
SDL_Flip(pScreen);
//free image surfaces
SDL_FreeSurface(pImage1);
SDL_FreeSurface(pImage2);
//wait to see what's on screen...
sleep(5);
//close SDL
SDL_Quit();
Run Code Online (Sandbox Code Playgroud)
我希望用两个静态图像实现分屏效果.然而,所有这一切都是第一张图像显示在屏幕的一半,另一张是空白.
我试过搞乱矩形x和y,看起来图像的位置没有改变,而是观察矩形的大小.有任何想法吗?
我正在尝试获取我的htaccess重写规则以index.php从网址中删除并将www.请求重定向到非www版本.
这是我的htaccess,可以正常删除index.php:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
我遇到了另一个关于如何删除该www部分的问题:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
但我似乎无法让他们一起玩得很好!任何建议/建议最感谢!
我正在尝试让LookUpEdit在显示表单时显示初始值。我将国家列表绑定为数据源,然后在加载表单时设置EditValue,该表单应将国家显示为LookUpEdit中的选定项。不幸的是,它只是显示一个空值。LookUpEdit似乎可以正常工作,它使我可以滚动浏览国家列表并选择一个项目,然后在提交表单时将值传回。
国家类别:
public class Country
{
public Country();
public int CountryId {get; set;}
public string CountryName {get; set;}
public string IsoCode {get; set; }
}
Run Code Online (Sandbox Code Playgroud)
包含LookUpEdit的表单后面的代码:
this.country.Properties.DataSource = this.Countries;
this.country.Properties.DisplayMember = "CountryName";
this.country.Properties.ValueMember = "CountryId";
this.country.EditValue = initialCountry;
this.country.DataBindings.Add("EditValue", viewModel.Address, "AddressCountry", false, DataSourceUpdateMode.OnPropertyChanged);
Run Code Online (Sandbox Code Playgroud)
在此示例中,this.Countries已填充List<Country>并initialCountry设置为的实例Country并viewModel.Address包含属性Country AddressCountry。
我已经尝试过EditValue直接设置直接和设置数据绑定到EditValue本身。无论我尝试什么,在加载表单时LookUpEdit始终为空白,我需要将其设置为initialCountry。我敢肯定这确实很简单,但是我没有看到它,因此我们非常感谢您的帮助。
c# ×2
php ×2
.htaccess ×1
apache ×1
c++ ×1
codeigniter ×1
css ×1
devexpress ×1
html ×1
ironpython ×1
jquery ×1
knockout.js ×1
mod-rewrite ×1
sdl ×1