python类showerror()的实例源码

AppGUI.py 文件源码 项目:stash-scanner 作者: senuido 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def load(self):
        ls = LoadingScreen(self)
        # ls.lift()

        self.check_version()
        Thread(target=self.init_scanner, args=(ls,)).start()
        self.wait_window(ls)

        self.focus_set()
        self.lift()

        if self.init_error:
            title, message = self.init_error.args
            message += '\n{}'
            messagebox.showerror(title, message.format('Application will now close.'), parent=self)
            self.on_close()
            return

        self.init_warn()
        self.nb_cfg.onTabChange()

        self.after(100, self.handle_msgs)
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _load_run_results(self):
        filename = filedialog.askopenfilename()
        if not filename:
            return
        self.runresultsvar.set(filename)

        valid_parsers = importer.get_parsers(filename, self.cfg)
        if not valid_parsers:
            messagebox.showerror(
                'Unknown Format', 'Unable to parse this file. '
                'View log for details.')
            self.choose_parser['values'] = ['']
            self.choose_parser.current(0)
            self.choose_parser.event_generate('<<ComboboxSelected>>')
            return

        self.valid_parsers = {p.__name__: p for p in valid_parsers}
        self.choose_parser['values'] = list(self.valid_parsers.keys())
        if len(valid_parsers) > 1:
            self.choose_parser.config(state='enabled')
        self.choose_parser.current(0)
        self.choose_parser.event_generate('<<ComboboxSelected>>')
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _on_parser_changed(self, dummy_event=None):
        filepath = self.runresultsvar.get()
        if not filepath:
            self.runresultsview.clear()
            self.runresultsview.refresh()
            return
        parser_name = self.choose_parser.get()
        if not parser_name:
            self.runresultsview.clear()
            self.runresultsview.refresh()
            return
        parser = self.valid_parsers[parser_name]
        results = []
        try:
            self.results = importer.parse_results(parser, filepath, self.cfg)
        except importer.ParserError as ex:
            messagebox.showerror(
                'Parser Error', 'An error occurred while parsing. '
                'View log for details.')
            LOG.exception(ex)

        self.runresultsview.populate(self.results['tests'])
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def login_callback(self, logincfg):
        """
        called by login window
        """
        use_history = self.cfg.getboolean('main', 'history')
        if use_history:
            hist = importer.load_history()
            importer.update_history(hist, logincfg)
        # pylint
        try:
            qcc = qualitycenter.connect(**logincfg)
        except pythoncom.com_error as ex:
            messagebox.showerror('Unable to Connect',
                                 'Error Details:\n\n{}'.format(ex))
            return False
        self.qcc = qcc
        self.qc_domain.set(logincfg['domain'])
        self.qc_project.set(logincfg['project'])
        self.qc_conn_status.set(True)
        self.refresh_qc_directories()
        return True
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def errorBox(self, title, message):
        self.topLevel.update_idletasks()
        MessageBox.showerror(title, message)
        self.__bringToFront()
appjar.py 文件源码 项目:Cryptokey_Generator 作者: 8BitCookie 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def errorBox(self, title, message):
        self.topLevel.update_idletasks()
        MessageBox.showerror(title, message)
        self.__bringToFront()
ULAO02.py 文件源码 项目:mcculw 作者: mccdaq 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def send_data(self):
        # Build the data array
        num_chans = min(self.ao_props.num_chans, 4)
        num_points = num_chans
        ao_range = self.ao_props.available_ranges[0]

        memhandle = ul.win_buf_alloc(num_points)

        # Check if the buffer was successfully allocated
        if not memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.start_button["state"] = tk.NORMAL
            return

        try:
            data_array = self.memhandle_as_ctypes_array(memhandle)

            full_scale_count = (2 ** self.ao_props.resolution) - 1
            value_step = full_scale_count / (num_chans + 1)
            for point_num in range(0, num_points):
                raw_value = int(value_step * (point_num + 1))
                data_array[point_num] = raw_value

                self.raw_data_labels[point_num]["text"] = str(raw_value)
                # ul.to_eng_units cannot be used here, as it uses the analog
                # input resolution. Instead, do the conversion on our own.
                volts = self.ao_to_eng_units(
                    raw_value, ao_range, self.ao_props.resolution)
                self.volts_labels[point_num]["text"] = (
                    '{:.3f}'.format(volts))

            ul.a_out_scan(
                self.board_num, 0, num_chans - 1, num_points, 100, ao_range,
                memhandle, 0)
        except ULError as e:
            self.show_ul_error(e)
        finally:
            ul.win_buf_free(memhandle)
