Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open webbrowser regsiter() error #2047

Closed
cgn5566 opened this issue Dec 27, 2019 · 2 comments
Closed

open webbrowser regsiter() error #2047

cgn5566 opened this issue Dec 27, 2019 · 2 comments
Labels

Comments

@cgn5566
Copy link

cgn5566 commented Dec 27, 2019

Versions

  • Python:3.7.1
  • OS:ubuntu 18.0.4 64
  • Kivy:master
  • Cython: 0.28.2

Description

it's my code:
url = 'http://****' #it's a valid url
def launch_webbrowser(self, url):
import webbrowser
if platform == 'android':
from jnius import autoclass, cast
def open_url(url):
PythonActivity = autoclass('org.kivy.android.PythonActivity')
activity = PythonActivity.mActivity
Intent = autoclass('android.content.Intent')
Uri = autoclass('android.net.Uri')
browserIntent = Intent()
browserIntent.setAction(Intent.ACTION_VIEW)
browserIntent.setData(Uri.parse(url))
currentActivity = cast('android.app.Activity', activity)
currentActivity.startActivity(browserIntent)

        # Web browser support.
        class AndroidBrowser(object):
            def open(self, url, new=0, autoraise=True):
                open_url(url)

            def open_new(self, url):
                open_url(url)
            def open_new_tab(self, url):
                open_url(url)

        webbrowser.register('android', AndroidBrowser, None, -1)
    webbrowser.open(url)

when i call launch_webbrowser() in kv
on_press:
root.launch_webbrowser(root.url)

i get this error in log:
webbrowser.register('android', AndroidBrowser, None, -1)
TypeError: register() takes from 2 to 3 positional arguments but 4 were given

maybe i think it's a bug of python3.7
please help ths!

buildozer.spec

Command:

// REPLACE ME: buildozer command ran? e.g. buildozer android debug

Spec file:

// REPLACE ME: Paste your buildozer.spec file here

Logs

@ghost
Copy link

ghost commented Jan 5, 2020

webbrowser.register has changed in Python 3.7: a keyword-only paramater was added (preferred, whose default value is False). It appears in Python documentation.

In summary, to date, register() takes a total of 4 arguments:

  • name
  • constructor
  • instance=None (optional)
  • preferred=False (optional, keyword-only argument)

Copy link

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.

If you're having trouble installing or using python-for-android, maybe you could be interested in our quickstart guide.

Let us know if this comment was made in error, and we'll be happy to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants