Rapidamente app não inicia

0

Estou criando um navegador da web chamado "Surf's Up!", e eu programo o código e a interface, mas quando tento executar o aplicativo, aparece uma mensagem de erro:

Traceback (most recent call last):
File "bin/surfs-up", line 32, in <module>
import surfs_up
File "/home/owner/surfs-up/surfs_up/__init__.py", line 14, in <module>
from surfs_up import SurfsUpWindow
File "/home/owner/surfs-up/surfs_up/SurfsUpWindow.py", line 10, in <module>
from gi.repository import Gtk, WebKit # pylint: disable=E0611
File "/usr/lib/python2.7/dist-packages/gi/importer.py", line 76, in load_module
dynamic_module._load()
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 222, in _load
version)
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 90, in __init__
repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gtk' version '2.0', but '3.0' is already loaded

O código é o seguinte:

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# This file is in the public domain
### END LICENSE

import gettext
from gettext import gettext as _
gettext.textdomain('surfs-up')

from gi.repository import Gtk, WebKit # pylint: disable=E0611
import logging
logger = logging.getLogger('surfs_up')

from surfs_up_lib import Window
from surfs_up.AboutSurfsUpDialog import AboutSurfsUpDialog
from surfs_up.PreferencesSurfsUpDialog import PreferencesSurfsUpDialog

# See surfs_up_lib.Window.py for more details about how this class works
class SurfsUpWindow(Window):
    __gtype_name__ = "SurfsUpWindow"

    def finish_initializing(self, builder): # pylint: disable=E1002
        """Set up the main window"""
        super(SurfsUpWindow, self).finish_initializing(builder)

        self.AboutDialog = AboutSurfsUpDialog
        self.PreferencesDialog = PreferencesSurfsUpDialog

        # Code for other initialization actions should be added here.

        self.refresh = self.builder.get_object("refresh")
        self.urltext = self.builder.get_object("urltext")
        self.scroll = self.builder.get_object("scroll")
        self.toolbar = self.builder.get_object("toolbar")

        context = self.toolbar.get_style_context()
        context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)

        self.webview = WebKit.WebView()

        self.scroll.add(self.webview)
        self.webview.show()

    def on_refresh_clicked(self, widget):
        print "Refreshing page.................................."
        self.webview.reload()
    def on_urltext_activate(self, widget):
        url = widget.get_text()
        print url
        self.webview.open(url)

O que preciso corrigir para resolver a situação?

    
por Jonathan 07.07.2012 / 19:31

1 resposta

0
gi.RepositoryError: Requiring namespace 'Gtk' version '2.0', but '3.0' is already loaded

Com base nisso, eu tentaria mudar a versão gtk para a que se encaixa.

Tente:

....
from gi.repository import Gtk, WebKit # pylint: disable=E0611    
Gtk.switch
....
    
por Krustenbrot 07.07.2012 / 20:15