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


Python widgets.DownloadProgressBox类代码示例

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


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

示例1: start_download

 def start_download(self, file_uri, dest_file, callback=None, data=None):
     self.clean_widgets()
     logger.debug("Downloading %s to %s", file_uri, dest_file)
     self.download_progress = DownloadProgressBox({"url": file_uri, "dest": dest_file}, cancelable=True)
     callback_function = callback or self.download_complete
     self.download_progress.connect("complete", callback_function, data)
     self.widget_box.pack_start(self.download_progress, False, False, 10)
     self.download_progress.show()
     self.download_progress.start()
开发者ID:regoecuaycong,项目名称:lutris,代码行数:9,代码来源:installgamedialog.py

示例2: start_download

 def start_download(self, file_uri, dest_file, callback=None, data=None):
     self.clean_widgets()
     self.download_progress = DownloadProgressBox(
         {'url': file_uri, 'dest': dest_file}, cancelable=True
     )
     callback_function = callback or self.download_complete
     self.download_progress.connect('complete', callback_function, data)
     self.widget_box.pack_start(self.download_progress, False, False, 10)
     self.download_progress.show()
     self.download_progress.start()
开发者ID:nsteenv,项目名称:lutris,代码行数:10,代码来源:installer.py

示例3: DownloadDialog

class DownloadDialog(Gtk.Dialog):
    """Dialog showing a download in progress."""
    def __init__(self, url=None, dest=None, title=None, label=None,
                 downloader=None):
        Gtk.Dialog.__init__(self, title or "Downloading file")
        self.set_size_request(485, 104)
        self.set_border_width(12)
        params = {'url': url,
                  'dest': dest,
                  'title': label or "Downloading %s" % url}
        self.download_box = DownloadProgressBox(params, downloader=downloader)

        self.download_box.connect('complete', self.download_complete)
        self.download_box.connect('cancel', self.download_cancelled)
        self.connect('response', self.on_response)

        self.get_content_area().add(self.download_box)
        self.show_all()
        self.download_box.start()

    def download_complete(self, _widget, _data):
        self.response(Gtk.ResponseType.OK)
        self.destroy()

    def download_cancelled(self, _widget, data):
        self.response(Gtk.ResponseType.CANCEL)
        self.destroy()

    def on_response(self, dialog, response):
        if response == Gtk.ResponseType.DELETE_EVENT:
            self.download_box.downloader.cancel()
            self.destroy()
开发者ID:Freso,项目名称:lutris,代码行数:32,代码来源:dialogs.py

示例4: DownloadDialog

class DownloadDialog(Gtk.Dialog):
    """ Dialog showing a download in progress. """

    def __init__(self, url, dest):
        super(DownloadDialog, self).__init__("Downloading file")
        self.set_size_request(560, 100)
        params = {'url': url, 'dest': dest}
        self.download_progress_box = DownloadProgressBox(params)
        self.download_progress_box.connect('complete',
                                           self.download_complete)
        self.download_progress_box.connect('cancelrequested',
                                           self.download_cancelled)
        label = Gtk.Label(label='Downloading %s' % url)
        label.set_selectable(True)
        label.set_padding(0, 0)
        label.set_alignment(0.0, 1.0)
        self.vbox.pack_start(label, True, True, 0)
        self.vbox.pack_start(self.download_progress_box, True, False, 0)
        self.show_all()
        self.download_progress_box.start()

    def download_complete(self, _widget, _data):
        self.destroy()

    def download_cancelled(self, _widget, data):
        self.destroy()
开发者ID:Kehlyos,项目名称:lutris,代码行数:26,代码来源:dialogs.py

示例5: start_download

 def start_download(self, file_uri, dest_file, callback=None, data=None):
     self.clean_widgets()
     logger.debug("Downloading %s to %s", file_uri, dest_file)
     self.download_progress = DownloadProgressBox(
         {'url': file_uri, 'dest': dest_file}, cancelable=True
     )
     self.download_progress.cancel_button.hide()
     callback = callback or self.on_download_complete
     self.download_progress.connect('complete', callback, data)
     self.widget_box.pack_start(self.download_progress, False, False, 10)
     self.download_progress.show()
     self.download_progress.start()
     self.interpreter.abort_current_task = self.download_progress.cancel
