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


Python confirmationdialog.ConfirmationDialog类代码示例

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


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

示例1: on_emptying_tokens

    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,代码行数:28,代码来源:settingspage.py

示例2: start_download_from_uri

    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,代码行数:35,代码来源:tribler_window.py

示例3: SubscribedChannelsPage

class SubscribedChannelsPage(QWidget):
    """
    This page shows all the channels that the user has subscribed to.
    """

    def __init__(self):
        QWidget.__init__(self)

        self.dialog = None
        self.request_mgr = None

    def initialize(self):
        self.window().add_subscription_button.clicked.connect(self.on_add_subscription_clicked)

    def load_subscribed_channels(self):
        self.window().subscribed_channels_list.set_data_items([(LoadingListItem, None)])

        self.request_mgr = TriblerRequestManager()
        self.request_mgr.perform_request("channels/subscribed", self.received_subscribed_channels)

    def received_subscribed_channels(self, results):
        if not results:
            return
        self.window().subscribed_channels_list.set_data_items([])
        items = []

        if len(results['subscribed']) == 0:
            self.window().subscribed_channels_list.set_data_items(
                [(LoadingListItem, "You are not subscribed to any channel.")])
            return

        for result in results['subscribed']:
            items.append((ChannelListItem, result))
        self.window().subscribed_channels_list.set_data_items(items)

    def on_add_subscription_clicked(self):
        self.dialog = ConfirmationDialog(self, "Add subscribed channel",
                                         "Please enter the identifier of the channel you want to subscribe to below. "
                                         "It can take up to a minute before the channel is visible in your list of "
                                         "subscribed channels.",
                                         [('ADD', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)],
                                         show_input=True)
        self.dialog.dialog_widget.dialog_input.setPlaceholderText('Channel identifier')
        self.dialog.button_clicked.connect(self.on_subscription_added)
        self.dialog.show()

    def on_subscription_added(self, action):
        if action == 0:
            self.request_mgr = TriblerRequestManager()
            self.request_mgr.perform_request("channels/subscribed/%s" % self.dialog.dialog_widget.dialog_input.text(),
                                             self.on_channel_subscribed, method='PUT')

        self.dialog.close_dialog()
        self.dialog = None

    def on_channel_subscribed(self, _):
        pass
开发者ID:synctext,项目名称:tribler,代码行数:57,代码来源:subscribedchannelspage.py

示例4: on_payment

 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,代码行数:9,代码来源:marketpage.py

示例5: show_error

    def show_error(self, error_text):
        main_text = "An error occurred during the request:\n\n%s" % error_text
        error_dialog = ConfirmationDialog(TriblerRequestManager.window, "Request error",
                                          main_text, [('CLOSE', BUTTON_TYPE_NORMAL)])

        def on_close():
            error_dialog.close_dialog()

        error_dialog.button_clicked.connect(on_close)
        error_dialog.show()
开发者ID:synctext,项目名称:tribler,代码行数:10,代码来源:tribler_request_manager.py

示例6: on_rss_feeds_remove_selected_clicked

 def on_rss_feeds_remove_selected_clicked(self):
     if len(self.window().edit_channel_rss_feeds_list.selectedItems()) == 0:
         ConfirmationDialog.show_message(self, "Remove RSS Feeds",
                                         "Selection is empty. Please select the feeds to remove.", "OK")
         return
     self.dialog = ConfirmationDialog(self, "Remove RSS feed",
                                      "Are you sure you want to remove the selected RSS feed?",
                                      [('REMOVE', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)])
     self.dialog.button_clicked.connect(self.on_rss_feed_dialog_removed)
     self.dialog.show()
开发者ID:synctext,项目名称:tribler,代码行数:10,代码来源:editchannelpage.py

示例7: save_to_file

 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,代码行数:10,代码来源:debug_window.py

示例8: on_export_download_request_done

 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,代码行数:11,代码来源:editchannelpage.py

示例9: on_files_list_loaded

    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,代码行数:12,代码来源:videoplayerpage.py

示例10: on_memory_dump_data_available

 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,代码行数:12,代码来源:debug_window.py

示例11: on_browse_dir_clicked

    def on_browse_dir_clicked(self):
        chosen_dir = QFileDialog.getExistingDirectory(self.window(), "Please select the destination directory of your "
                                                                     "download", "", QFileDialog.ShowDirsOnly)

        if len(chosen_dir) != 0:
            self.dialog_widget.destination_input.setCurrentText(chosen_dir)

        is_writable, error = is_dir_writable(chosen_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. [%s]" \
                                % (chosen_dir, error)
            ConfirmationDialog.show_message(self.dialog_widget, "Insufficient Permissions", gui_error_message, "OK")
开发者ID:synctext,项目名称:tribler,代码行数:13,代码来源:startdownloaddialog.py

示例12: show_new_order_dialog

    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,代码行数:14,代码来源:marketpage.py

示例13: on_low_storage

 def on_low_storage(self):
     """
     Dealing with low storage space available. First stop the downloads and the core manager and ask user to user to
     make free space.
     :return:
     """
     self.downloads_page.stop_loading_downloads()
     self.core_manager.stop(False)
     close_dialog = ConfirmationDialog(self.window(), "<b>CRITICAL ERROR</b>",
                                       "You are running low on disk space (<100MB). Please make sure to have "
                                       "sufficient free space available and restart Tribler again.",
                                       [("Close Tribler", BUTTON_TYPE_NORMAL)])
     close_dialog.button_clicked.connect(lambda _: self.close_tribler())
     close_dialog.show()
开发者ID:Tribler,项目名称:tribler,代码行数:14,代码来源:tribler_window.py

示例14: on_download_clicked

 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,代码行数:14,代码来源:startdownloaddialog.py

示例15: on_choose_log_dir_clicked

    def on_choose_log_dir_clicked(self):
        previous_log_dir = self.window().log_location_input.text() or ""
        log_dir = QFileDialog.getExistingDirectory(self.window(), "Please select the log directory",
                                                   previous_log_dir, QFileDialog.ShowDirsOnly)

        if not log_dir or log_dir == previous_log_dir:
            return

        is_writable, error = is_dir_writable(log_dir)
        if not is_writable:
            gui_error_message = "<i>%s</i> is not writable. [%s]" % (log_dir, error)
            ConfirmationDialog.show_message(self.window(), "Insufficient Permissions", gui_error_message, "OK")
        else:
            self.window().log_location_input.setText(log_dir)
开发者ID:Tribler,项目名称:tribler,代码行数:14,代码来源:settingspage.py


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