當前位置: 首頁>>代碼示例>>Python>>正文


Python WebKit.WebView方法代碼示例

本文整理匯總了Python中gi.repository.WebKit.WebView方法的典型用法代碼示例。如果您正苦於以下問題:Python WebKit.WebView方法的具體用法?Python WebKit.WebView怎麽用?Python WebKit.WebView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gi.repository.WebKit的用法示例。


在下文中一共展示了WebKit.WebView方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self):
        Gtk.OffscreenWindow.__init__(self)
        self.view = WebKit.WebView()
        settings = self.view.get_settings()
        settings.set_property("enable-java-applet", False)
        settings.set_property("enable-plugins", False)
        settings.set_property("enable-scripts", False)
        self.view.set_size_request(-1, ExhibitBanner.MAX_HEIGHT)
        self.add(self.view)
        self.show_all()
        self.loader = SimpleFileDownloader()
        self.loader.connect("file-download-complete",
                            self.on_download_complete)
        self.loader.connect("error",
                            self.on_download_error)
        self.exhibit = None
        self.view.connect("notify::load-status", self._on_load_status) 
開發者ID:fossasia,項目名稱:x-mario-center,代碼行數:19,代碼來源:exhibits.py

示例2: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self, tracker, url, tab_id):
        self.alive = True
        self.tracker = tracker
        self.uuid = tab_id
        self.plug = Gtk.Plug()
        self.plug.connect("destroy", Gtk.main_quit)
        
        self.webview = WebKit.WebView()
        settings = self.webview.get_settings()
        settings.set_property("enable-developer-extras", True)
        #settings.set_property("enable-webgl", True)

        self.webview.connect("load-started", self.load_start_event)
        self.webview.connect("notify::title", self.push_title_change)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.add(self.webview)
        self.plug.set_default_size(800, 600)
        self.plug.add(scrolled_window)
        self.plug.show_all()

        self.send("attach_event", plug_id = str(self.plug.get_id()))
        self.navigate_event(url) 
開發者ID:Aeva,項目名稱:ridinghood,代碼行數:25,代碼來源:webkit_plug.py

示例3: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self):
        super(VideoPlayer, self).__init__()
        self.set_size_request(400, 255)
        self.webkit = WebKit.WebView()
        settings = self.webkit.get_settings()
        # this disables the flash and other plugins so that we force html5
        # video on the system. This is works currently (11/2011) fine with
        # dailymotion and vimeo but youtube is opt-in only so we need
        # to monitor the situation
        settings.set_property("enable-plugins", False)
        # on navigation/new window etc, just use the proper browser
        self.webkit.connect(
            "new-window-policy-decision-requested", self._on_new_window)
        self.webkit.connect("create-web-view", self._on_create_web_view)
        self.pack_start(self.webkit, True, True, 0)
        self._uri = ""

    # helper required to follow ToS about the "back" link (flash version) 
開發者ID:fossasia,項目名稱:x-mario-center,代碼行數:20,代碼來源:videoplayer.py

示例4: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self, lat=39.36873, lon=-2.417274645879, units='F'):
        self.images = {}
        self.echo = True
        Gtk.Window.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_title(comun.APP)
        self.set_default_size(900, 600)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox = Gtk.VBox(spacing=5)
        self.get_content_area().add(vbox)
        hbox1 = Gtk.HBox()
        vbox.pack_start(hbox1, True, True, 0)
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
        hbox1.pack_start(self.scrolledwindow1, True, True, 0)
        self.viewer = WebKit.WebView()
        self.scrolledwindow1.add(self.viewer)
        self.scrolledwindow1.set_size_request(900, 600)
        self.viewer.connect('title-changed', self.title_changed)
        self.viewer.open('file://' + comun.HTML)
        self.lat = lat
        self.lon = lon
        self.units = units
        self.set_focus(self.viewer)
        self.show_all()
        self.message_queue = queue.Queue()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.show_all()
        self.inicialize()
        self.run()
        self.destroy()

    # ###################################################################
    # #########################ENGINE####################################
    # ################################################################### 
