Exemplo n.º 1
0
def createPageWithDialog(parentwnd, parentpage):
    """
    Показать диалог настроек и создать страницу
    """
    assert parentpage is not None

    if parentpage.readonly:
        raise outwiker.core.exceptions.ReadonlyException

    page = None

    with CreatePageDialog(parentwnd, parentpage, Application) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            factory = dlg.selectedFactory
            alias = dlg.pageTitle
            siblings = [child_page.title for child_page in parentpage.children]
            title = getAlternativeTitle(alias, siblings)

            try:
                page = factory.create(parentpage, title, [])
                if title != alias:
                    page.alias = alias
            except EnvironmentError:
                MessageBox(_(u"Can't create page"), "Error",
                           wx.ICON_ERROR | wx.OK)
                return None

            assert page is not None
            if not dlg.setPageProperties(page):
                return None

            page.root.selectedPage = page

    return page
Exemplo n.º 2
0
def createPageWithDialog(parentwnd, parentpage):
    """
    Показать диалог настроек и создать страницу
    """
    assert parentpage is not None

    if parentpage.readonly:
        raise outwiker.core.exceptions.ReadonlyException

    page = None

    with CreatePageDialog(parentwnd, parentpage, Application) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            factory = dlg.selectedFactory
            alias = dlg.pageTitle
            siblings = [child_page.title for child_page in parentpage.children]
            title = getAlternativeTitle(alias, siblings)

            try:
                page = factory.create(parentpage, title, [])
                if title != alias:
                    page.alias = alias
            except EnvironmentError:
                showError(Application.mainWindow, _(u"Can't create page"))
                return None

            assert page is not None
            if not dlg.setPageProperties(page):
                return None

            page.root.selectedPage = page

    return page
Exemplo n.º 3
0
    def test_title_strip(self):
        title = '    Проверка тест    '
        siblings = []

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, 'Проверка тест')
Exemplo n.º 4
0
    def test_title_siblings_07(self):
        title = 'Проверка'
        siblings = ['Test', 'проверка']

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, 'Проверка (1)')
Exemplo n.º 5
0
    def test_title_ok_01(self):
        title = 'Проверка'
        siblings = []

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, title)
Exemplo n.º 6
0
    def test_empty_03(self):
        title = ''
        siblings = ['(1)']

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, '(2)')
Exemplo n.º 7
0
    def test_title_replace_03(self):
        title = 'Проверка ><|?*:"\\/#% test'
        siblings = []

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, 'Проверка ___________ test')
Exemplo n.º 8
0
    def test_title_replace_01(self):
        title = 'Проверка:'
        siblings = []

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, 'Проверка_')
Exemplo n.º 9
0
    def test_title_replace_siblings_02(self):
        title = 'Проверка:'
        siblings = ['Проверка_', 'Проверка_ (1)']

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, 'Проверка_ (2)')