Example #1
0
def create_db_ask():
    return wx.FileDialog(wx.GetApp().root, message="Create database",
                        wildcard="|".join(("Outspline database (*.{})|*.{}"
                                "".format(coreaux_api.get_standard_extension(),
                                coreaux_api.get_standard_extension()),
                                "All files (*)|*")),
                        style=wx.SAVE | wx.FD_OVERWRITE_PROMPT)
Example #2
0
def open_db_ask(defdir):
    return wx.FileDialog(wx.GetApp().root, message="Open database",
                        defaultDir=defdir,
                        wildcard="|".join(("Outspline database (*.{})|*.{}"
                                "".format(coreaux_api.get_standard_extension(),
                                coreaux_api.get_standard_extension()),
                                "All files (*)|*")),
                        style=wx.OPEN | wx.FD_FILE_MUST_EXIST)
Example #3
0
def create_db_ask():
    return wx.FileDialog(wx.GetApp().root,
                         message="Create database",
                         wildcard="|".join(
                             ("Outspline database (*.{})|*.{}"
                              "".format(coreaux_api.get_standard_extension(),
                                        coreaux_api.get_standard_extension()),
                              "All files (*)|*")),
                         style=wx.SAVE | wx.FD_OVERWRITE_PROMPT)
Example #4
0
def open_db_ask(defdir):
    return wx.FileDialog(wx.GetApp().root,
                         message="Open database",
                         defaultDir=defdir,
                         wildcard="|".join(
                             ("Outspline database (*.{})|*.{}"
                              "".format(coreaux_api.get_standard_extension(),
                                        coreaux_api.get_standard_extension()),
                              "All files (*)|*")),
                         style=wx.OPEN | wx.FD_FILE_MUST_EXIST)
Example #5
0
def create_database(defpath=None, filename=None):
    if not filename:
        if not defpath:
            defpath = os.path.join(os.path.expanduser('~'),
                                    '.'.join(('new_database',
                                    coreaux_api.get_standard_extension())))

        dlg = msgboxes.create_db_ask()
        dlg.SetPath(defpath)

        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetPath()
        else:
            return False

    if filename:
        try:
            core_api.create_database(filename)
        except core_api.DatabaseAlreadyOpenError:
            msgboxes.create_db_open(filename).ShowModal()
            return False
        except core_api.AccessDeniedError:
            msgboxes.create_db_access(filename).ShowModal()
            return False
        else:
            return filename
    else:
        return False
Example #6
0
def create_database(defpath=None, filename=None):
    if not filename:
        if not defpath:
            defpath = os.path.join(
                os.path.expanduser('~'), '.'.join(
                    ('new_database', coreaux_api.get_standard_extension())))

        dlg = msgboxes.create_db_ask()
        dlg.SetPath(defpath)

        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetPath()
        else:
            return False

    if filename:
        try:
            core_api.create_database(filename)
        except core_api.DatabaseAlreadyOpenError:
            msgboxes.create_db_open(filename).ShowModal()
            return False
        except core_api.AccessDeniedError:
            msgboxes.create_db_access(filename).ShowModal()
            return False
        else:
            return filename
    else:
        return False
