当前位置: 首页>>代码示例>>Python>>正文


Python tkinter_messagebox.showerror函数代码示例

本文整理汇总了Python中six.moves.tkinter_messagebox.showerror函数的典型用法代码示例。如果您正苦于以下问题:Python showerror函数的具体用法?Python showerror怎么用?Python showerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了showerror函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_figure

    def save_figure(self, *args):
        from six.moves import tkinter_tkfiledialog, tkinter_messagebox
        filetypes = self.canvas.get_supported_filetypes().copy()
        default_filetype = self.canvas.get_default_filetype()

        # Tk doesn't provide a way to choose a default filetype,
        # so we just have to put it first
        default_filetype_name = filetypes[default_filetype]
        del filetypes[default_filetype]

        sorted_filetypes = list(six.iteritems(filetypes))
        sorted_filetypes.sort()
        sorted_filetypes.insert(0, (default_filetype, default_filetype_name))

        tk_filetypes = [(name, '*.%s' % ext)
                        for (ext, name) in sorted_filetypes]

        # adding a default extension seems to break the
        # asksaveasfilename dialog when you choose various save types
        # from the dropdown.  Passing in the empty string seems to
        # work - JDH!
        #defaultextension = self.canvas.get_default_filetype()
        defaultextension = ''
        initialdir = rcParams.get('savefig.directory', '')
        initialdir = os.path.expanduser(initialdir)
        initialfile = self.canvas.get_default_filename()
        fname = tkinter_tkfiledialog.asksaveasfilename(
            master=self.window,
            title='Save the figure',
            filetypes=tk_filetypes,
            defaultextension=defaultextension,
            initialdir=initialdir,
            initialfile=initialfile,
        )

        if fname == "" or fname == ():
            return
        else:
            if initialdir == '':
                # explicitly missing key or empty str signals to use cwd
                rcParams['savefig.directory'] = initialdir
            else:
                # save dir for next time
                rcParams['savefig.directory'] = os.path.dirname(
                    six.text_type(fname))
            try:
                # This method will handle the delegation to the correct type
                self.canvas.print_figure(fname)
            except Exception as e:
                tkinter_messagebox.showerror("Error saving file", str(e))
开发者ID:efiring,项目名称:matplotlib,代码行数:50,代码来源:backend_tkagg.py

示例2: save_figure

    def save_figure(self, *args):
        from six.moves import tkinter_tkfiledialog, tkinter_messagebox
        filetypes = self.canvas.get_supported_filetypes().copy()
        default_filetype = self.canvas.get_default_filetype()

        # Tk doesn't provide a way to choose a default filetype,
        # so we just have to put it first
        default_filetype_name = filetypes.pop(default_filetype)
        sorted_filetypes = ([(default_filetype, default_filetype_name)]
                            + sorted(six.iteritems(filetypes)))
        tk_filetypes = [(name, '*.%s' % ext) for ext, name in sorted_filetypes]

        # adding a default extension seems to break the
        # asksaveasfilename dialog when you choose various save types
        # from the dropdown.  Passing in the empty string seems to
        # work - JDH!
        #defaultextension = self.canvas.get_default_filetype()
        defaultextension = ''
        initialdir = os.path.expanduser(rcParams['savefig.directory'])
        initialfile = self.canvas.get_default_filename()
        fname = tkinter_tkfiledialog.asksaveasfilename(
            master=self.window,
            title='Save the figure',
            filetypes=tk_filetypes,
            defaultextension=defaultextension,
            initialdir=initialdir,
            initialfile=initialfile,
            )

        if fname in ["", ()]:
            return
        # Save dir for next time, unless empty str (i.e., use cwd).
        if initialdir != "":
            rcParams['savefig.directory'] = (
                os.path.dirname(six.text_type(fname)))
        try:
            # This method will handle the delegation to the correct type
            self.canvas.figure.savefig(fname)
        except Exception as e:
            tkinter_messagebox.showerror("Error saving file", str(e))
开发者ID:pwuertz,项目名称:matplotlib,代码行数:40,代码来源:_backend_tk.py

示例3: error_msg_tkpaint

def error_msg_tkpaint(msg, parent=None):
    from six.moves import tkinter_messagebox as tkMessageBox
    tkMessageBox.showerror("matplotlib", msg)
开发者ID:pwuertz,项目名称:matplotlib,代码行数:3,代码来源:_backend_tk.py

示例4: sort_to_send

    def sort_to_send(self):
        """The data is collected and prepared here"""
        course_names = self.courseName.get().split()
        courses.append(*course_names)
        self.Init_data = {}

        if not self.username.get():
            creds = CS.get_netrc_creds()
            if not creds:
                tkMessageBox.showerror('Error',"No username passed and no .netrc credentials found, unable to login")
                return False
            else:
                username, password = creds
        else:
            username = self.username.get()
            # prompt the user for his password if not specified
            if not self.password.get():
                password = getpass.getpass()
            else:
                password = self.password.get()

        # should we be trimming paths?
        # TODO: this is a simple hack, something more elaborate needed
        mppl = None
        try:
            if self.mppl_entry.get() and int(self.mppl_entry.get()) > 0:
                #if mppl specified, always use that
                mppl = int(self.mppl_entry.get())
            elif platform.system() == "Windows":
                # if mppl is not specified on windows set manually
                mppl = 90
            else:
                # linux max path length is typically around 4060 so assume thats ok
                pass
        except ValueError:
            tkMessageBox.showerror('Error','Maximum length of a path component should be a positive integer')
            return False

        self.Init_data['max_path_part_len'] = mppl

        if self.proxy.get():
             self.Init_data['proxy']= self.proxy.get()

        if self.parser.get():
            self.Init_data['parser'] = self.parser.get()

        if self.gzip_courses:
            self.Init_data['gzip_courses'] = True

        if self.wkfilter.get():
            self.Init_data['wk_filter'] = self.wkfilter.get()

        if self.ignoreFiles.get():
            self.Init_data['ignorefiles']= self.ignoreFiles.get()
        else:
        # Ignorefiles is a bit buggy, as it would cause a AttributeError if not passed an empty string if the user hasn't entered anything
            self.Init_data['ignorefiles']= ''

        if not self.destination:
            self.destination = self.directory.get()

        queue.append([username,password])
        queue.append(self.Init_data)
        queue.append([self.destination,
                    bool(self.reverse.get()),
                    bool(self.gzip_courses.get())])
        return True
开发者ID:K-DawG007,项目名称:coursera-dl,代码行数:67,代码来源:gui.py


注:本文中的six.moves.tkinter_messagebox.showerror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。