开发者ID:RobLoach,项目名称:lutris,代码行数:13,代码来源:installgamedialog.py

示例6: __init__

 def __init__(self, url, dest):
     super(DownloadDialog, self).__init__("Downloading file")
     self.set_size_request(485, 104)
     self.set_border_width(12)
     params = {'url': url, 'dest': dest, 'title': 'Downloading %s' % url}
     self.download_progress_box = DownloadProgressBox(params)
     self.download_progress_box.connect('complete',
                                        self.download_complete)
     self.download_progress_box.connect('cancelrequested',
                                        self.download_cancelled)
     self.vbox.pack_start(self.download_progress_box, True, False, 0)
     self.show_all()
     self.download_progress_box.start()
开发者ID:regoecuaycong,项目名称:lutris,代码行数:13,代码来源:dialogs.py

示例7: __init__

    def __init__(self, url=None, dest=None, title=None, label=None,
                 downloader=None):
        Gtk.Dialog.__init__(self, title or "Downloading file")
        self.set_size_request(485, 104)
        self.set_border_width(12)
        params = {'url': url,
                  'dest': dest,
                  'title': label or "Downloading %s" % url}
        self.download_box = DownloadProgressBox(params, downloader=downloader)

        self.download_box.connect('complete', self.download_complete)
        self.download_box.connect('cancel', self.download_cancelled)
        self.connect('response', self.on_response)

        self.get_content_area().add(self.download_box)
        self.show_all()
        self.download_box.start()
开发者ID:Freso,项目名称:lutris,代码行数:17,代码来源:dialogs.py

示例8: InstallerDialog