Example #7
0
    def __init__(self, filename, ext, value, propmanager):
        self.filename = filename
        self.ext = ext
        self.value = value
        self.propmanager = propmanager

        self.dialog = wx.Dialog(parent=wx.GetApp().root, title=self.title)

        outsizer = wx.BoxSizer(wx.VERTICAL)
        self.dialog.SetSizer(outsizer)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        # Add vsizer right here because then I use Fit in order to make
        # vsizer.GetSize().GetWidth() work
        outsizer.Add(vsizer, flag=wx.EXPAND | wx.ALL, border=12)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        icon = wx.StaticBitmap(
            self.dialog,
            bitmap=wx.GetApp().artprovider.get_dialog_icon("@warning"))
        hsizer.Add(icon, flag=wx.ALIGN_TOP | wx.RIGHT, border=12)

        label = wx.StaticText(self.dialog, label=self.warning)
        label.Wrap(320)
        hsizer.Add(label, flag=wx.ALIGN_TOP)

        vsizer.Add(hsizer, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=12)

        label = wx.StaticText(
            self.dialog,
            label="The database needs to be "
            "closed and re-opened in order to apply the changes.")
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.BOTTOM, border=12)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self.dialog, label="A backup will be saved in:")
        hsizer2.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        defpath = time_.strftime(
            '{}_%Y%m%d%H%M%S{}'.format(*os.path.splitext(self.filename)))
        self.backup = wx.FilePickerCtrl(
            self.dialog,
            message="Save backup",
            wildcard="|".join(('Outspline database (*.{})|*.{}'.format(
                coreaux_api.get_standard_extension(),
                coreaux_api.get_standard_extension()), "All files (*)|*")),
            style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL)
        # Instantiating FilePickerCtrl with 'path' doesn't seem to work well
        self.backup.SetPath(defpath)
        hsizer2.Add(self.backup, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        vsizer.Add(hsizer2, flag=wx.EXPAND | wx.BOTTOM, border=12)

        hsizer3 = wx.BoxSizer(wx.HORIZONTAL)

        ok = wx.Button(self.dialog, label="&OK")
        hsizer3.Add(ok, flag=wx.RIGHT, border=8)

        cancel = wx.Button(self.dialog, label="&Cancel")
        hsizer3.Add(cancel)

        vsizer.Add(hsizer3, flag=wx.ALIGN_RIGHT)

        self.dialog.Bind(wx.EVT_BUTTON, self._proceed, ok)
        self.dialog.Bind(wx.EVT_BUTTON, self._abort, cancel)
        self.dialog.Bind(wx.EVT_CLOSE, self._handle_close)

        self.dialog.Fit()
        self.dialog.ShowModal()
Example #8
0
    def __init__(self, updater, open_properties):
        self.updater = updater
        self.open_properties = open_properties

        self.dialog = wx.Dialog(parent=wx.GetApp().root, title="Open database")

        outsizer = wx.BoxSizer(wx.VERTICAL)
        self.dialog.SetSizer(outsizer)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        # Add vsizer right here because then I use Fit in order to make
        # vsizer.GetSize().GetWidth() work
        outsizer.Add(vsizer, flag=wx.EXPAND | wx.ALL, border=12)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        icon = wx.StaticBitmap(self.dialog, bitmap=wx.GetApp().artprovider.get_dialog_icon("@question"))
        hsizer.Add(icon, flag=wx.ALIGN_TOP | wx.RIGHT, border=12)

        hvsizer = wx.BoxSizer(wx.VERTICAL)

        # Core will never be in the dependencies here
        label = wx.StaticText(
            self.dialog,
            label="{} is missing support for "
            "the following installed extensions:".format(self.updater.get_filename()),
        )
        label.Wrap(320)
        hvsizer.Add(label, flag=wx.BOTTOM, border=4)

        self.deplist = []
        deptext = []

        for addon in self.updater.get_addible_dependencies():
            self.deplist.append(addon)
            deptext.append(u"\u2022 {}".format(addon))

        label = wx.StaticText(self.dialog, label="\n".join(deptext))
        label.Wrap(320)
        hvsizer.Add(label)

        hsizer.Add(hvsizer, flag=wx.ALIGN_TOP)

        vsizer.Add(hsizer, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=12)

        add = wx.Button(self.dialog, label="Add &support and open database")
        vsizer.Add(add, flag=wx.EXPAND | wx.BOTTOM, border=4)

        label = wx.StaticText(
            self.dialog, label="Warning: enabling " "dependencies will clear all the history of the database."
        )
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.BOTTOM, border=4)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self.dialog, label="A backup will be saved in:")
        hsizer2.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        defpath = time_.strftime("{}_%Y%m%d%H%M%S{}".format(*os.path.splitext(self.updater.get_filename())))
        self.backup = wx.FilePickerCtrl(
            self.dialog,
            message="Save backup",
            wildcard="|".join(
                (
                    "Outspline database (*.{})|*.{}".format(
                        coreaux_api.get_standard_extension(), coreaux_api.get_standard_extension()
                    ),
                    "All files (*)|*",
                )
            ),
            style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL,
        )
        # Instantiating FilePickerCtrl with 'path' doesn't seem to work well
        self.backup.SetPath(defpath)
        hsizer2.Add(self.backup, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        vsizer.Add(hsizer2, flag=wx.EXPAND | wx.BOTTOM, border=12)

        vsizer.Add(wx.StaticLine(self.dialog), flag=wx.EXPAND | wx.BOTTOM, border=12)

        skip = wx.Button(self.dialog, label="&Open database as it is")
        vsizer.Add(skip, flag=wx.EXPAND | wx.BOTTOM, border=4)

        label = wx.StaticText(
            self.dialog,
            label="This dialog will appear "
            "every time the database is opened, unless "
            "disabled in the database properties.",
        )
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.EXPAND | wx.BOTTOM, border=12)

        vsizer.Add(wx.StaticLine(self.dialog), flag=wx.EXPAND | wx.BOTTOM, border=12)

        abort = wx.Button(self.dialog, label="&Abort opening database")
        vsizer.Add(abort, flag=wx.EXPAND)

        self.dialog.Bind(wx.EVT_BUTTON, self._add, add)
        self.dialog.Bind(wx.EVT_BUTTON, self._skip, skip)
        self.dialog.Bind(wx.EVT_BUTTON, self._abort, abort)
        self.dialog.Bind(wx.EVT_CLOSE, self._handle_close)

        self.dialog.Fit()
        self.dialog.ShowModal()
Example #9
0
    def __init__(self, updater, open_properties):
        self.updater = updater
        self.open_properties = open_properties

        self.dialog = wx.Dialog(parent=wx.GetApp().root, title="Open database")

        outsizer = wx.BoxSizer(wx.VERTICAL)
        self.dialog.SetSizer(outsizer)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        # Add vsizer right here because then I use Fit in order to make
        # vsizer.GetSize().GetWidth() work
        outsizer.Add(vsizer, flag=wx.EXPAND | wx.ALL, border=12)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        icon = wx.StaticBitmap(self.dialog,
                bitmap=wx.GetApp().artprovider.get_dialog_icon('@question'))
        hsizer.Add(icon, flag=wx.ALIGN_TOP | wx.RIGHT, border=12)

        hvsizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self.dialog, label="{} is based on an old "
                    "version of the core or the following extensions:".format(
                                                self.updater.get_filename()))
        label.Wrap(320)
        hvsizer.Add(label, flag=wx.BOTTOM, border=4)

        dependencies = self.updater.get_updatable_dependencies()
        self.deplist = []
        deptext = []

        for addon in dependencies:
            dep = dependencies[addon]

            self.deplist.append(addon)

            if addon is None:
                deptext.append(u"\u2022 core (version {}.x supported, {}.x "
                                    "installed)".format(dep[1], dep[0]))
            else:
                deptext.append(u"\u2022 {} (version {}.x supported, {}.x "
                                    "installed)".format(addon, dep[1], dep[0]))

        label = wx.StaticText(self.dialog, label="\n".join(deptext))
        label.Wrap(320)
        hvsizer.Add(label)

        hsizer.Add(hvsizer, flag=wx.ALIGN_TOP)

        vsizer.Add(hsizer, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=12)

        update = wx.Button(self.dialog, label="&Update and open database")
        vsizer.Add(update, flag=wx.EXPAND | wx.BOTTOM, border=4)

        label = wx.StaticText(self.dialog, label="Warning: updating "
                    "dependencies will clear all the history of the database.")
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.BOTTOM, border=4)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self.dialog, label="A backup will be saved in:")
        hsizer2.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        defpath = time_.strftime('{}_%Y%m%d%H%M%S{}'.format(
                            *os.path.splitext(self.updater.get_filename())))
        self.backup = wx. FilePickerCtrl(self.dialog, message="Save backup",
            wildcard="|".join(('Outspline database (*.{})|*.{}'.format(
                                coreaux_api.get_standard_extension(),
                                coreaux_api.get_standard_extension()),
                    "All files (*)|*")),
            style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL)
        # Instantiating FilePickerCtrl with 'path' doesn't seem to work well
        self.backup.SetPath(defpath)
        hsizer2.Add(self.backup, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        vsizer.Add(hsizer2, flag=wx.EXPAND | wx.BOTTOM, border=12)

        vsizer.Add(wx.StaticLine(self.dialog), flag=wx.EXPAND | wx.BOTTOM,
                                                                    border=12)

        abort = wx.Button(self.dialog, label="&Abort opening database")
        vsizer.Add(abort, flag=wx.EXPAND)

        self.dialog.Bind(wx.EVT_BUTTON, self._update, update)
        self.dialog.Bind(wx.EVT_BUTTON, self._abort, abort)
        self.dialog.Bind(wx.EVT_CLOSE, self._handle_close)

        self.dialog.Fit()
        self.dialog.ShowModal()
Example #10
0
    def __init__(self, updater, open_properties):
        self.updater = updater
        self.open_properties = open_properties

        self.dialog = wx.Dialog(parent=wx.GetApp().root, title="Open database")

        outsizer = wx.BoxSizer(wx.VERTICAL)
        self.dialog.SetSizer(outsizer)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        # Add vsizer right here because then I use Fit in order to make
        # vsizer.GetSize().GetWidth() work
        outsizer.Add(vsizer, flag=wx.EXPAND | wx.ALL, border=12)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        icon = wx.StaticBitmap(
            self.dialog,
            bitmap=wx.GetApp().artprovider.get_dialog_icon('@question'))
        hsizer.Add(icon, flag=wx.ALIGN_TOP | wx.RIGHT, border=12)

        hvsizer = wx.BoxSizer(wx.VERTICAL)

        # Core will never be in the dependencies here
        label = wx.StaticText(self.dialog,
                              label="{} is missing support for "
                              "the following installed extensions:".format(
                                  self.updater.get_filename()))
        label.Wrap(320)
        hvsizer.Add(label, flag=wx.BOTTOM, border=4)

        self.deplist = []
        deptext = []

        for addon in self.updater.get_addible_dependencies():
            self.deplist.append(addon)
            deptext.append(u"\u2022 {}".format(addon))

        label = wx.StaticText(self.dialog, label="\n".join(deptext))
        label.Wrap(320)
        hvsizer.Add(label)

        hsizer.Add(hvsizer, flag=wx.ALIGN_TOP)

        vsizer.Add(hsizer, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=12)

        add = wx.Button(self.dialog, label="Add &support and open database")
        vsizer.Add(add, flag=wx.EXPAND | wx.BOTTOM, border=4)

        label = wx.StaticText(
            self.dialog,
            label="Warning: enabling "
            "dependencies will clear all the history of the database.")
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.BOTTOM, border=4)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self.dialog, label="A backup will be saved in:")
        hsizer2.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        defpath = time_.strftime('{}_%Y%m%d%H%M%S{}'.format(
            *os.path.splitext(self.updater.get_filename())))
        self.backup = wx.FilePickerCtrl(
            self.dialog,
            message="Save backup",
            wildcard="|".join(('Outspline database (*.{})|*.{}'.format(
                coreaux_api.get_standard_extension(),
                coreaux_api.get_standard_extension()), "All files (*)|*")),
            style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL)
        # Instantiating FilePickerCtrl with 'path' doesn't seem to work well
        self.backup.SetPath(defpath)
        hsizer2.Add(self.backup, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        vsizer.Add(hsizer2, flag=wx.EXPAND | wx.BOTTOM, border=12)

        vsizer.Add(wx.StaticLine(self.dialog),
                   flag=wx.EXPAND | wx.BOTTOM,
                   border=12)

        skip = wx.Button(self.dialog, label="&Open database as it is")
        vsizer.Add(skip, flag=wx.EXPAND | wx.BOTTOM, border=4)

        label = wx.StaticText(self.dialog,
                              label="This dialog will appear "
                              "every time the database is opened, unless "
                              "disabled in the database properties.")
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.EXPAND | wx.BOTTOM, border=12)

        vsizer.Add(wx.StaticLine(self.dialog),
                   flag=wx.EXPAND | wx.BOTTOM,
                   border=12)

        abort = wx.Button(self.dialog, label="&Abort opening database")
        vsizer.Add(abort, flag=wx.EXPAND)

        self.dialog.Bind(wx.EVT_BUTTON, self._add, add)
        self.dialog.Bind(wx.EVT_BUTTON, self._skip, skip)
        self.dialog.Bind(wx.EVT_BUTTON, self._abort, abort)
        self.dialog.Bind(wx.EVT_CLOSE, self._handle_close)

        self.dialog.Fit()
        self.dialog.ShowModal()
