reprowd.presenter package

reprowd.presenter.base module

class reprowd.presenter.base.BasePresenter[source]

BasePresenter is a base class of presenter. We derive ImageLabel, ImageCmp and TextCmp three preseter classes from this base class. Users can also use it to define own customized presenters.

>>> customized_presenter = BasePresenter
>>> customized_presenter.set_name("image Labeling")
>>> customized_presenter.set_description("Help us to label an image")
>>> customized_presenter.set_short_name("imagelabel")
>>> customized_presenter.set_question("Do you see a human face in this picture?")
>>> customized_presenter.set_template(string_of_HTML)
>>> crowddata = cc.CrowdData(object_list, table_name = "test") \  
...               .set_presenter(presenter, map_func)
set_name(name)[source]

Set the presenter a new name, which will be the name of attached project.

set_description(description)[source]

Set the presenter a new description, which will be the description of attached project.

set_template(template)[source]

Set the presenter a new HTML file.

set_short_name(short_name)[source]

Set the presenter a new short_name, which will be the short_name of attached project.

set_question(question)[source]

Set the presenter a question, which will be the question of attached task presented on the HTML file.

reprowd.presenter.image module

class reprowd.presenter.image.ImageLabel[source]

ImageLabel is a presenter class direved from base presenter class. It is attacted with project. ImageLabel basically is used for image label tasks.

In order to load the images correctly, the map function of set_presenter function should be consistent with the picture format in Javascript part of template.

For example,

>>> map_func = lambda obj: {'url_b':obj}

this means the key of your image url in task info json is ‘url_b’, which will be passed to Javascript part of template.

Thus, in pybossa.taskLoaded function of Javascript part. The key ‘url_b’ should be used to bind a src attribute to a img tag.

>>> img.attr('src', task.info.url_b).css('height', 460);
__init__()[source]

Initialize a ImageLabel presenter for a project. Defaultly, question, project name, project shor_name and project description are set as empty, “Image Labeling”, “imglabel” and “Help us to label an image” respectively. The template attribute is a string of HTML file, which is the content of presenter. For writing a new template, check http://docs.pybossa.com/en/latest/user/tutorial.html#presenting-the-tasks-to-the-user.

>>> presenter = ImageLabel();
>>> presenter.set_name("Do you see a Human face in this picture?")
>>> crowddata = cc.CrowdData(object_list, table_name = "test") \  
...               .set_presenter(presenter, map_func)
>>> crowddata.presenter
<reprowd.presenter.image.ImageLabel object at 0x...>
set_description(description)

Set the presenter a new description, which will be the description of attached project.

set_name(name)

Set the presenter a new name, which will be the name of attached project.

set_question(question)

Set the presenter a question, which will be the question of attached task presented on the HTML file.

set_short_name(short_name)

Set the presenter a new short_name, which will be the short_name of attached project.

set_template(template)

Set the presenter a new HTML file.

class reprowd.presenter.image.ImageCmp[source]

ImageCmp is a presenter class direved from base presenter class. It is attacted with project. ImageCmp basically is used for a pair of images comparing tasks.

In order to load the images correctly, the map function of set_presenter function should be consistent with the picture format in Javascript part of template.

For example,

>>> map_func = lambda obj: {'pic1': obj[0], 'pic2': obj[1]}

this means the keys of your images url in task info json are ‘pic1’ and ‘pic2’, which will be passed to Javascript part of template.

Thus, in pybossa.taskLoaded function of Javascript part. The keys ‘pic1’ and ‘pic2’ should be used to bind src attributes to two img tag2.

>>> img1.attr('src', task.info.pic1).css('height', 300);
>>> img2.attr('src', task.info.pic2).css('height', 300);
__init__()[source]

Initialize a ImageCmp presenter for a project. Defaultly, question, project name, project shor_name and project description are set as empty, “Image Comparison”, “imgcmp” and “Help us to compare images” respectively. The template attribute is a string of HTML file, which is the content of presenter. For writing a new template, check http://docs.pybossa.com/en/latest/user/tutorial.html#presenting-the-tasks-to-the-user.

>>> presenter = ImageCmp();
>>> presenter.set_name("Which picture is more beautiful?")
>>> crowddata = cc.CrowdData(object_list, table_name = "test") \  
...               .set_presenter(presenter, map_func)
>>> crowddata.presenter
<reprowd.presenter.image.ImageCmp object at 0x...>
set_description(description)

Set the presenter a new description, which will be the description of attached project.

set_name(name)

Set the presenter a new name, which will be the name of attached project.

set_question(question)

Set the presenter a question, which will be the question of attached task presented on the HTML file.

set_short_name(short_name)

Set the presenter a new short_name, which will be the short_name of attached project.

set_template(template)

Set the presenter a new HTML file.