Advertisement
elhackerlibre

navegadorweb

Sep 23rd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Autor: Felix Molero
  5. # Nick: Virus69
  6. # Proyecto: Navegador Web
  7. # Licencia GPL v2.0
  8.  
  9. import gtk
  10. import webkit
  11.  
  12. def go_but(widget):
  13.     add = addressbar.get_text()
  14.     if add.startswith("http://"):
  15.         web.open(add)
  16.     else:
  17.         add = "http://" + add
  18.         addressbar.set_text(add)
  19.         web.open(add)
  20.  
  21. def new_title(view, frame, title):
  22.     win.set_title(title)  # Cambia el titulo del borde
  23.    
  24. def on_click_link(view, frame):
  25.     uri=frame.get_uri()
  26.     addressbar.set_text(uri)
  27.  
  28. #def back_but(widget):
  29. #def next_but(widget):
  30.  
  31. win = gtk.Window()
  32. win.set_default_size(1024, 768)
  33. win.connect('destroy', lambda w: gtk.main_quit())
  34.  
  35. box1 = gtk.VBox()
  36. win.add(box1)
  37.  
  38. box2 = gtk.HBox()
  39. box1.pack_start(box2, False)
  40.  
  41. addressbar = gtk.Entry()
  42. addressbar.connect("activate", go_but)
  43. box2.pack_start(addressbar)
  44.  
  45. backbutton = gtk.Button("<")  # Boton para regresa a la página anterior
  46. box2.pack_start(backbutton, False)
  47. # backbutton.connect("clicked", back_but)
  48.  
  49. nextbutton = gtk.Button(">")  # Boton para ir a la suiguiente página
  50. box2.pack_start(nextbutton, False)
  51. # nextbutton.connect("clicked", next_but)
  52.  
  53. gobutton = gtk.Button("GO")  # Boton de buscar
  54. box2.pack_start(gobutton, False)  # Reduce el tamaño del boton "GO"
  55. gobutton.connect("clicked", go_but)
  56.  
  57. scroller = gtk.ScrolledWindow()
  58. box1.pack_start(scroller)
  59.  
  60. web = webkit.WebView()
  61. web.open("http://www.google.com")  # fijar la url del sitio de preferencia
  62. web.connect("title-changed", new_title)
  63. web.connect("load-committed", on_click_link)
  64. scroller.add(web)
  65.  
  66. win.show_all()
  67. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement