Exemple #1
0
    def OnViewSave(self):
        config = wx.Config.Get()
        changer = wx.ConfigPathChanger(config, "/Views/MainWindow/")

        pos = self.GetPosition()
        size = self.GetSize()

        config.WriteInt("Left", pos.x)
        config.WriteInt("Top", pos.y)
        config.WriteInt("Width", size.width)
        config.WriteInt("Height", size.height)
Exemple #2
0
    def test_Config3(self):
        null = wx.LogNull()
        name = cfgFilename + '_3'

        cfg = wx.Config('unittest_ConfigTests', localFilename=name)
        self.writeStuff(cfg)

        cfg.SetPath('/before')
        self.assertTrue(cfg.GetPath() == '/before')
        with wx.ConfigPathChanger(cfg, '/one/two/three/'):
            self.assertTrue(cfg.GetPath() == '/one/two/three')
        self.assertTrue(cfg.GetPath() == '/before')

        del cfg
        if os.path.exists(name):
            os.remove(name)
Exemple #3
0
    def OnViewRestore(self):
        config = wx.Config.Get()
        changer = wx.ConfigPathChanger(config, "/Views/MainWindow/")

        left = config.ReadInt("Left", -1)
        top = config.ReadInt("Top", -1)
        width = config.ReadInt("Width", -1)
        height = config.ReadInt("Height", -1)

        if left >= 0 and top >= 0:
            self.SetPosition((left, top))

        if width >= 0 and height >= 0:
            size = wx.Size(width, height)
            size.IncTo(self.GetMinSize())
            self.SetSize(size)
Exemple #4
0
    def InitGui(self):
        """ Create the GUI. """

        # Widgets
        text = wx.StaticText(
            self, wx.ID_ANY,
            "Select a previous PIM to open from the list below, or a new PIM.")
        self.history = wx.ListBox(self, size=(300, 200))
        self.remember = wx.CheckBox(self, wx.ID_ANY,
                                    "Open the selected PIM at startup.")
        choose_button = wx.Button(self, wx.ID_ANY, "Choose")

        self.Bind(wx.EVT_BUTTON, self.OnNew, choose_button)
        self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK)

        # Positions
        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.AddF(text, wx.SizerFlags(0).Expand().Border(wx.BOTTOM))
        sizer.AddF(self.history, wx.SizerFlags(1).Expand())
        sizer.AddF(
            self.remember,
            wx.SizerFlags(0).Expand().Align(wx.ALIGN_LEFT).Border(wx.BOTTOM))
        sizer.AddF(choose_button, wx.SizerFlags(0).Align(wx.ALIGN_RIGHT))

        btns = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)

        mainSizer.AddF(sizer, wx.SizerFlags(1).Expand().Border(wx.ALL))
        mainSizer.Add(btns, 0, wx.ALL | wx.EXPAND)
        self.SetSizerAndFit(mainSizer)

        # Load the list
        config = wx.Config.Get()

        history = wx.FileHistory()
        changer = wx.ConfigPathChanger(config, "/History/")
        history.Load(config)
        changer = None

        for i in range(history.GetCount()):
            self.history.Append(history.GetHistoryFile(i))

        # Remember
        self.remember.SetValue(config.ReadBool("/OpenLast", False))
Exemple #5
0
    def OnOk(self, event):
        index = self.history.GetSelection()
        if index >= 0:
            self.result = self.history.GetString(index)

        config = wx.Config.Get()

        # Save the History list
        history = wx.FileHistory()
        for i in reversed(range(self.history.GetCount())):
            history.AddFileToHistory(self.history.GetString(i))

        if self.result:
            history.AddFileToHistory(self.result)

        changer = wx.ConfigPathChanger(config, "/History/")
        history.Save(config)
        changer = None

        # Save the Current Item
        config.WriteBool("/OpenLast", self.remember.IsChecked())
        config.Write("/LastPIM", "")  # It is set by the main window after open

        self.EndModal(wx.ID_OK)
Exemple #6
0
    def OnViewSave(self):
        config = wx.Config.Get()
        changer = wx.ConfigPathChanger(config,
                                       "/Views/" + self.VIEW_NAME + "/")

        self.DoViewSave(config)