開發者ID:atareao,項目名稱:my-weather-indicator,代碼行數:42,代碼來源:openweathermap.py

示例5: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self, window):
        """
        Provides Webkit WebView element to display ebook content
        :param window: Main application window reference, serves as communication hub
        """
        WebKit.WebView.__init__(self)

        # Allow transparency so we can use GTK theme as background
        # Can be overridden by CSS background property, needs to be rgba(0,0,0,0)
        self.set_transparent(True)

        # Sets WebView settings for ebook display
        # No java script etc.
        self.set_full_content_zoom(True)
        settings = self.get_settings()
        settings.props.enable_scripts = False
        settings.props.enable_plugins = False
        settings.props.enable_page_cache = False
        settings.props.enable_java_applet = False
        try:
            settings.props.enable_webgl = False
        except AttributeError:
            pass

        # Disable default menu: contains copy and reload options
        # Reload messes with custom styling, doesn't reload CSS
        # App is using own "copy" right click hack
        # It will allow in future to add more options on right click
        settings.props.enable_default_context_menu = False

        settings.props.enable_html5_local_storage = False

        self.connect('context-menu', self.callback)

        self.__window = window 
開發者ID:michaldaniel,項目名稱:Ebook-Viewer,代碼行數:37,代碼來源:viewer.py

示例6: load_current_chapter

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def load_current_chapter(self):
        """
        Loads current chapter as pointed by content porvider
        """
        file_url = self.__window.content_provider.get_chapter_file(self.__window.content_provider.current_chapter)
        # Using WebView.load_html_string since WebView.load_uri files for some html files
        # while load_html_string works just fine
        # It's a bug that needs to be resolved upstream

        try:
            with open(file_url) as file_open:
                self.load_html_string(file_open.read(), "file://" + file_url)
                print("Loaded: " + file_url)
        except IOError:
            print("Could not read: ", file_url) 
開發者ID:michaldaniel,項目名稱:Ebook-Viewer,代碼行數:17,代碼來源:viewer.py

示例7: on_menuitem_feedback_activate

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def on_menuitem_feedback_activate(self, widget):
        window_feedback = Gtk.Window()
        window_feedback.set_title("Feedback Form")
        window_feedback.set_default_size(640, 640)
        window_feedback.set_position(Gtk.WindowPosition.CENTER)
        feedback_browser = WebKit.WebView()
        feedback_browser.connect("console-message", self._javascript_console_message) # Suppress .js output
        feedback_scroller = Gtk.ScrolledWindow()
        feedback_scroller.add(feedback_browser)
        window_feedback.add(feedback_scroller)
        feedback_browser.open("https://jamiemcgowan.typeform.com/to/ng5Lhc")
        window_feedback.show_all() 
開發者ID:jamiemcg,項目名稱:Remarkable,代碼行數:14,代碼來源:RemarkableWindow.py

示例8: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self,url):
		self.code = None
		Gtk.Dialog.__init__(self)
		self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
		self.set_title(comun.APP)
		self.set_icon_from_file(comun.ICON)
		#
		vbox = Gtk.VBox(spacing = 5)
		self.get_content_area().add(vbox)
		hbox1 = Gtk.HBox()
		vbox.pack_start(hbox1,True,True,0)
		#
		self.scrolledwindow1 = Gtk.ScrolledWindow()
		self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
		self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
		hbox1.pack_start(self.scrolledwindow1,True,True,0)
		#
		self.viewer = WebKit.WebView()
		self.scrolledwindow1.add(self.viewer)
		self.scrolledwindow1.set_size_request(600,420)
		self.viewer.connect('navigation-policy-decision-requested', self.on_navigation_requested)
		self.viewer.open(url)
		#		
		self.show_all()

	####################################################################
	#########################BROWSER####################################
	#################################################################### 
