当前位置: 首页>>代码示例>>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;未经允许,请勿转载。