Author Topic: Lets create a PCLinuxOS webkit browser (python)  (Read 28240 times)

ongoto

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #150 on: April 04, 2011, 01:43:23 PM »
When attempting to run the latest build, I'm getting this error:
Quote
line 296, in __init__
    addBackButton.connect("clicked", self.go_back_cb)
AttributeError: 'WebToolbar' object has no attribute 'go_back_cb'

Lines 294 to 298 add the back button.
Code: [Select]
       if toolbar_enabled:
            addBackButton = gtk.ToolButton(gtk.STOCK_ADD)
            addBackButton.connect("clicked", self.go_back_cb)
            self.insert(addBackButton, -1)
            addBackButton.show()

Lines 337 and 338 define its attribute.
Code: [Select]
   def _add_go_back_cb(self, button):
        self.emit("go-back-requested",button.go_back_cb())

 ??? Ideas, anyone?

same here... Did anyone to run it???

These names have to match each other

        addBackButton.connect("clicked", self.go_back_cb)
         def _add_go_back_cb(self, button):

Then drop the ,button.go_back_cb() from this; it doesn't belong there.
        self.emit("go-back-requested",button.go_back_cb())

You'll have to edit the other buttons likewise.

ongoto

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #151 on: April 04, 2011, 04:09:47 PM »
A current build --
http://nbrks.com/hammer/hammertest.py.tar.xz

Look it over.

Edit: This is not running at present. Help find why not, please.
Edit2: Remember please that this is still to be considered early alpha and has bugs to be worked out.
« Last Edit: April 04, 2011, 04:14:15 PM by Neal »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #152 on: April 04, 2011, 04:20:13 PM »
Error from this latest build:
Quote
line 24, in <module>
    import gtk
  File "/usr/lib/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
    from gtk import _gtk
ImportError: /usr/lib/python2.6/site-packages/gtk-2.0/gtk/_gtk.so: undefined symbol: gtk_combo_box_set_entry_text_column

Ideas? Solutions?

Offline Sproggy

  • Hero Member
  • *****
  • Posts: 1484
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #153 on: April 04, 2011, 04:22:52 PM »
A current build --
http://nbrks.com/hammer/hammertest.py.tar.xz

Look it over.

Edit: This is not running at present. Help find why not, please.
Edit2: Remember please that this is still to be considered early alpha and has bugs to be worked out.



Heya Neal i am getting the following

Traceback (most recent call last):
  File "./hammertest.py", line 26, in <module>
    from pango import tabs
ImportError: cannot import name tabs

any ideas??? as i have pango installed


Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #154 on: April 04, 2011, 04:29:26 PM »
Check that you have --
/usr/include/pango-1.0/pango/pango-tabs.h and pango-types.h

Offline Sproggy

  • Hero Member
  • *****
  • Posts: 1484
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #155 on: April 04, 2011, 04:35:47 PM »
Check that you have --
/usr/include/pango-1.0/pango/pango-tabs.h and pango-types.h


yep all there .... hmmmmmmmmm

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #156 on: April 04, 2011, 06:34:20 PM »
Got shut down by a storm. ::) Tornadoes and thunderstorms are passing through the area today. That's common this time of year.