開發者ID:atareao,項目名稱:google-tasks-indicator,代碼行數:30,代碼來源:logindialog.py

示例9: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self, post_editing_source, post_editing_reference, notebook, grid, output_directory):
        self.post_editing_source = post_editing_source
        self.post_editing_reference = post_editing_reference
        self.translation_tab_grid = grid
        self.notebook = notebook
        self.modified_references =  []
        self.saved_modified_references = []
        self.visibility_of_statistics_menu = True
        self.output_directory = output_directory

        self.tables = {}
        self.source_log = {}
        self.HTML_view = WebKit.WebView()
        uri = "statistics/generated/stats.html"
        uri = os.path.realpath(uri)
        uri = urlparse.ParseResult('file', '', uri, '', '', '')
        uri = urlparse.urlunparse(uri)
        self.HTML_view.load_uri(uri)
        filename = post_editing_reference[post_editing_reference.rfind('/'):]
        filename_without_extension = os.path.splitext(filename)[0]
        filename_extension = os.path.splitext(filename)[1]
        self.saved_origin_filepath = self.output_directory + filename


        self.tables["translation_table"] =  Table("translation_table",self.post_editing_source,self.post_editing_reference, self.preparePostEditingAnalysis_event,self.preparePostEditingAnalysis, self.calculate_statistics_event, self.translation_tab_grid, self.output_directory)

        self.source_log_filepath = self.output_directory + '/source_log.json'


        shutil.rmtree("./statistics/generated", ignore_errors=True)
        os.makedirs(os.path.abspath("statistics/generated"))

        self.translation_tab_grid.show_all()
        self.tables["translation_table"].save_post_editing_changes_button.hide()
        self.tables["translation_table"].statistics_button.hide()
        self.tables["translation_table"].insertions_statistics_button.hide()
        self.tables["translation_table"].deletions_statistics_button.hide()
        self.tables["translation_table"].time_statistics_button.hide() 
開發者ID:roxana-lafuente,項目名稱:MTTT,代碼行數:40,代碼來源:post_editing.py

示例10: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self):
        # actual webkit init
        webkit.WebView.__init__(self)
        self.connect("resource-request-starting",
                     self._on_resource_request_starting) 
開發者ID:fossasia,項目名稱:x-mario-center,代碼行數:7,代碼來源:webkit.py

示例11: __init__

# 需要導入模塊: from gi.repository import WebKit [as 別名]
# 或者: from gi.repository.WebKit import WebView [as 別名]
def __init__(self, title='', subtitle='', temperature='', humidity='',
                 cloudiness=''):
        self.images = {}
        self.echo = True
        Gtk.Window.__init__(self)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_title(comun.APP)
        self.set_default_size(900, 600)
        self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox = Gtk.VBox(spacing=5)
        self.get_content_area().add(vbox)
        hbox1 = Gtk.HBox()
        vbox.pack_start(hbox1, True, True, 0)
        #
        self.scrolledwindow1 = Gtk.ScrolledWindow()
        self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC,
                                        Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
        hbox1.pack_start(self.scrolledwindow1, True, True, 0)
        #
        self.viewer = WebKit.WebView()
        self.scrolledwindow1.add(self.viewer)
        self.scrolledwindow1.set_size_request(900, 600)
        self.viewer.connect('title-changed', self.title_changed)
        self.viewer.open('file://' + comun.HTML_GRAPH)
        #
        self.title = title
        self.subtitle = subtitle
        self.humidity = humidity
        self.cloudiness = cloudiness
        self.temperature = temperature
        self.set_focus(self.viewer)
        self.show_all()
        self.message_queue = queue.Queue()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.show_all()
        self.run()
        self.destroy()

    # ###################################################################
    # #########################ENGINE####################################
    # ################################################################### 
開發者ID:atareao,項目名稱:my-weather-indicator,代碼行數:47,代碼來源:graph.py


注:本文中的gi.repository.WebKit.WebView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。