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


Python Game.remove方法代码示例

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


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

示例1: on_apply_button_clicked

# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import remove [as 别名]
    def on_apply_button_clicked(self, widget):
        widget.set_sensitive(False)

        remove_from_library_button = self.builder.get_object(
            'remove_from_library_button'
        )
        remove_from_library = remove_from_library_button.get_active()
        remove_contents_button = self.builder.get_object(
            'remove_contents_button'
        )
        remove_contents = remove_contents_button.get_active()
        game = Game(self.game_slug)
        game.remove(remove_from_library, remove_contents)
        self.callback(self.game_slug, remove_from_library)

        self.on_close()
开发者ID:Cybolic,项目名称:lutris,代码行数:18,代码来源:uninstallgamedialog.py

示例2: test_can_add_game

# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import remove [as 别名]
    def test_can_add_game(self):
        name_entry = self.dlg.name_entry
        name_entry.set_text("Test game")
        self.dlg.runner_dropdown.set_active(1)

        game_box = self.get_game_box()
        exe_box = game_box.get_children()[0].get_children()[0]
        exe_label = exe_box.get_children()[0]
        self.assertEqual(exe_label.get_text(), "Executable")
        test_exe = os.path.abspath(__file__)
        exe_field = exe_box.get_children()[1]
        exe_field.set_file(Gio.File.new_for_path(test_exe))
        exe_field.emit('file-set')
        self.assertEqual(exe_field.get_filename(), test_exe)

        add_button = self.get_buttons().get_children()[1]
        add_button.clicked()

        game = Game('test-game')
        self.assertEqual(game.name, 'Test game')
        game.remove(from_library=True)
开发者ID:jimmyleith,项目名称:lutris,代码行数:23,代码来源:test_dialogs.py

示例3: test_can_add_game

# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import remove [as 别名]
    def test_can_add_game(self):
        name_entry = self.dlg.name_entry
        name_entry.set_text("Test game")
        self.dlg.runner_dropdown.set_active_id('linux')

        game_box = self.get_game_box()
        exe_box = game_box.get_children()[0].get_children()[0]
        exe_label = exe_box.get_children()[0]
        self.assertEqual(exe_label.get_text(), "Executable")
        test_exe = os.path.abspath(__file__)
        exe_field = exe_box.get_children()[1]
        exe_field.entry.set_text(test_exe)
        self.assertEqual(exe_field.get_text(), test_exe)

        add_button = self.get_buttons().get_children()[1]
        add_button.clicked()

        pga_game = pga.get_game_by_field('test-game', 'slug')
        self.assertTrue(pga_game)
        game = Game(pga_game['id'])
        self.assertEqual(game.name, 'Test game')
        game.remove(from_library=True)
开发者ID:,项目名称:,代码行数:24,代码来源:

示例4: UninstallGameDialog

# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import remove [as 别名]
class UninstallGameDialog(GtkBuilderDialog):
    glade_file = 'dialog-uninstall-game.ui'
    dialog_object = 'uninstall-game-dialog'

    def substitute_label(self, widget, name, replacement):
        if hasattr(widget, 'get_text'):
            get_text = widget.get_text
            set_text = widget.set_text
        elif hasattr(widget, 'get_label'):
            get_text = widget.get_label
            set_text = widget.set_label
        else:
            raise TypeError("Unsupported type %s" % type(widget))

        replacement = replacement.replace('&', '&')
        set_text(get_text().replace("{%s}" % name, replacement))

    def initialize(self, slug=None, callback=None):
        self.game = Game(slug)
        self.callback = callback
        runner = self.game.runner

        self.substitute_label(self.builder.get_object('description_label'),
                              'game', self.game.name)

        self.substitute_label(
            self.builder.get_object('remove_from_library_button'),
            'game', self.game.name
        )
        remove_contents_button = self.builder.get_object(
            'remove_contents_button'
        )
        if self.game.is_installed:
            if hasattr(runner, 'own_game_remove_method'):
                remove_contents_button.set_label(runner.own_game_remove_method)
            else:
                try:
                    default_path = runner.default_path
                except AttributeError:
                    default_path = "/"
                if not is_removeable(runner.game_path, excludes=[default_path]):
                    remove_contents_button.set_sensitive(False)

            path = self.game.directory or 'disk'
            self.substitute_label(remove_contents_button, 'path', path)
            remove_contents_button.get_children()[0].set_use_markup(True)
        else:
            remove_contents_button.hide()

        cancel_button = self.builder.get_object('cancel_button')
        cancel_button.connect('clicked', self.on_close)

        apply_button = self.builder.get_object('apply_button')
        apply_button.connect('clicked', self.on_apply_button_clicked)

    def on_apply_button_clicked(self, widget):
        widget.set_sensitive(False)

        remove_from_library_button = self.builder.get_object(
            'remove_from_library_button'
        )
        remove_from_library = remove_from_library_button.get_active()
        remove_contents_button = self.builder.get_object(
            'remove_contents_button'
        )
        remove_contents = remove_contents_button.get_active()
        if remove_contents and not hasattr(self.game.runner,
                                           'no_game_remove_warning'):
            game_dir = self.game.directory.replace('&', '&')
            dlg = QuestionDialog({
                'question': "Are you sure you want to delete EVERYTHING under "
                            "\n<b>%s</b>?\n (This can't be undone)"
                            % game_dir,
                'title': "CONFIRM DANGEROUS OPERATION"
            })
            if dlg.result != Gtk.ResponseType.YES:
                widget.set_sensitive(True)
                return

        self.game.remove(remove_from_library, remove_contents)
        self.callback(self.game.slug, remove_from_library)

        self.on_close()
