当前位置: 首页>>代码示例>>Python>>正文


Python ServiceItem.render方法代码示例

本文整理汇总了Python中openlp.core.lib.ServiceItem.render方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceItem.render方法的具体用法?Python ServiceItem.render怎么用?Python ServiceItem.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlp.core.lib.ServiceItem的用法示例。


在下文中一共展示了ServiceItem.render方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_preview

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def generate_preview(self, theme_data, force_page=False):
        """
        Generate a preview of a theme.

        :param theme_data:  The theme to generated a preview for.
        :param force_page: Flag to tell message lines per page need to be generated.
        """
        # save value for use in format_slide
        self.force_page = force_page
        # build a service item to generate preview
        service_item = ServiceItem()
        if self.force_page:
            # make big page for theme edit dialog to get line count
            service_item.add_from_text(VERSE_FOR_LINE_COUNT)
        else:
            service_item.add_from_text(VERSE)
        service_item.raw_footer = FOOTER
        # if No file do not update cache
        if theme_data.background_filename:
            self.image_manager.add_image(
                theme_data.background_filename, ImageSource.Theme, QtGui.QColor(theme_data.background_border_color))
        theme_data, main, footer = self.pre_render(theme_data)
        service_item.theme_data = theme_data
        service_item.main = main
        service_item.footer = footer
        service_item.render(True)
        if not self.force_page:
            self.display.build_html(service_item)
            raw_html = service_item.get_rendered_frame(0)
            self.display.text(raw_html, False)
            preview = self.display.preview()
            return preview
        self.force_page = False
开发者ID:imkernel,项目名称:openlp,代码行数:35,代码来源:renderer.py

示例2: service_item_load_custom_from_service_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def service_item_load_custom_from_service_test(self):
        """
        Test the Service Item - adding a custom slide from a saved service
        """
        # GIVEN: A new service item and a mocked add icon function
        service_item = ServiceItem(None)
        service_item.add_icon = MagicMock()

        # WHEN: We add a custom from a saved service
        line = convert_file_service_item(TEST_PATH, 'serviceitem_custom_1.osj')
        service_item.set_from_service(line)

        # THEN: We should get back a valid service item
        self.assertTrue(service_item.is_valid, 'The new service item should be valid')
        assert_length(0, service_item._display_frames, 'The service item should have no display frames')
        assert_length(5, service_item.capabilities, 'There should be 5 default custom item capabilities')

        # WHEN: We render the frames of the service item
        service_item.render(True)

        # THEN: The frames should also be valid
        self.assertEqual('Test Custom', service_item.get_display_title(), 'The title should be "Test Custom"')
        self.assertEqual(VERSE[:-1], service_item.get_frames()[0]['text'],
                         'The returned text matches the input, except the last line feed')
        self.assertEqual(VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1),
                         'The first line has been returned')
        self.assertEqual('Slide 1', service_item.get_frame_title(0), '"Slide 1" has been returned as the title')
        self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title')
        self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3')
开发者ID:crossroadchurch,项目名称:paul,代码行数:31,代码来源:test_serviceitem.py

示例3: service_item_load_song_and_audio_from_service_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def service_item_load_song_and_audio_from_service_test(self):
        """
        Test the Service Item - adding a song slide from a saved service
        """
        # GIVEN: A new service item and a mocked add icon function
        service_item = ServiceItem(None)
        service_item.add_icon = MagicMock()

        # WHEN: We add a custom from a saved service
        line = convert_file_service_item(TEST_PATH, 'serviceitem-song-linked-audio.osj')
        service_item.set_from_service(line, '/test/')

        # THEN: We should get back a valid service item
        self.assertTrue(service_item.is_valid, 'The new service item should be valid')
        assert_length(0, service_item._display_frames, 'The service item should have no display frames')
        assert_length(7, service_item.capabilities, 'There should be 7 default custom item capabilities')

        # WHEN: We render the frames of the service item
        service_item.render(True)

        # THEN: The frames should also be valid
        self.assertEqual('Amazing Grace', service_item.get_display_title(), 'The title should be "Amazing Grace"')
        self.assertEqual(VERSE[:-1], service_item.get_frames()[0]['text'],
                         'The returned text matches the input, except the last line feed')
        self.assertEqual(VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1),
                         'The first line has been returned')
        self.assertEqual('Amazing Grace! how sweet the s', service_item.get_frame_title(0),
                         '"Amazing Grace! how sweet the s" has been returned as the title')
        self.assertEqual('’Twas grace that taught my hea', service_item.get_frame_title(1),
                         '"’Twas grace that taught my hea" has been returned as the title')
        self.assertEqual('/test/amazing_grace.mp3', service_item.background_audio[0],
                         '"/test/amazing_grace.mp3" should be in the background_audio list')
