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


Python ConfirmationDialog.show_error方法代码示例

本文整理汇总了Python中TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog.show_error方法的典型用法代码示例。如果您正苦于以下问题:Python ConfirmationDialog.show_error方法的具体用法?Python ConfirmationDialog.show_error怎么用?Python ConfirmationDialog.show_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog的用法示例。


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

示例1: start_download_from_uri

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def start_download_from_uri(self, uri):
        self.download_uri = uri

        if get_gui_setting(self.gui_settings, "ask_download_settings", True, is_bool=True):
            # If tribler settings is not available, fetch the settings and inform the user to try again.
            if not self.tribler_settings:
                self.fetch_settings()
                ConfirmationDialog.show_error(self, "Download Error", "Tribler settings is not available yet. "
                                                                      "Fetching it now. Please try again later.")
                return
            # Clear any previous dialog if exists
            if self.dialog:
                self.dialog.close_dialog()
                self.dialog = None

            self.dialog = StartDownloadDialog(self, self.download_uri)
            self.dialog.button_clicked.connect(self.on_start_download_action)
            self.dialog.show()
            self.start_download_dialog_active = True
        else:
            # In the unlikely scenario that tribler settings are not available yet, try to fetch settings again and
            # add the download uri back to self.pending_uri_requests to process again.
            if not self.tribler_settings:
                self.fetch_settings()
                if self.download_uri not in self.pending_uri_requests:
                    self.pending_uri_requests.append(self.download_uri)
                return

            self.window().perform_start_download_request(self.download_uri,
                                                         self.window().tribler_settings['download_defaults'][
                                                             'anonymity_enabled'],
                                                         self.window().tribler_settings['download_defaults'][
                                                             'safeseeding_enabled'],
                                                         self.tribler_settings['download_defaults']['saveas'], [], 0)
            self.process_uri_request()
开发者ID:Tribler,项目名称:tribler,代码行数:37,代码来源:tribler_window.py

示例2: on_emptying_tokens

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def on_emptying_tokens(self, data):
        if not data:
            return
        json_data = json.dumps(data)

        if has_qr:
            self.empty_tokens_barcode_dialog = QWidget()
            self.empty_tokens_barcode_dialog.setWindowTitle("Please scan the following QR code")
            self.empty_tokens_barcode_dialog.setGeometry(10, 10, 500, 500)
            qr = qrcode.QRCode(
                version=1,
                error_correction=qrcode.constants.ERROR_CORRECT_M,
                box_size=10,
                border=5,
            )
            qr.add_data(json_data)
            qr.make(fit=True)

            img = qr.make_image()  # PIL format

            qim = ImageQt(img)
            pixmap = QtGui.QPixmap.fromImage(qim).scaled(600, 600, QtCore.Qt.KeepAspectRatio)
            label = QLabel(self.empty_tokens_barcode_dialog)
            label.setPixmap(pixmap)
            self.empty_tokens_barcode_dialog.resize(pixmap.width(), pixmap.height())
            self.empty_tokens_barcode_dialog.show()
        else:
            ConfirmationDialog.show_error(self.window(), DEPENDENCY_ERROR_TITLE, DEPENDENCY_ERROR_MESSAGE)
开发者ID:Tribler,项目名称:tribler,代码行数:30,代码来源:settingspage.py

示例3: on_payment

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def on_payment(self, payment):
     if not payment["success"]:
         # Error occurred during payment
         main_text = "Transaction with id %s failed." % payment["transaction_number"]
         self.window().tray_show_message("Transaction failed", main_text)
         ConfirmationDialog.show_error(self.window(), "Transaction failed", main_text)
         self.window().hide_status_bar()
     else:
         self.window().show_status_bar("Transaction in process, please don't close Tribler.")
开发者ID:synctext,项目名称:tribler,代码行数:11,代码来源:marketpage.py

示例4: save_to_file

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def save_to_file(self, filename, data):
     base_dir = QFileDialog.getExistingDirectory(self, "Select an export directory", "", QFileDialog.ShowDirsOnly)
     if len(base_dir) > 0:
         dest_path = os.path.join(base_dir, filename)
         try:
             torrent_file = open(dest_path, "wb")
             torrent_file.write(json.dumps(data))
             torrent_file.close()
         except IOError as exc:
             ConfirmationDialog.show_error(self.window(), "Error exporting file", str(exc))