ULDI03.py 文件源码 项目:mcculw 作者: mccdaq 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def start_scan(self):
        rate = 100
        count = 1000

        # Allocate a buffer for the scan
        self.memhandle = ul.win_buf_alloc(count)

        # Check if the buffer was successfully allocated
        if not self.memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.set_ui_idle_state()
            return

        try:
            # Configure the port (if necessary)
            if self.port.is_port_configurable:
                ul.d_config_port(
                    self.board_num, self.port.type, DigitalIODirection.IN)

            # Run the scan
            ul.d_in_scan(
                self.board_num, self.port.type, count, rate, self.memhandle,
                ScanOptions.BACKGROUND)
        except ULError as e:
            self.show_ul_error(e)
            self.set_ui_idle_state()
            return

        # Convert the memhandle to a ctypes array
        # Note: the ctypes array will no longer be valid after win_buf_free is called.
        # A copy of the buffer can be created using win_buf_to_array
        # before the memory is freed. The copy can be used at any time.
        self.ctypes_array = self.memhandle_as_ctypes_array(self.memhandle)

        # Start updating the displayed values
        self.update_displayed_values()
uiexample.py 文件源码 项目:mcculw 作者: mccdaq 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def show_ul_error(self, ul_error):
        message = (
            "A UL Error occurred.\n\n Error Code: " + str(ul_error.errorcode)
            + "\nMessage: " + ul_error.message)
        messagebox.showerror("Error", message)
CInScan02.py 文件源码 项目:mcculw 作者: mccdaq 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def start_scan(self):
        rate = 390
        total_count = 100

        # Allocate a buffer for the scan
        memhandle = ul.win_buf_alloc_32(total_count)

        # Check if the buffer was successfully allocated
        if not memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.start_button["state"] = tk.NORMAL
            return

        try:
            # Configure the counter
            ul.c_config_scan(
                self.board_num, self.chan_num, CounterMode.DECREMENT_ON,
                CounterDebounceTime.DEBOUNCE_NONE, 0,
                CounterEdgeDetection.FALLING_EDGE,
                CounterTickSize.TICK20PT83ns, 1)

            # Run the scan
            ul.c_in_scan(
                self.board_num, self.chan_num, self.chan_num, total_count,
                rate, memhandle, 0)

            # Convert the memhandle to a ctypes array
            # Note: the ctypes array will only be valid until win_buf_free
            # is called.
            # A copy of the buffer can be created using win_buf_to_array_32
            # before the memory is freed. The copy can be used at any time.
            array = self.memhandle_as_ctypes_array_32(memhandle)

            # Display the values
            self.display_values(array, total_count)
        except ULError as e:
            self.show_ul_error(e)
        finally:
            # Free the allocated memory
            ul.win_buf_free(memhandle)
            self.start_button["state"] = tk.NORMAL
GUI_message_box_error.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def _msgBox():
#     msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.')  
#     msg.showwarning('Python Message Warning Box', 'A Python GUI created using tkinter:'
#                       '\nWarning: There might be a bug in this code.')
    msg.showerror('Python Message Error Box', 'A Python GUI created using tkinter:'
                  '\nError: Houston ~ we DO have a serious PROBLEM!')

# Add another Menu to the Menu Bar and an item
start_window.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def open_pack(self):
        pack = filedialog.askdirectory(initialdir=self.resourcepack_location)
        if os.path.isfile(pack + "/pack.mcmeta"):
            # messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
            self.parent.directory = pack
            self.parent.cmd.tree_refresh()
            self.destroy()
        else:
            messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")
