2

I am building a simple Kivy app with 2 screens. The first screen has a simple button which, when clicked, goes to the second screen and should open a particular website (e.g. google.com) in embedded browser. I am aware that Kivy does not natively support an embedded browser so I used cefpython. By the way, I am using Python 3 and Kivy 1.11.1 for the app.

https://github.com/cztomczak/cefpython

The simple hello-world example uses cefpython3 and seems to run fine.

https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md#hello-world

The problem is that this code opens a new app window over the Kivy app and pauses its execution until the browser window is closed. What I would like to achieve is open the url within the Kivy app screen.

So, I came across this example of embedding cefpython within Kivy:

https://github.com/cztomczak/cefpython/blob/master/src/linux/binaries_64bit/kivy_.py

But it seems this example requires pygtk2 which is not supported by Python 3. Hence, I could not get it to work. Besides, the code looks a bit of an overkill for a simple activity like trying to open a URL.

Can someone please guide me with a working example of how to embed cefpython or any other embedded browser inside Kivy?

Shoumik Das
  • 441
  • 5
  • 16

1 Answers1

0

I'm able to get basic and buggy functionnality by using Ubuntu 20.04, Python 3.7 from deadsnake I installed Kivy 2 and pip install Cefpython3==66.0 Then I git clone this repository https://github.com/allestuetsmerweh/garden.cefpython

and then I followed the advice to create a symlink:

ln -s path/to/this/garden.cefpython ~/.kivy/garden/garden.cefpython

You will have to go in the source file cefbrowser.py from garden.cefpython and change a few things mainly named parameters that are set to none but nonevalue not checked or named parameters that are passed to the function but the function doesn't declare it.

After all that some example seem to work a little but with a lot of issues with Content Security Policy. I'm still working on the controls.py example to try to change the url...

Rolandf
  • 1,647
  • 1
  • 11
  • 10
  • Thanks. I think Kivy 2.0+ introduces asynchronous requests and that might be an approach worth exploring. – Shoumik Das Dec 28 '21 at 14:23
  • 1
    Hi, I ended up using async kivy + async Playwright. I can still have full browser control but the downside is that I have two windows, on for my app, one for the browser but what is nice is now no crash, no error message, no patching. – Rolandf Dec 29 '21 at 17:01