开发者ID:Tribler,项目名称:tribler,代码行数:12,代码来源:debug_window.py

示例5: on_export_download_request_done

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def on_export_download_request_done(dest_path, data):
     try:
         torrent_file = open(dest_path, "wb")
         torrent_file.write(data)
         torrent_file.close()
     except IOError as exc:
         ConfirmationDialog.show_error(self.window(),
                                       "Error when exporting file",
                                       "An error occurred when exporting the torrent file: %s" % str(exc))
     else:
         self.window().tray_show_message("Torrent file exported", "Torrent file exported to %s" % dest_path)
开发者ID:synctext,项目名称:tribler,代码行数:13,代码来源:editchannelpage.py

示例6: on_memory_dump_data_available

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def on_memory_dump_data_available(self, filename, data):
     if not data:
         return
     dest_path = os.path.join(self.export_dir, filename)
     try:
         memory_dump_file = open(dest_path, "wb")
         memory_dump_file.write(data)
         memory_dump_file.close()
     except IOError as exc:
         ConfirmationDialog.show_error(self.window(),
                                       "Error when exporting file",
                                       "An error occurred when exporting the torrent file: %s" % str(exc))
开发者ID:Tribler,项目名称:tribler,代码行数:14,代码来源:debug_window.py

示例7: on_files_list_loaded

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def on_files_list_loaded(self):
        if self.active_index == -1:
            largest_index, largest_file = self.window().left_menu_playlist.get_largest_file()

            if not largest_file:
                # We don't have a media file in this torrent. Reset everything and show an error
                ConfirmationDialog.show_error(self.window(), "No media files", "This download contains no media files.")
                self.window().hide_left_menu_playlist()
                return

            self.active_index = largest_index
        self.play_active_item()
开发者ID:synctext,项目名称:tribler,代码行数:14,代码来源:videoplayerpage.py

示例8: on_download_clicked

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def on_download_clicked(self):
     if self.has_metainfo and len(self.get_selected_files()) == 0:  # User deselected all torrents
         ConfirmationDialog.show_error(self.window(), "No files selected",
                                       "Please select at least one file to download.")
     else:
         download_dir = self.dialog_widget.destination_input.currentText()
         is_writable, error = is_dir_writable(download_dir)
         if not is_writable:
             gui_error_message = "Tribler cannot download to <i>%s</i> directory. Please add proper write " \
                                 "permissions to the directory or choose another download directory and try " \
                                 "to download again. [%s]" % (download_dir, error)
             ConfirmationDialog.show_message(self.dialog_widget, "Insufficient Permissions", gui_error_message, "OK")
         else:
             self.button_clicked.emit(1)
开发者ID:synctext,项目名称:tribler,代码行数:16,代码来源:startdownloaddialog.py

示例9: show_new_order_dialog

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def show_new_order_dialog(self, is_ask):
        if not self.wallets[self.chosen_wallets[0]]['created']:
            ConfirmationDialog.show_error(self.window(), "Wallet not available",
                                          "%s wallet not available, please create it first." % self.chosen_wallets[0])
            return
        elif not self.wallets[self.chosen_wallets[1]]['created']:
            ConfirmationDialog.show_error(self.window(), "Wallet not available",
                                          "%s wallet not available, please create it first." % self.chosen_wallets[1])
            return

        self.dialog = NewMarketOrderDialog(self.window().stackedWidget, is_ask, self.chosen_wallets[0],
                                           self.chosen_wallets[1], self.wallets)
        self.dialog.button_clicked.connect(self.on_new_order_action)
        self.dialog.show()
开发者ID:synctext,项目名称:tribler,代码行数:16,代码来源:marketpage.py