start_window.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def open_zip(self):
        pack = filedialog.askopenfile("r", initialdir=self.resourcepack_location)
        found_pack = False

        if pack:
            amount = functions.zip_files(pack.name)
            progress = dialog.ProgressWindow(self.parent, title="Opening Zip", maximum=amount)

            count = 0

            with zipfile.ZipFile(pack.name, "r") as z:
                for file in z.namelist():
                    if file == "pack.mcmeta":
                        # messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
                        found_pack = True
                        self.destroy()

                if found_pack:
                    self.parent.d = tempfile.TemporaryDirectory()
                    for file in z.namelist():
                        z.extract(file, self.parent.d.name)

                        count += 1
                        progress.variable_name.set("Current File: " + file)
                        progress.variable_percent.set("{}% Complete".format(round(100 * float(count) / float(amount))))
                        progress.variable_progress.set(progress.variable_progress.get() + 1)

                    self.parent.name = pack.name.split("/")[-1].split(".")[0]
                    self.parent.directory = self.parent.d.name
                    self.parent.directory_real = pack.name
                    self.parent.cmd.tree_refresh()
                    self.destroy()

                elif not found_pack:
                    messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")

                pack.close()
            progress.destroy()
start_window.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def install_pack(self):
        pack = filedialog.askdirectory()
        if os.path.isfile(pack + "/pack.mcmeta"):
            # messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
            try:
                shutil.move(pack, self.resourcepack_location)
            except shutil.Error:
                messagebox.showerror("Error", "This pack is already installed.")
        else:
            messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")
widget.py 文件源码 项目:touch-pay-client 作者: HackPucBemobi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def error(self, message):
        """ Shows error message """
        if PY2:
            import tkMessageBox as messagebox
        else:
            from tkinter import messagebox

        messagebox.showerror('web2py start server', message)
spgl.py 文件源码 项目:SPGL 作者: wynand1004 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def show_error(self, title, message):
        return messagebox.showerror(title, message)
spgl.py 文件源码 项目:SPGL 作者: wynand1004 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def show_error(self, title, message):
        return messagebox.showerror(title, message)
simulate.py 文件源码 项目:accpy 作者: kramerfelix 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def gui_twisstrack(frame, w, h, status, start, stop):
    def _start():
        latt = latticemenu.get()
        if latt in closedlatts:
            closed = True
        elif latt in openlatts:
            closed = False
        else:
            showerror(title='ERROR', message='Please choose a lattice')
            return
        slic = int(entry_slice.get())
        mode = 'trackbeta'
        particles = 1
        rounds = 1
        runthread(status, tabs, lsd,
                  (closed, latt, slic, mode, particles, rounds))

    start.configure(command=_start)
    tabs = cs_tabbar(frame, w, h, ['Menu', 'Radial', 'Axial', 'Dispersion',
                                   'Overview', 'Parameters', 'Beam extents'])

    cs_label(tabs[0], 1, 1, 'Lattice')
    cs_label(tabs[0], 1, 2, 'Nr. of slices')
    closedlatts, openlatts = lattlist()
    latticemenu = cs_dropd(tabs[0], 2, 1, closedlatts + openlatts)
    entry_slice = cs_Intentry(tabs[0], 2, 2, 1e3)
    return
mainwindow.py 文件源码 项目:hypersim 作者: redPanther 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def readConfig(self,layout_file, layout_type="hyperion"):
            opc_map = {'opc_xy' : (0,1),'opc_xz' : (0,2),'opc_yz' : (1,2) }

            try:
                if layout_type == "hyperion":
                    self.readConfig_hyperion(layout_file)
                elif layout_type in opc_map:
                    self.readConfig_opc(layout_file, opc_map[layout_type][0], opc_map[layout_type][1])
                else:
                    print("unknown type of config file")
                    exit(1)
            except Exception as e:
                tkMessageBox.showerror("Open Config File", "Failed to open '%s' file \n'%s'\n%s" % (self.layout_type, self.layout_file, e))

    # ------------------------------------------------------


问题


面经


文章

微信
公众号

扫码关注公众号