dialog.py 文件源码

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

项目:aniwall 作者: worron 项目源码 文件源码
def run(self, path_suggest=None, name_suggest=None):
        """Activate dialog"""
        dialog = Gtk.FileChooserDialog(
            self.title, self.parent, self.action,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, self.action_button, Gtk.ResponseType.OK)
        )

        # set initial location and file name
        if path_suggest is not None:
            dialog.set_current_folder(path_suggest)
        else:
            dialog.set_current_folder(self.homedir)
        if name_suggest is not None:
            dialog.set_current_name(name_suggest)

        # listen response
        is_ok, path, filename = False, None, None
        response = dialog.run()

        if response == Gtk.ResponseType.OK:
            # get data
            is_ok = True
            path = dialog.get_current_folder()
            if self.action != Gtk.FileChooserAction.SELECT_FOLDER:
                filename = dialog.get_filename()

        # clean up
        dialog.destroy()
        return is_ok, path, filename
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号