开发者ID:malkavi,项目名称:lutris,代码行数:85,代码来源:uninstallgamedialog.py

示例5: UninstallGameDialog

# 需要导入模块: from lutris.game import Game [as 别名]
# 或者: from lutris.game.Game import remove [as 别名]
class UninstallGameDialog(GtkBuilderDialog):
    glade_file = "dialog-uninstall-game.ui"
    dialog_object = "uninstall-game-dialog"

    @staticmethod
    def substitute_label(widget, name, replacement):
        if hasattr(widget, "get_text"):
            get_text = widget.get_text
            set_text = widget.set_text
        elif hasattr(widget, "get_label"):
            get_text = widget.get_label
            set_text = widget.set_label
        else:
            raise TypeError("Unsupported type %s" % type(widget))

        set_text(get_text().replace("{%s}" % name, replacement))

    def initialize(self, game_id=None, callback=None):
        self.game = Game(game_id)
        self.callback = callback
        runner = self.game.runner

        self.substitute_label(
            self.builder.get_object("description_label"), "game", self.game.name
        )

        self.substitute_label(
            self.builder.get_object("remove_from_library_button"),
            "game",
            self.game.name,
        )
        remove_contents_button = self.builder.get_object("remove_contents_button")
        if self.game.is_installed:
            path = self.game.directory or ""
            if hasattr(runner, "own_game_remove_method"):
                remove_contents_button.set_label(runner.own_game_remove_method)
                remove_contents_button.set_active(True)
            else:
                try:
                    default_path = runner.default_path
                except AttributeError:
                    default_path = "/"
                if is_removeable(path, excludes=[default_path]):
                    remove_contents_button.set_active(True)
                else:
                    remove_contents_button.set_sensitive(False)
                    path = "No game folder"

            path = reverse_expanduser(path)
            self.substitute_label(remove_contents_button, "path", path)
            label = remove_contents_button.get_child()
            label.set_use_markup(True)
            label.set_line_wrap(True)
            label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
        else:
            remove_contents_button.hide()

        cancel_button = self.builder.get_object("cancel_button")
        cancel_button.connect("clicked", self.on_close)

        apply_button = self.builder.get_object("apply_button")
        apply_button.connect("clicked", self.on_apply_button_clicked)

    def on_apply_button_clicked(self, widget):
        widget.set_sensitive(False)

        remove_from_library_button = self.builder.get_object(
            "remove_from_library_button"
        )
        remove_from_library = remove_from_library_button.get_active()
        remove_contents_button = self.builder.get_object("remove_contents_button")
        remove_contents = remove_contents_button.get_active()
        if remove_contents and not hasattr(self.game.runner, "no_game_remove_warning"):
            game_dir = self.game.directory.replace("&", "&amp;")
            dlg = QuestionDialog(
                {
                    "question": "Are you sure you want to delete EVERYTHING under "
                    "\n<b>%s</b>?\n (This can't be undone)" % game_dir,
                    "title": "CONFIRM DANGEROUS OPERATION",
                }
            )
            if dlg.result != Gtk.ResponseType.YES:
                widget.set_sensitive(True)
                return

        remove_from_library = self.game.remove(remove_from_library, remove_contents)
        self.callback(self.game.id, remove_from_library)

        self.on_close()
开发者ID:,项目名称:,代码行数:91,代码来源:


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