Example #11
0
    def __init__(self, filename, ext, value, propmanager):
        self.filename = filename
        self.ext = ext
        self.value = value
        self.propmanager = propmanager

        self.dialog = wx.Dialog(parent=wx.GetApp().root, title=self.title)

        outsizer = wx.BoxSizer(wx.VERTICAL)
        self.dialog.SetSizer(outsizer)

        vsizer = wx.BoxSizer(wx.VERTICAL)

        # Add vsizer right here because then I use Fit in order to make
        # vsizer.GetSize().GetWidth() work
        outsizer.Add(vsizer, flag=wx.EXPAND | wx.ALL, border=12)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        icon = wx.StaticBitmap(self.dialog,
                    bitmap=wx.GetApp().artprovider.get_dialog_icon("@warning"))
        hsizer.Add(icon, flag=wx.ALIGN_TOP | wx.RIGHT, border=12)

        label = wx.StaticText(self.dialog, label=self.warning)
        label.Wrap(320)
        hsizer.Add(label, flag=wx.ALIGN_TOP)

        vsizer.Add(hsizer, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=12)

        label = wx.StaticText(self.dialog, label="The database needs to be "
                        "closed and re-opened in order to apply the changes.")
        # Fit in order to make vsizer.GetSize().GetWidth() work
        self.dialog.Fit()
        label.Wrap(vsizer.GetSize().GetWidth())
        vsizer.Add(label, flag=wx.BOTTOM, border=12)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)

        label = wx.StaticText(self.dialog, label="A backup will be saved in:")
        hsizer2.Add(label, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=4)

        defpath = time_.strftime('{}_%Y%m%d%H%M%S{}'.format(
                                            *os.path.splitext(self.filename)))
        self.backup = wx. FilePickerCtrl(self.dialog, message="Save backup",
            wildcard="|".join(('Outspline database (*.{})|*.{}'.format(
                                coreaux_api.get_standard_extension(),
                                coreaux_api.get_standard_extension()),
                    "All files (*)|*")),
            style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL)
        # Instantiating FilePickerCtrl with 'path' doesn't seem to work well
        self.backup.SetPath(defpath)
        hsizer2.Add(self.backup, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        vsizer.Add(hsizer2, flag=wx.EXPAND | wx.BOTTOM, border=12)

        hsizer3 = wx.BoxSizer(wx.HORIZONTAL)

        ok = wx.Button(self.dialog, label="&OK")
        hsizer3.Add(ok, flag=wx.RIGHT, border=8)

        cancel = wx.Button(self.dialog, label="&Cancel")
        hsizer3.Add(cancel)

        vsizer.Add(hsizer3, flag=wx.ALIGN_RIGHT)

        self.dialog.Bind(wx.EVT_BUTTON, self._proceed, ok)
        self.dialog.Bind(wx.EVT_BUTTON, self._abort, cancel)
        self.dialog.Bind(wx.EVT_CLOSE, self._handle_close)

        self.dialog.Fit()
        self.dialog.ShowModal()