示例#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
示例#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
示例#3
0
    def test_title_strip(self):
        title = '    Проверка тест    '
        siblings = []

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

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

        newtitle = getAlternativeTitle(title, siblings)
        self.assertEqual(newtitle, title)
示例#6
0
    def test_empty_03(self):
        title = ''
        siblings = ['(1)']

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

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

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

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