I want to display a WebBrowser inside my tkinter app. Per the example below:
##############
# label #
#————————————#
# webbrowser #
##############
Here is what I have tried: https://github.com/iCarlosCode/Problematika/blob/88a0f13cbdc4ee48ac9690b3ae26cf231ce3c340/calculator/cef3.py
I tried to copy the cefpython example and use the BrowserFrame, but it does not work. The cefpython tkinter example: https://github.com/cztomczak/cefpython/blob/master/examples/tkinter_.py
Anyone can help me?
So, there are 2 core issues with your main code:
cefpythonbrowser_framewas not configured to fit the whole areaIn short, the answer is:
So to fix issue № 1, within the tkinter main loop you have to type
cef.Initialize()and then putcef.Shutdown()afterwards to close it. The problem is we still can't see the frame because you didn't do thegrid_columnconfigurenorgrid_rowconfigureso even though you didsticky='nsew'it didn't do anything as there was no weight added to the row and column, to rectify this I used pack instead.On windows this created for me:
Annoyingly this doesn't work very well on on
cefpythonbecause the MathJax isn't loaded, to rectify this you need to change yourcalculo.htmlto read:Because the inline type
text/x-mathjax-configis not supported bycefpython.This creates:
Just as a quick pointer this does take a few seconds before the mathjax loads in, so it may be an idea to host a local MathJax config because this will allow for faster loading times most likely.
In relation to having a label above this, it would be rather simple to code this in by simply move the variable frame to
grid(row=1, column=0...(and changing the row weights) and then adding a label ingrid(row=0, column=0....