开发者ID:crossroadchurch,项目名称:paul,代码行数:34,代码来源:test_serviceitem.py

示例4: serviceitem_load_custom_from_service_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def serviceitem_load_custom_from_service_test(self):
        """
        Test the Service Item - adding a custom slide from a saved service
        """
        # GIVEN: A new service item and a mocked add icon function
        service_item = ServiceItem(None)
        mocked_add_icon =  MagicMock()
        service_item.add_icon = mocked_add_icon

        # WHEN: adding a custom from a saved Service
        line = self.convert_file_service_item(u'serviceitem_custom1.osd')
        service_item.set_from_service(line)

        # THEN: We should get back a valid service item
        assert service_item.is_valid is True, u'The new service item should be valid'
        assert len(service_item._display_frames) == 0, u'The service item has no display frames'
        assert len(service_item.capabilities) == 5, u'There are 5 default custom item capabilities'
        service_item.render(True)
        assert (service_item.get_display_title()) == u'Test Custom', u'The custom title should be correct'
开发者ID:marmyshev,项目名称:transitions,代码行数:21,代码来源:test_serviceitem.py

示例5: serviceitem_add_text_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def serviceitem_add_text_test(self):
        """
        Test the Service Item - add text test
        """
        # GIVEN: A new service item
        service_item = ServiceItem(None)

        # WHEN: adding text to a service item
        service_item.add_from_text(VERSE)
        service_item.raw_footer = FOOTER

        # THEN: We should get back a valid service item
        assert service_item.is_valid is True, u'The new service item should be valid'
        assert service_item.missing_frames() is False, u'check frames loaded '

        # WHEN: Render called
        assert len(service_item._display_frames) == 0, u'A blank Service Item with no display frames'
        service_item.render(True)

        # THEN: We should have a page of output.
        assert len(service_item._display_frames) == 1, u'A valid rendered Service Item has 1 display frame'
        assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A output has rendered correctly.'
开发者ID:marmyshev,项目名称:transitions,代码行数:24,代码来源:test_serviceitem.py

示例6: serviceitem_load_custom_from_service_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import render [as 别名]
    def serviceitem_load_custom_from_service_test(self):
        """
        Test the Service Item - adding a custom slide from a saved service
        """
        # GIVEN: A new service item and a mocked add icon function
        service_item = ServiceItem(None)
        service_item.add_icon = MagicMock()

        # WHEN: adding a custom from a saved Service
        line = self.convert_file_service_item('serviceitem_custom_1.osj')
        service_item.set_from_service(line)

        # THEN: We should get back a valid service item
        assert service_item.is_valid is True, 'The new service item should be valid'
        assert len(service_item._display_frames) == 0, 'The service item should have no display frames'
        assert len(service_item.capabilities) == 5, 'There should be 5 default custom item capabilities'
        service_item.render(True)
        assert service_item.get_display_title() == 'Test Custom', 'The title should be "Test Custom"'
        assert service_item.get_frames()[0]['text'] == VERSE[:-1], \
            'The returned text matches the input, except the last line feed'
        assert service_item.get_rendered_frame(1) == VERSE.split('\n', 1)[0], 'The first line has been returned'
        assert service_item.get_frame_title(0) == 'Slide 1', '"Slide 1" has been returned as the title'
        assert service_item.get_frame_title(1) == 'Slide 2', '"Slide 2" has been returned as the title'
        assert service_item.get_frame_title(2) == '', 'Blank has been returned as the title of slide 3'
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:26,代码来源:test_serviceitem.py


注:本文中的openlp.core.lib.ServiceItem.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。