gu.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Solfege 作者: RannyeriDev 项目源码 文件源码
def on_open(self, widget):
        """
        Open a FileChooserDialog and select a file.
        Load into this editor window if it is empty and unused,
        if not load into a new one.

        This method will catch exceptions raised while loading the file
        and display a dialog. Then it will destroy any newly created
        dialog.
        """
        dialog = Gtk.FileChooserDialog(None, self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.OK))
        dialog.set_current_folder(self.savedir)
        ret = dialog.run()
        if ret == Gtk.ResponseType.OK:
            try:
                new_file = decode_filename(dialog.get_filename())
                assert new_file not in self.instance_dict
                win = self.__class__(new_file)
                win.show_all()
                win.set_title(new_file)

                if (not self.m_filename) and (not self.m_changed):
                    del self.instance_dict[self.get_idict_key()]
                    self.destroy()
            except Exception, e:
                # Since we catch all sorts of exceptions here, we don't have
                # to do handle string to int conversion in
                # PractiseSheet.parse_file. Just let int() raise ValueException
                # if the string in not an integer.

                if 'msg1' in dir(e):
                    solfege.win.display_error_message2(getattr(e, 'msg1', ''),
                        getattr(e, 'msg2', ''))

                else:
                    display_exception_message(e)
        dialog.destroy()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号