pythonurlbrowserpywebview

I got an error when I try to load url what contains a domain with language code at the beginig in pywebview


I am working at a mini web browser in python and I tried to make a refresh button but it don't load the domains what start with www or language code.

Is this normal ?

Can anyone help me with that ?

Code:

import webview as wb
import webview.menu as mm



mp = {
    'back': '<--',
    'ref': 'Refresh',
    'fr': '-->'
    }
file = open('_app_data_\path.txt', 'r')
path_c = file.read()
file.close()

def ww():
    return wb.windows[0]
def load_ed():
    window = ww()
    if window.get_current_url() != None:
        window.set_title('Test Browser - ' + window.get_current_url())
    else:
        window.set_title('still loading')

def exec():
    window = ww()
    window.events.loaded += load_ed

def ok():
    print('ok')

def refr():
    window = ww()
    url = window.get_current_url()
    if 'www' in url:
        url = url.replace('www.', '')
    print(url)
    window.load_url(url)

    

men_itm = [
    mm.MenuAction(mp['back'], ok),
    mm.MenuAction(mp['fr'], ok),
    mm.MenuAction(mp['ref'], refr)
    ]


window = wb.create_window('Test Browser is opening...', url='https://google.com/', resizable=True, min_size=(200, 100), draggable=True, text_select=True)
wb.start(menu = men_itm, private_mode=False, storage_path=path_c, func = exec)

Solution

  • I solved. I load a html file and I loaded again the url.