Pango defs has an update in PASS. After updating, I get the same error. :( I'll need to do some searching to get to the possible reason for this.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #157 on: April 04, 2011, 06:57:28 PM »
A thought struck me. (ouch!) Has pywebkitgtk been updated against the new gcc? Other webkit packages?

Kori, can you look into that?

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #158 on: April 04, 2011, 09:29:39 PM »
OK, I give up - how the heck do you open a tar.xz file?!?

ongoto - I have been trying different matching combinations between "add back button" and the "def _go_back_cb".  I have also tried adding a matching "toolbar.connect" further down.  The tab button has all of these matching but I can't replicate it with the back button.  I keep getting error "global name 'go_back_requested_cb' is not defined."  Here is the snippet of code.  I think its lines 286-389 inclusive or thereabouts.   
Code: [Select]
def __init__(self, location_enabled=True, toolbar_enabled=True):
        gtk.Toolbar.__init__(self)
       
        # add back button
        if toolbar_enabled:
            addBackButton = gtk.ToolButton(gtk.STOCK_GO_BACK)
            addBackButton.connect("clicked", self._go_back_cb)
            self.insert(addBackButton, -1)
            addBackButton.show()
       
        # add forward button
        if toolbar_enabled:
            addForwardButton = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
            addForwardButton.connect("clicked", self._go_forward_cb)
            self.insert(addForwardButton, -1)
            addForwardButton.show()
     
        # add refresh button
        if toolbar_enabled:
            addRefreshButton = gtk.ToolButton(gtk.STOCK_REFRESH)
            addRefreshButton.connect("clicked", self._refresh_cb)
            self.insert(addRefreshButton, -1)
            addRefreshButton.show()
       
        # add home button
        if toolbar_enabled:
            addHomeButton = gtk.ToolButton(gtk.STOCK_HOME)
            addHomeButton.connect("clicked", self._go_home_cb)
            self.insert(addHomeButton, -1)
            addHomeButton.show()
       
        # location entry
        if location_enabled:
            self._entry = gtk.Entry()
            self._entry.connect('activate', self._entry_activate_cb)
            entry_item = gtk.ToolItem()
            entry_item.set_expand(True)
            entry_item.add(self._entry)
            self._entry.show()
            self.insert(entry_item, -1)
            entry_item.show()

        # add tab button
        if toolbar_enabled:
            addTabButton = gtk.ToolButton(gtk.STOCK_ADD)
            addTabButton.connect("clicked", self._add_tab_cb)
            self.insert(addTabButton, -1)
            addTabButton.show()

            viewSourceItem = gtk.ToggleToolButton(gtk.STOCK_PROPERTIES)
            viewSourceItem.set_label("View Source Mode")
            viewSourceItem.connect('toggled', self._view_source_mode_cb)
            self.insert(viewSourceItem, -1)
            viewSourceItem.show()

    def _go_back_cb(self, button):
        self.emit("go-back-requested")
   
    def _go_forward_cb(self, button):
        self.web_view.go_forward()
   
    def _refresh_cb(self, button):
        self.web_view.refresh()
   
    def _go_home_cb(self, button):
        self.emit()

    def location_set_text (self, text):
        self._entry.set_text(text)

    def _entry_activate_cb(self, entry):
        self.emit("load-requested", entry.props.text)

    def _add_tab_cb(self, button):
        self.emit("new-tab-requested")

    def _view_source_mode_cb(self, button):
        self.emit("view-source-mode-requested", button.get_active())

class WebBrowser(gtk.Window):

    def __init__(self):
        gtk.Window.__init__(self)

        toolbar = WebToolbar()
        content_tabs = ContentPane()
        content_tabs.connect("focus-view-title-changed", self._title_changed_cb, toolbar)
        content_tabs.connect("new-window-requested", self._new_window_requested_cb)
        toolbar.connect("go-back-requested", go_back_requested_cb, content_tabs)
        toolbar.connect("load-requested", load_requested_cb, content_tabs)
        toolbar.connect("new-tab-requested", new_tab_requested_cb, content_tabs)
        toolbar.connect("view-source-mode-requested", view_source_mode_requested_cb, content_tabs)

        vbox = gtk.VBox(spacing=1)
        vbox.pack_start(toolbar, expand=False, fill=False)
        vbox.pack_start(content_tabs)

        self.add(vbox)
        self.set_default_size(800, 600)
        self.connect('destroy', destroy_cb, content_tabs)

        self.show_all()

        content_tabs.new_tab("http://www.google.com")

If you comment out the offending code relating to the back button, the script launches and the tab button works.  The script works for me when launched through Geany and Eric.  I haven't tried it as standalone yet.  I am pretty sure the three areas of code are linked because I think that each tab is treated as a separate browser and needs the toolbar to be treated as such.  Of course, I could be a long way up a very wrong tree too!!  Oh, and I commented out the lines to do with inspector.py.

I've just noticed at about line 418 there is a section called "event handlers".  It includes a "def new_tab_requested_cb" - maybe the back button needs to be further defined here.       


Linux Registered User # 529407


Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3791
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #159 on: April 04, 2011, 10:10:01 PM »
OK, I give up - how the heck do you open a tar.xz file?!?

tar -xJ

;) I know this one.

Galen

Offline Sproggy

  • Hero Member
  • *****
  • Posts: 1484
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #160 on: April 04, 2011, 11:35:02 PM »
nope same result Neal .... hmmmmmm now i am puzzled lol

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3731
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #161 on: April 04, 2011, 11:37:27 PM »
OK, I give up - how the heck do you open a tar.xz file?!?

tar -xJ

;) I know this one.

Galen


File-roller makes a good job ...

Offline Taco.22

  • Sr. Member
  • ****
  • Posts: 481
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #162 on: April 04, 2011, 11:55:34 PM »
Check that you have --
/usr/include/pango-1.0/pango/pango-tabs.h and pango-types.h

Got the hammertest.py opened: tar -xvwf did it in the end.  I'm getting the same pango tab error.  I don't have pango in usr/include, although Synaptic tells me it is installed, as well as libpango 1.0.

Linux Registered User # 529407


ongoto

  • Guest
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #163 on: April 05, 2011, 12:16:56 AM »
OK, I give up - how the heck do you open a tar.xz file?!?

ongoto - I have been trying different matching combinations between "add back button" and the "def _go_back_cb".  I have also tried adding a matching "toolbar.connect" further down.  The tab button has all of these matching but I can't replicate it with the back button.  I keep getting error "global name 'go_back_requested_cb' is not defined."  Here is the snippet of code.  I think its lines 286-389 inclusive or thereabouts.  

If you trace new_tab_requested you'll see what you have to do for the rest of your buttons.  It starts out like this.

Code: [Select]
class WebToolbar(gtk.Toolbar):

    __gsignals__ = {
        "load-requested": (gobject.SIGNAL_RUN_FIRST,
                           gobject.TYPE_NONE,
                           (gobject.TYPE_STRING,)),
        "new-tab-requested": (gobject.SIGNAL_RUN_FIRST,
                              gobject.TYPE_NONE, ()),
                             
You need to add your signal name in here
Code: [Select]
       "go-back-requested": (gobject.SIGNAL_RUN_FIRST,
                              gobject.TYPE_NONE, ()),
                             
Then, further down, add your signal sender
Code: [Select]
   def _add_tab_cb(self, button):
        self.emit("new-tab-requested")
    def go_back_requested_cb(self, button):
        self.emit("go-back-requested")
       
Then, outside of WebToolBar, add your signal handler
Code: [Select]
# event handlers
def new_tab_requested_cb (toolbar, content_pane):
    content_pane.new_tab("about:blank")

def go_back_requested_cb (toolbar):
    toolbar._go_back_cb()

Done finally, right back where you started. LOL    
I don't have a working script for this, so try it and let me know.  I quit working on this script because it was causing one of my eyes to wander.

ongoto
« Last Edit: April 05, 2011, 12:55:40 AM by ongoto »

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Lets create a PCLinuxOS webkit browser (python)
« Reply #164 on: April 05, 2011, 02:38:45 AM »
Made some modifications:
http://nbrks.com/hammer/hammertest2.py.tar.xz

Now a different error:
Code: [Select]
line 367, in __init__
    toolbar.connect("load-requested", load_requested_cb, content_tabs)
TypeError: <gtk.Toolbar object at 0x91797d4 (GtkToolbar at 0x9212800)>: unknown signal name: load-requested