MyTetra Share
Делитесь знаниями!
FileDialog
Время создания: 31.08.2017 21:00
Текстовые метки: test_code
Раздел: Python - Modules - wxPython
Запись: xintrea/mytetra_db_mcold/master/base/15011636029p1hkb7g85/text.html на raw.githubusercontent.com
      SAVE_FILE_ID = wx.NewId()
      self.Bind(wx.EVT_MENU, self.saveFile, id=SAVE_FILE_ID)

      LOAD_FILE_ID = wx.NewId()
      self.Bind(wx.EVT_MENU, self.loadFile, id=LOAD_FILE_ID)

      accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL,  ord('O'), LOAD_FILE_ID ),
                                       (wx.ACCEL_CTRL,  ord('S'), SAVE_FILE_ID )])

      self.SetAcceleratorTable(accel_tbl)

      def saveFile(self, event):
        saveFileDialog = wx.FileDialog(self, "Save As", "", "", 
                                      "Python files (*.py)|*.py", 
                                      wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)

        self.text.SaveFile(saveFileDialog.GetPath())
        event.Skip()

      def loadFile(self, event):
        openFileDialog = wx.FileDialog(self, "Open", "", "", 
                                      "Python files (*.py)|*.py", 
                                      wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

        self.text.LoadFile(openFileDialog.GetPath())
        event.Skip()
 
MyTetra Share v.0.58
Яндекс индекс цитирования