#.........这里部分代码省略.........
        self.location_entry = FileChooserEntry(action, default_path)
        self.location_entry.show_all()
        if callback:
            self.location_entry.entry.connect('changed', callback)
        else:
            self.install_button.set_visible(False)
            self.continue_button.show()
        self.widget_box.pack_start(self.location_entry, False, False, 0)

    def on_target_changed(self, text_entry):
        """ Sets the installation target for the game """
        path = text_entry.get_text()
        self.interpreter.target_path = path
        self.show_non_empty_warning()

    def on_install_clicked(self, button):
        button.set_sensitive(False)
        self.interpreter.iter_game_files()

    def ask_user_for_file(self, message=None):
        self.clean_widgets()
        self.set_message(message)
        self.set_location_entry(None, 'file')

    def on_file_selected(self, widget):
        widget.set_sensitive(False)
        file_path = self.location_entry.get_text()
        self.interpreter.file_selected(file_path)

    def clean_widgets(self):
        for child_widget in self.widget_box.get_children():
            child_widget.destroy()

    def set_status(self, text):
        self.status_label.set_text(text)

    def add_spinner(self):
        self.clean_widgets()
        spinner = Gtk.Spinner()
        self.widget_box.pack_start(spinner, True, False, 10)
        spinner.show()
        spinner.start()

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        self.download_progress = DownloadProgressBox(
            {'url': file_uri, 'dest': dest_file}, cancelable=True
        )
        callback_function = callback or self.download_complete
        self.download_progress.connect('complete', callback_function, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()

    def wait_for_user_action(self, message, callback, data=None):
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(label=message)
        self.widget_box.add(label)
        label.show()
        button = Gtk.Button(label='Ok')
        button.connect('clicked', callback, data)
        self.widget_box.add(button)
        button.show()

    def download_complete(self, widget, data, more_data=None):
        """Action called on a completed download"""
        self.interpreter.iter_game_files()

    def on_steam_downloaded(self, widget, data, appid):
        self.interpreter.complete_steam_install(widget.dest, appid)

    def on_install_finished(self):
        """Actual game installation"""
        self.status_label.set_text("Installation finished !")
        self.clean_widgets()
        self.notify_install_success()
        self.continue_button.hide()
        self.install_button.hide()
        self.play_button.show()
        self.close_button.show()

    def notify_install_success(self):
        if self.parent:
            self.parent.view.emit('game-installed', self.game_ref)

    def on_install_error(self, message):
        self.status_label.set_text(message)
        self.clean_widgets()
        self.close_button.show()

    def launch_game(self, widget, _data=None):
        """Launch a game after it's been installed"""
        widget.set_sensitive(False)
        game = Game(self.interpreter.game_slug)
        game.play()
        self.close(widget)

    def close(self, _widget):
        self.destroy()
开发者ID:nsteenv,项目名称:lutris,代码行数:101,代码来源:installer.py

示例9: InstallerDialog


#.........这里部分代码省略.........
        self.clean_widgets()
        self.set_message(message)
        if self.selected_directory:
            path = self.selected_directory
        else:
            path = os.path.expanduser('~')
        self.set_location_entry(None, 'file', default_path=path)

    def on_file_selected(self, widget):
        file_path = self.location_entry.get_text()
        if os.path.isfile(file_path):
            self.selected_directory = os.path.dirname(file_path)
        else:
            return
        self.interpreter.file_selected(file_path)

    def clean_widgets(self):
        for child_widget in self.widget_box.get_children():
            child_widget.destroy()

    def set_status(self, text):
        self.status_label.set_text(text)

    def add_spinner(self):
        self.clean_widgets()
        spinner = Gtk.Spinner()
        self.widget_box.pack_start(spinner, True, False, 10)
        spinner.show()
        spinner.start()

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        logger.debug("Downloading %s to %s", file_uri, dest_file)
        self.download_progress = DownloadProgressBox(
            {'url': file_uri, 'dest': dest_file}, cancelable=True
        )
        callback_function = callback or self.download_complete
        self.download_progress.connect('complete', callback_function, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()

    def wait_for_user_action(self, message, callback, data=None):
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(label=message)
        label.set_use_markup(True)
        self.widget_box.add(label)
        label.show()
        button = Gtk.Button(label='Ok')
        button.connect('clicked', callback, data)
        self.widget_box.add(button)
        button.grab_focus()
        button.show()

    def input_menu(self, alias, options, preselect, has_entry, callback):
        """Display an input request as a dropdown menu with options."""
        time.sleep(0.3)
        self.clean_widgets()

        model = Gtk.ListStore(str, str)
        for option in options:
            key, label = option.popitem()
            model.append([key, label])
        combobox = Gtk.ComboBox.new_with_model(model)
        renderer_text = Gtk.CellRendererText()
开发者ID:Xodetaetl,项目名称:lutris,代码行数:67,代码来源:installgamedialog.py

示例10: InstallerDialog


#.........这里部分代码省略.........
        """Display a file/folder chooser."""
        if action == 'file':
            title = 'Select file'
            action = Gtk.FileChooserAction.OPEN
        elif action == 'folder':
            title = 'Select folder'
            action = Gtk.FileChooserAction.SELECT_FOLDER

        if self.location_entry:
            self.location_entry.destroy()
        self.location_entry = FileChooserEntry(title, action, default_path)
        self.location_entry.show_all()
        if callback_on_changed:
            self.location_entry.entry.connect('changed', callback_on_changed)
        else:
            self.install_button.set_visible(False)
            self.continue_button.connect('clicked', self.on_file_selected)
            self.continue_button.grab_focus()
            self.continue_button.show()
        self.widget_box.pack_start(self.location_entry, False, False, 0)

    def on_file_selected(self, widget):
        file_path = os.path.expanduser(self.location_entry.get_text())
        if os.path.isfile(file_path):
            self.selected_directory = os.path.dirname(file_path)
        else:
            logger.warning('%s is not a file', file_path)
            return
        self.interpreter.file_selected(file_path)

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        logger.debug("Downloading %s to %s", file_uri, dest_file)
        self.download_progress = DownloadProgressBox(
            {'url': file_uri, 'dest': dest_file}, cancelable=True
        )
        self.download_progress.cancel_button.hide()
        callback = callback or self.on_download_complete
        self.download_progress.connect('complete', callback, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()
        self.interpreter.abort_current_task = self.download_progress.cancel

    def on_download_complete(self, widget, data, more_data=None):
        """Action called on a completed download."""
        self.interpreter.abort_current_task = None
        self.interpreter.iter_game_files()

    # ----------------
    # "Commands" stage
    # ----------------

    def ask_for_disc(self, message, callback, requires):
        """Ask the user to do insert a CD-ROM."""
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(label=message)
        label.set_use_markup(True)
        self.widget_box.add(label)
        label.show()

        buttons_box = Gtk.Box()
        buttons_box.show()
        buttons_box.set_margin_top(40)
        buttons_box.set_margin_bottom(40)
开发者ID:RobLoach,项目名称:lutris,代码行数:67,代码来源:installgamedialog.py

示例11: InstallerDialog


#.........这里部分代码省略.........
        """Display a file/folder chooser."""
        if action == "file":
            title = "Select file"
            action = Gtk.FileChooserAction.OPEN
        elif action == "folder":
            title = "Select folder"
            action = Gtk.FileChooserAction.SELECT_FOLDER

        if self.location_entry:
            self.location_entry.destroy()
        self.location_entry = FileChooserEntry(title, action, default_path)
        self.location_entry.show_all()
        if callback_on_changed:
            self.location_entry.entry.connect("changed", callback_on_changed)
        else:
            self.install_button.set_visible(False)
            self.continue_button.connect("clicked", self.on_file_selected)
            self.continue_button.grab_focus()
            self.continue_button.show()
        self.widget_box.pack_start(self.location_entry, False, False, 0)

    def on_file_selected(self, widget):
        file_path = os.path.expanduser(self.location_entry.get_text())
        if os.path.isfile(file_path):
            self.selected_directory = os.path.dirname(file_path)
        else:
            logger.warning("%s is not a file", file_path)
            return
        self.interpreter.file_selected(file_path)

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        logger.debug("Downloading %s to %s", file_uri, dest_file)
        self.download_progress = DownloadProgressBox({"url": file_uri, "dest": dest_file}, cancelable=True)
        self.download_progress.cancel_button.hide()
        callback_function = callback or self.on_download_complete
        self.download_progress.connect("complete", callback_function, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()
        self.interpreter.abort_current_task = self.download_progress.cancel

    def on_download_complete(self, widget, data, more_data=None):
        """Action called on a completed download."""
        self.interpreter.abort_current_task = None
        self.interpreter.iter_game_files()

    # ----------------
    # "Commands" stage
    # ----------------

    def wait_for_user_action(self, message, callback, data=None):
        """Ask the user to do something."""
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(label=message)
        label.set_use_markup(True)
        self.widget_box.add(label)
        label.show()
        button = Gtk.Button(label="Ok")
        button.connect("clicked", callback, data)
        self.widget_box.add(button)
        button.grab_focus()
        button.show()

    def input_menu(self, alias, options, preselect, has_entry, callback):
开发者ID:dacp17,项目名称:lutris,代码行数:67,代码来源:installgamedialog.py

示例12: InstallerDialog


#.........这里部分代码省略.........
            label = Gtk.Label("Click install to continue")
        self.show_all()

    def on_destroy(self, widget):
        if self.parent:
            self.destroy()
        else:
            Gtk.main_quit()

    def on_target_changed(self, text_entry):
        """ Sets the installation target for the game """
        self.interpreter.target_path = text_entry.get_text()

    def on_install_clicked(self, button):
        button.set_sensitive(False)
        self.interpreter.iter_game_files()

    def ask_user_for_file(self, message=None):
        dlg = FileDialog(message)
        filename = getattr(dlg, 'filename', '')
        return filename

    def clean_widgets(self):
        for child_widget in self.widget_box.get_children():
            child_widget.destroy()

    def set_status(self, text):
        self.status_label.set_text(text)

    def add_spinner(self):
        self.clean_widgets()
        spinner = Gtk.Spinner()
        self.widget_box.pack_start(spinner, True, False, 10)
        spinner.show()
        spinner.start()

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        self.download_progress = DownloadProgressBox(
            {'url': file_uri, 'dest': dest_file}, cancelable=True
        )
        callback_function = callback or self.download_complete
        self.download_progress.connect('complete', callback_function, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()

    def wait_for_user_action(self, message, callback, data=None):
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(message)
        self.widget_box.add(label)
        label.show()
        button = Gtk.Button('Ok')
        button.connect('clicked', callback, data)
        self.widget_box.add(button)
        button.show()

    def download_complete(self, widget, data, more_data=None):
        """Action called on a completed download"""
        self.interpreter.iter_game_files()

    def on_steam_downloaded(self, widget, data, appid):
        self.interpreter.complete_steam_install(widget.dest, appid)

    def on_install_finished(self):
        """Actual game installation"""
        self.status_label.set_text("Installation finished !")

        self.clean_widgets()

        self.install_button.destroy()
        play_button = Gtk.Button("Launch game")
        play_button.show()
        play_button.connect('clicked', self.launch_game)
        self.action_buttons.pack_start(play_button, True, True, 10)

        close_button = Gtk.Button("Close")
        close_button.show()
        close_button.connect('clicked', self.close)
        self.action_buttons.pack_start(close_button, True, True, 10)
        if self.parent:
            self.parent.view.emit('game-installed', self.game_ref)

    def on_install_error(self, message):
        self.status_label.set_text(message)
        self.clean_widgets()
        close_button = Gtk.Button("Close")
        close_button.show()
        close_button.connect('clicked', self.close)
        self.action_buttons.pack_start(close_button, True, True, 10)

    def launch_game(self, widget, _data=None):
        """Launch a game after it's been installed"""
        widget.set_sensitive(False)
        game = Game(self.interpreter.game_slug)
        game.play()

    def close(self, _widget):
        self.destroy()
开发者ID:Cybolic,项目名称:lutris,代码行数:101,代码来源:installer.py

示例13: InstallerDialog


#.........这里部分代码省略.........
    def on_target_changed(self, text_entry):
        """ Sets the installation target for the game """
        path = text_entry.get_text()
        self.interpreter.target_path = path
        self.show_non_empty_warning()

    def on_install_clicked(self, button):
        button.set_sensitive(False)
        self.interpreter.iter_game_files()

    def ask_user_for_file(self, message):
        self.clean_widgets()
        self.set_message(message)
        if self.selected_directory:
            path = self.selected_directory
        else:
            path = os.path.expanduser('~')
        self.set_location_entry(None, 'file', default_path=path)

    def on_file_selected(self, widget):
        file_path = self.location_entry.get_text()
        if os.path.isfile(file_path):
            self.selected_directory = os.path.dirname(file_path)
        else:
            return
        self.interpreter.file_selected(file_path)

    def clean_widgets(self):
        for child_widget in self.widget_box.get_children():
            child_widget.destroy()

    def set_status(self, text):
        self.status_label.set_text(text)

    def add_spinner(self):
        self.clean_widgets()
        spinner = Gtk.Spinner()
        self.widget_box.pack_start(spinner, True, False, 10)
        spinner.show()
        spinner.start()

    def start_download(self, file_uri, dest_file, callback=None, data=None):
        self.clean_widgets()
        logger.debug("Downloading %s to %s", file_uri, dest_file)
        self.download_progress = DownloadProgressBox(
            {'url': file_uri, 'dest': dest_file}, cancelable=True
        )
        callback_function = callback or self.download_complete
        self.download_progress.connect('complete', callback_function, data)
        self.widget_box.pack_start(self.download_progress, False, False, 10)
        self.download_progress.show()
        self.download_progress.start()

    def wait_for_user_action(self, message, callback, data=None):
        time.sleep(0.3)
        self.clean_widgets()
        label = Gtk.Label(label=message)
        label.set_use_markup(True)
        self.widget_box.add(label)
        label.show()
        button = Gtk.Button(label='Ok')
        button.connect('clicked', callback, data)
        self.widget_box.add(button)
        button.show()

    def download_complete(self, widget, data, more_data=None):
        """Action called on a completed download"""
        self.interpreter.iter_game_files()

    def on_steam_downloaded(self, widget, *args, **kwargs):
        self.interpreter.complete_steam_install(widget.dest)

    def on_install_finished(self):
        """Actual game installation"""
        self.status_label.set_text("Installation finished !")
        self.clean_widgets()
        self.notify_install_success()
        self.continue_button.hide()
        self.install_button.hide()
        self.play_button.show()
        self.close_button.show()

    def notify_install_success(self):
        if self.parent:
            self.parent.view.emit('game-installed', self.game_ref)

    def on_install_error(self, message):
        self.status_label.set_text(message)
        self.clean_widgets()
        self.close_button.show()

    def launch_game(self, widget, _data=None):
        """Launch a game after it's been installed"""
        widget.set_sensitive(False)
        game = Game(self.interpreter.game_slug)
        game.play()
        self.close(widget)

    def close(self, _widget):
        self.destroy()
开发者ID:Kehlyos,项目名称:lutris,代码行数:101,代码来源:installer.py


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