本文整理汇总了Python中lutris.gui.widgets.DownloadProgressBox.show方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadProgressBox.show方法的具体用法?Python DownloadProgressBox.show怎么用?Python DownloadProgressBox.show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lutris.gui.widgets.DownloadProgressBox
的用法示例。
在下文中一共展示了DownloadProgressBox.show方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
class InstallerDialog(Gtk.Window):
""" Gtk Dialog used during the install process """
game_dir = None
download_progress = None
def __init__(self, game_ref, parent=None):
Gtk.Window.__init__(self)
self.parent = parent
self.game_ref = game_ref
# Dialog properties
self.set_size_request(600, 480)
self.set_default_size(600, 480)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(False)
self.vbox = Gtk.VBox()
self.add(self.vbox)
# Default signals
self.connect('destroy', self.on_destroy)
# Interpreter
self.interpreter = ScriptInterpreter(game_ref, self)
if not self.interpreter.script:
return
# GUI Setup
# Title label
title_label = Gtk.Label()
game_name = self.interpreter.game_name
title_label.set_markup("<b>Installing {}</b>".format(game_name))
self.vbox.pack_start(title_label, False, False, 20)
self.status_label = Gtk.Label()
self.status_label.set_max_width_chars(80)
self.status_label.set_property('wrap', True)
self.status_label.set_selectable(True)
self.vbox.pack_start(self.status_label, False, False, 15)
# Main widget box
self.widget_box = Gtk.VBox()
self.widget_box.set_margin_right(25)
self.widget_box.set_margin_left(25)
self.vbox.pack_start(self.widget_box, True, True, 15)
self.location_entry = None
# Separator
self.vbox.pack_start(Gtk.HSeparator(), False, False, 0)
# Buttons
action_buttons_alignment = Gtk.Alignment.new(0.95, 0, 0.15, 0)
self.action_buttons = Gtk.HBox()
action_buttons_alignment.add(self.action_buttons)
self.vbox.pack_start(action_buttons_alignment, False, True, 20)
self.install_button = Gtk.Button(label='Install')
self.install_button.connect('clicked', self.on_install_clicked)
self.action_buttons.add(self.install_button)
self.continue_button = Gtk.Button(label='Continue')
self.continue_button.set_margin_left(20)
self.continue_button.connect('clicked', self.on_file_selected)
self.action_buttons.add(self.continue_button)
self.play_button = Gtk.Button(label="Launch game")
self.play_button.set_margin_left(20)
self.play_button.connect('clicked', self.launch_game)
self.action_buttons.add(self.play_button)
self.close_button = Gtk.Button(label="Close")
self.close_button.set_margin_left(20)
self.close_button.connect('clicked', self.close)
self.action_buttons.add(self.close_button)
# Target chooser
if not self.interpreter.requires and self.interpreter.files:
self.set_message("Select installation directory")
default_path = self.interpreter.default_target
self.set_location_entry(self.on_target_changed, 'folder',
default_path)
self.non_empty_label = Gtk.Label()
self.non_empty_label.set_markup(
"<b>Warning!</b> The selected path "
"contains files, installation might not work property."
)
self.widget_box.pack_start(self.non_empty_label, False, False, 10)
else:
self.set_message("Click install to continue")
self.show_all()
self.continue_button.hide()
self.close_button.hide()
self.play_button.hide()
self.show_non_empty_warning()
def on_destroy(self, widget):
self.interpreter.cleanup()
if self.parent:
self.destroy()
#.........这里部分代码省略.........
示例2: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
class InstallerDialog(Gtk.Window):
""" Gtk Dialog used during the install process """
game_dir = None
download_progress = None
def __init__(self, game_ref, parent=None):
Gtk.Window.__init__(self)
self.interpreter = None
self.selected_directory = None # Latest directory chosen by user
self.parent = parent
self.game_ref = game_ref
# Dialog properties
self.set_size_request(600, 480)
self.set_default_size(600, 480)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(False)
self.vbox = Gtk.VBox()
self.add(self.vbox)
# Default signals
self.connect('destroy', self.on_destroy)
# GUI Setup
# Title label
self.title_label = Gtk.Label()
self.vbox.pack_start(self.title_label, False, False, 20)
self.status_label = Gtk.Label()
self.status_label.set_max_width_chars(80)
self.status_label.set_property('wrap', True)
self.status_label.set_selectable(True)
self.vbox.pack_start(self.status_label, False, False, 15)
# Main widget box
self.widget_box = Gtk.VBox()
self.widget_box.set_margin_right(25)
self.widget_box.set_margin_left(25)
self.vbox.pack_start(self.widget_box, True, True, 15)
self.location_entry = None
# Separator
self.vbox.pack_start(Gtk.HSeparator(), False, False, 0)
# Buttons
action_buttons_alignment = Gtk.Alignment.new(0.95, 0, 0.15, 0)
self.action_buttons = Gtk.HBox()
action_buttons_alignment.add(self.action_buttons)
self.vbox.pack_start(action_buttons_alignment, False, True, 20)
self.install_button = Gtk.Button(label='Install')
self.install_button.connect('clicked', self.on_install_clicked)
self.action_buttons.add(self.install_button)
self.continue_button = Gtk.Button(label='Continue')
self.continue_button.set_margin_left(20)
self.continue_handler = None
self.action_buttons.add(self.continue_button)
self.play_button = Gtk.Button(label="Launch game")
self.play_button.set_margin_left(20)
self.play_button.connect('clicked', self.launch_game)
self.action_buttons.add(self.play_button)
self.close_button = Gtk.Button(label="Close")
self.close_button.set_margin_left(20)
self.close_button.connect('clicked', self.close)
self.action_buttons.add(self.close_button)
if os.path.isfile(game_ref):
# local script
logger.debug("Opening script: %s", game_ref)
self.scripts = yaml.safe_load(open(game_ref, 'r').read())
else:
self.scripts = installer.fetch_script(self, game_ref)
if not self.scripts:
self.destroy()
return
if not isinstance(self.scripts, list):
self.scripts = [self.scripts]
self.show_all()
self.close_button.hide()
self.play_button.hide()
self.install_button.hide()
self.choose_installer()
def launch_install(self, script_index):
script = self.scripts[script_index]
self.interpreter = installer.ScriptInterpreter(script, self)
game_name = self.interpreter.game_name.replace('&', '&')
self.title_label.set_markup("<b>Installing {}</b>".format(game_name))
self.continue_install()
def continue_install(self):
# Target chooser
if not self.interpreter.requires and self.interpreter.files:
self.set_message("Select installation directory")
#.........这里部分代码省略.........
示例3: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
#.........这里部分代码省略.........
self.present()
def add_button(self, label, handler=None):
button = Gtk.Button.new_with_mnemonic(label)
button.set_margin_left(20)
if handler:
button.connect('clicked', handler)
self.action_buttons.add(button)
return button
# ---------------------------
# "Get installer" stage
# ---------------------------
def get_scripts(self):
if system.path_exists(self.installer_file):
# local script
logger.debug("Opening script: %s", self.installer_file)
scripts = yaml.safe_load(open(self.installer_file, 'r').read())
self.on_scripts_obtained(scripts)
else:
jobs.AsyncCall(interpreter.fetch_script, self.on_scripts_obtained,
self.game_slug, self.revision)
def on_scripts_obtained(self, scripts, _error=None):
if not scripts:
self.destroy()
self.run_no_installer_dialog()
return
if not isinstance(scripts, list):
scripts = [scripts]
self.scripts = scripts
self.show_all()
self.close_button.hide()
self.play_button.hide()
self.install_button.hide()
self.eject_button.hide()
self.choose_installer()
def run_no_installer_dialog(self):
"""Open dialog for 'no script available' situation."""
dlg = NoInstallerDialog(self)
if dlg.result == dlg.MANUAL_CONF:
game_data = pga.get_game_by_field(self.game_slug, 'slug')
game = Game(game_data['id'])
AddGameDialog(
self.parent,
game=game,
callback=lambda: self.notify_install_success(game_data['id'])
)
elif dlg.result == dlg.NEW_INSTALLER:
webbrowser.open(settings.GAME_URL % self.game_slug)
# ---------------------------
# "Choose installer" stage
# ---------------------------
def choose_installer(self):
"""Stage where we choose an install script."""
self.title_label.set_markup('<b>Select which version to install</b>')
self.installer_choice_box = Gtk.VBox()
self.installer_choice = 0
radio_group = None
示例4: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
#.........这里部分代码省略.........
self.action_buttons.add(self.play_button)
self.close_button = Gtk.Button.new_with_mnemonic("_Close")
self.close_button.set_margin_left(20)
self.close_button.connect("clicked", self.close)
self.action_buttons.add(self.close_button)
self.get_scripts()
# ---------------------------
# "Get installer" stage
# ---------------------------
def get_scripts(self):
if os.path.isfile(self.game_ref):
# local script
logger.debug("Opening script: %s", self.game_ref)
scripts = yaml.safe_load(open(self.game_ref, "r").read())
self.on_scripts_obtained(scripts)
else:
jobs.AsyncCall(interpreter.fetch_script, self.on_scripts_obtained, self.game_ref)
def on_scripts_obtained(self, scripts, _error=None):
if self.parent:
display.set_cursor("default", self.parent.window.get_window())
if not scripts:
self.destroy()
self.run_no_installer_dialog()
return
if not isinstance(scripts, list):
scripts = [scripts]
self.scripts = scripts
self.show_all()
self.close_button.hide()
self.play_button.hide()
self.install_button.hide()
self.choose_installer()
def run_no_installer_dialog(self):
"""Open dialog for 'no script available' situation."""
dlg = NoInstallerDialog(self)
if dlg.result == dlg.MANUAL_CONF:
game = Game(self.game_ref)
game_dialog = AddGameDialog(self, game)
game_dialog.run()
if game_dialog.saved:
self.notify_install_success()
elif dlg.result == dlg.NEW_INSTALLER:
installer_url = settings.SITE_URL + "games/%s/" % self.game_ref
webbrowser.open(installer_url)
# ---------------------------
# "Choose installer" stage
# ---------------------------
def choose_installer(self):
"""Stage where we choose an install script."""
self.title_label.set_markup("<b>Select which version to install</b>")
self.installer_choice_box = Gtk.VBox()
self.installer_choice = 0
radio_group = None
# Build list
for index, script in enumerate(self.scripts):
示例5: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
class InstallerDialog(Gtk.Window):
""" Gtk Dialog used during the install process """
game_dir = None
download_progress = None
# # Fetch assets
# banner_url = settings.INSTALLER_URL + '%s.jpg' % self.game_slug
# banner_dest = join(settings.DATA_DIR, "banners/%s.jpg" % self.game_slug)
# http.download_asset(banner_url, banner_dest, True)
# icon_url = settings.INSTALLER_URL + 'icon/%s.jpg' % self.game_slug
# icon_dest = join(settings.DATA_DIR, "icons/%s.png" % self.game_slug)
# http.download_asset(icon_url, icon_dest, True)
def __init__(self, game_ref, parent=None):
Gtk.Window.__init__(self)
self.parent = parent
self.game_ref = game_ref
# Dialog properties
self.set_size_request(600, 480)
self.set_default_size(600, 480)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(False)
self.vbox = Gtk.VBox()
self.add(self.vbox)
# Default signals
self.connect('destroy', self.on_destroy)
# Interpreter
self.interpreter = ScriptInterpreter(game_ref, self)
## GUI Setup
# Title label
title_label = Gtk.Label()
game_name = self.interpreter.game_name
title_label.set_markup("<b>Installing {}</b>".format(game_name))
self.vbox.pack_start(title_label, False, False, 20)
self.status_label = Gtk.Label()
self.vbox.pack_start(self.status_label, False, False, 15)
# Main widget box
self.widget_box = Gtk.VBox()
self.widget_box.set_margin_right(25)
self.widget_box.set_margin_left(25)
self.vbox.pack_start(self.widget_box, True, True, 15)
# Separator
self.vbox.pack_start(Gtk.HSeparator(), False, False, 0)
# Install button
self.install_button = Gtk.Button('Install')
self.install_button.connect('clicked', self.on_install_clicked)
action_buttons_alignment = Gtk.Alignment.new(0.95, 0, 0.15, 0)
self.action_buttons = Gtk.HBox()
action_buttons_alignment.add(self.action_buttons)
self.action_buttons.add(self.install_button)
self.vbox.pack_start(action_buttons_alignment, False, False, 25)
# Target chooser
if not self.interpreter.requires and self.interpreter.files:
# Top label
label = Gtk.Label()
label.set_markup('<b>Select installation directory:</b>')
label.set_alignment(0, 0)
self.widget_box.pack_start(label, False, False, 10)
default_path = self.interpreter.default_target
location_entry = FileChooserEntry(default=default_path)
location_entry.entry.connect('changed', self.on_target_changed)
self.widget_box.pack_start(location_entry, False, False, 0)
else:
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()
#.........这里部分代码省略.........
示例6: InstallerDialog
# 需要导入模块: from lutris.gui.widgets import DownloadProgressBox [as 别名]
# 或者: from lutris.gui.widgets.DownloadProgressBox import show [as 别名]
class InstallerDialog(Gtk.Window):
""" Gtk Dialog used during the install process """
game_dir = None
download_progress = None
def __init__(self, game_ref, parent=None):
Gtk.Window.__init__(self)
self.interpreter = None
self.selected_directory = None # Latest directory chosen by user
self.parent = parent
self.game_ref = game_ref
# Dialog properties
self.set_size_request(600, 480)
self.set_default_size(600, 480)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(False)
self.vbox = Gtk.VBox()
self.add(self.vbox)
# Default signals
self.connect('destroy', self.on_destroy)
# GUI Setup
# Title label
self.title_label = Gtk.Label()
self.vbox.pack_start(self.title_label, False, False, 20)
self.status_label = Gtk.Label()
self.status_label.set_max_width_chars(80)
self.status_label.set_property('wrap', True)
self.status_label.set_selectable(True)
self.vbox.pack_start(self.status_label, False, False, 15)
# Main widget box
self.widget_box = Gtk.VBox()
self.widget_box.set_margin_right(25)
self.widget_box.set_margin_left(25)
self.vbox.pack_start(self.widget_box, True, True, 15)
self.location_entry = None
# Separator
self.vbox.pack_start(Gtk.HSeparator(), False, False, 0)
# Buttons
action_buttons_alignment = Gtk.Alignment.new(0.95, 0, 0.15, 0)
self.action_buttons = Gtk.HBox()
action_buttons_alignment.add(self.action_buttons)
self.vbox.pack_start(action_buttons_alignment, False, True, 20)
self.install_button = Gtk.Button(label='Install')
self.install_button.connect('clicked', self.on_install_clicked)
self.action_buttons.add(self.install_button)
self.continue_button = Gtk.Button(label='Continue')
self.continue_button.set_margin_left(20)
self.continue_handler = None
self.action_buttons.add(self.continue_button)
self.play_button = Gtk.Button(label="Launch game")
self.play_button.set_margin_left(20)
self.play_button.connect('clicked', self.launch_game)
self.action_buttons.add(self.play_button)
self.close_button = Gtk.Button(label="Close")
self.close_button.set_margin_left(20)
self.close_button.connect('clicked', self.close)
self.action_buttons.add(self.close_button)
if os.path.exists(game_ref):
# local script
logger.debug("Opening script: %s", game_ref)
self.scripts = yaml.safe_load(open(game_ref, 'r').read())
else:
self.scripts = fetch_script(self, game_ref)
if not self.scripts:
return
self.show_all()
self.close_button.hide()
self.play_button.hide()
self.install_button.hide()
self.choose_installer()
def launch_install(self, script_index):
script = self.scripts[script_index]
self.interpreter = ScriptInterpreter(script, self)
game_name = self.interpreter.game_name.replace('&', '&')
self.title_label.set_markup("<b>Installing {}</b>".format(game_name))
# CDrom check
if self.interpreter.requires_disc:
self.insert_disc()
else:
self.continue_install()
def insert_disc(self):
#.........这里部分代码省略.........