示例10: on_memory_dump_button_clicked

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def on_memory_dump_button_clicked(self, dump_core):
        self.export_dir = QFileDialog.getExistingDirectory(self, "Please select the destination directory", "",
                                                           QFileDialog.ShowDirsOnly)

        if len(self.export_dir) > 0:
            filename = "tribler_mem_dump_%s_%s.json" % \
                       ('core' if dump_core else 'gui', datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
            if dump_core:
                self.request_mgr = TriblerRequestManager()
                self.request_mgr.download_file("debug/memory/dump",
                                               lambda data: self.on_memory_dump_data_available(filename, data))
            elif scanner:
                scanner.dump_all_objects(os.path.join(self.export_dir, filename))
            else:
                ConfirmationDialog.show_error(self.window(),
                                              "Error when performing a memory dump",
                                              "meliae memory dumper is not compatible with Python 3")
开发者ID:Tribler,项目名称:tribler,代码行数:19,代码来源:debug_window.py

示例11: on_start_download_action

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def on_start_download_action(self, action):
        if action == 1:
            if self.dialog and self.dialog.dialog_widget:
                self.window().perform_start_download_request(
                    self.download_uri, self.dialog.dialog_widget.anon_download_checkbox.isChecked(),
                    self.dialog.dialog_widget.safe_seed_checkbox.isChecked(),
                    self.dialog.dialog_widget.destination_input.currentText(),
                    self.dialog.get_selected_files(),
                    self.dialog.dialog_widget.files_list_view.topLevelItemCount())
            else:
                ConfirmationDialog.show_error(self, "Tribler UI Error", "Something went wrong. Please try again.")
                logging.exception("Error while trying to download. Either dialog or dialog.dialog_widget is None")

        if self.dialog:
            self.dialog.close_dialog()
            self.dialog = None
            self.start_download_dialog_active = False

        if action == 0:  # We do this after removing the dialog since process_uri_request is blocking
            self.process_uri_request()
开发者ID:Tribler,项目名称:tribler,代码行数:22,代码来源:tribler_window.py

示例12: confirm_partially_empty_tokens

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def confirm_partially_empty_tokens(self, action):
        tokens = self.empty_partial_tokens_dialog.dialog_widget.dialog_input.text()
        self.empty_partial_tokens_dialog.close_dialog()
        self.empty_partial_tokens_dialog = None

        if action == 0:
            try:
                tokens = int(float(tokens))
            except ValueError:
                ConfirmationDialog.show_error(self.window(), "Wrong input", "The provided amount is not a number")
                return

            self.confirm_empty_tokens_dialog = ConfirmationDialog(self, "Empty tokens into another account",
                                                                  "Are you sure you want to empty %d bandwidth tokens "
                                                                  "into another account? "
                                                                  "Warning: one-way action that cannot be revered" %
                                                                  tokens,
                                                                  [
                                                                      ('EMPTY', BUTTON_TYPE_NORMAL),
                                                                      ('CANCEL', BUTTON_TYPE_CONFIRM)
                                                                  ])
            self.confirm_empty_tokens_dialog.button_clicked.connect(
                lambda action2: self.on_confirm_partially_empty_tokens(action2, tokens))
            self.confirm_empty_tokens_dialog.show()
开发者ID:Tribler,项目名称:tribler,代码行数:26,代码来源:settingspage.py

示例13: save_settings

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
    def save_settings(self):
        # Create a dictionary with all available settings
        settings_data = {'general': {}, 'Tribler': {}, 'download_defaults': {}, 'libtorrent': {}, 'watch_folder': {},
                         'tunnel_community': {}, 'trustchain': {}, 'credit_mining': {}, 'resource_monitor': {},
                         'ipv8': {}, 'chant': {}}
        settings_data['download_defaults']['saveas'] = self.window().download_location_input.text().encode('utf-8')
        settings_data['general']['log_dir'] = self.window().log_location_input.text()

        settings_data['watch_folder']['enabled'] = self.window().watchfolder_enabled_checkbox.isChecked()
        if settings_data['watch_folder']['enabled']:
            settings_data['watch_folder']['directory'] = self.window().watchfolder_location_input.text()

        settings_data['libtorrent']['proxy_type'] = self.window().lt_proxy_type_combobox.currentIndex()

        if self.window().lt_proxy_server_input.text() and len(self.window().lt_proxy_server_input.text()) > 0 and len(
                self.window().lt_proxy_port_input.text()) > 0:
            try:
                settings_data['libtorrent']['proxy_server'] = "%s:%s" % (self.window().lt_proxy_server_input.text(),
                                                                         int(self.window().lt_proxy_port_input.text()))
            except ValueError:
                ConfirmationDialog.show_error(self.window(), "Invalid proxy port number",
                                              "You've entered an invalid format for the proxy port number. "
                                              "Please enter a whole number.")
                return
        else:
            settings_data['libtorrent']['proxy_server'] = ":"

        if self.window().lt_proxy_username_input.text() and self.window().lt_proxy_password_input.text():
            settings_data['libtorrent']['proxy_auth'] = "%s:%s" % (self.window().lt_proxy_username_input.text(),
                                                                   self.window().lt_proxy_password_input.text())
        else:
            settings_data['libtorrent']['proxy_auth'] = ":"

        settings_data['libtorrent']['utp'] = self.window().lt_utp_checkbox.isChecked()

        try:
            max_conn_download = int(self.window().max_connections_download_input.text())
        except ValueError:
            ConfirmationDialog.show_error(self.window(), "Invalid number of connections",
                                          "You've entered an invalid format for the maximum number of connections. "
                                          "Please enter a whole number.")
            return
        if max_conn_download == 0:
            max_conn_download = -1
        settings_data['libtorrent']['max_connections_download'] = max_conn_download

        try:
            if self.window().upload_rate_limit_input.text():
                user_upload_rate_limit = int(self.window().upload_rate_limit_input.text()) * 1024
                if user_upload_rate_limit < sys.maxsize:
                    settings_data['libtorrent']['max_upload_rate'] = user_upload_rate_limit
                else:
                    raise ValueError
            if self.window().download_rate_limit_input.text():
                user_download_rate_limit = int(self.window().download_rate_limit_input.text()) * 1024
                if user_download_rate_limit < sys.maxsize:
                    settings_data['libtorrent']['max_download_rate'] = user_download_rate_limit
                else:
                    raise ValueError
        except ValueError:
            ConfirmationDialog.show_error(self.window(), "Invalid value for bandwidth limit",
                                          "You've entered an invalid value for the maximum upload/download rate. "
                                          "Please enter a whole number (max: %d)" % (sys.maxsize / 1000))
            return

        try:
            if self.window().api_port_input.text():
                api_port = int(self.window().api_port_input.text())
                if api_port <= 0 or api_port >= 65536:
                    raise ValueError()
                self.window().gui_settings.setValue("api_port", api_port)
        except ValueError:
            ConfirmationDialog.show_error(self.window(), "Invalid value for api port",
                                          "Please enter a valid port for the api (between 0 and 65536)")
            return

        seeding_modes = ['forever', 'time', 'never', 'ratio']
        selected_mode = 'forever'
        for seeding_mode in seeding_modes:
            if getattr(self.window(), "seeding_" + seeding_mode + "_radio").isChecked():
                selected_mode = seeding_mode
                break
        settings_data['download_defaults']['seeding_mode'] = selected_mode
        settings_data['download_defaults']['seeding_ratio'] = self.window().seeding_ratio_combobox.currentText()

        try:
            settings_data['download_defaults']['seeding_time'] = string_to_seconds(
                self.window().seeding_time_input.text())
        except ValueError:
            ConfirmationDialog.show_error(self.window(), "Invalid seeding time",
                                          "You've entered an invalid format for the seeding time (expected HH:MM)")
            return

        settings_data['credit_mining']['enabled'] = self.window().credit_mining_enabled_checkbox.isChecked()
        try:
            settings_data['credit_mining']['max_disk_space'] = int(self.window().max_disk_space_input.text())
        except ValueError:
            ConfirmationDialog.show_error(self.window(), "Invalid number",
                                          "You've entered an invalid number for max disk space value")
            return
#.........这里部分代码省略.........
开发者ID:Tribler,项目名称:tribler,代码行数:103,代码来源:settingspage.py

示例14: on_credit_mining_error

# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show_error [as 别名]
 def on_credit_mining_error(self, error):
     ConfirmationDialog.show_error(self, "Credit Mining Error", error[u'message'])
开发者ID:Tribler,项目名称:tribler,代码行数:4,代码来源:tribler_window.py


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