Webbrowser returns 'True' when the script opens and closes. I have a script with many buttons, here I have reduced the error to one button. I have tried the 'simple webbrowser' as well with same result. I have searched the web for similar errors, but did not find anyone else with the same problem. Can you help? I have used both Kivy 2.2.1 and 2.2.0. Python 3.8.10 and Pydroid3. Here is the script:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
import webbrowser
#import simple_webbrowser as swb
#from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
kv_text = '''
<MyScreenManager>:
HomeScreen:
<HomeScreen>:
BoxLayout:
orientation: "vertical"
padding: ['11dp','8dp']
spacing: '10dp'
BoxLayout:
size_hint: 1,.1
orientation: "horizontal"
Button:
id:results_where
text:'Where \\nto stay'
background_color:[1,0,0,1]
on_press:app.root.btn()
'''
class MyScreenManager(ScreenManager):
pass
class MyButtons(BoxLayout):
#def __init__(self,**kwargs):
#super().__init__(**kwargs)
def mybutton_where(self):
wb=webbrowser.open('https://www.montagu.org.za/accommodation/')
return wb
class HomeScreen(Screen):
#def __init__(self,**kwargs):
#super(HomeScreen,self).__init__(**kwargs)
def btn(self):
alt=MyButtons.mybutton_where(self)
self.ids['results_where'].text= str(alt)
class MyApp(App):
def build(self):
return HomeScreen()
def main():
Builder.load_string(kv_text)
app = MyApp()
app.run()
if __name__ == '__main__':
main()
That is expected. webbrowser.open()
returns True
if it could open the page.
(I created an upstream PR to document this better: https://github.com/python/cpython/pull/123495)