Веб-браузер пытается открыть файл PDF вместо HTML в браузере - PullRequest
1 голос
/ 11 апреля 2019

Я пытаюсь открыть файл в своем браузере с помощью Python в приложении kivy с помощью модуля webbrowser.Вот мой код:

import webbrowser
import os

from kivy.app import App

from kivy.uix.button import Button

class SimpleBrowserApp(App):
    def build(self):
        btn = Button(text="open browser")
        btn.bind(on_press=SimpleBrowserApp.OpenBrowser)
        return btn

def OpenBrowser(*args):
    webbrowser.open("file:///" + os.getcwd()+"/"+"map.html")

SimpleBrowserApp().run()

Когда я пытаюсь открыть его, мой телефон возвращает эту карту - (PDF inaccessible(" map.html" can't open)):.

here Моя.html "находится в той же папке, что и" main.py ".

buildozer.spec:

[app]


# (str) Title of your application

title = GPSGuide



# (str) Package name

package.name = gpsguide



# (str) Package domain (needed for android/ios packaging)

package.domain = org.test



# (str) Source code where the main.py live

source.dir = .



# (list) Source files to include (let empty to include all the files)

source.include_exts = 



 # (list) List of inclusions using pattern matching

 #source.include_patterns = assets/*,images/*.png



 # (list) Source files to exclude (let empty to not exclude anything)

 #source.exclude_exts = spec



 # (list) List of directory to exclude (let empty to not exclude anything)

 #source.exclude_dirs = tests, bin



 # (list) List of exclusions using pattern matching

 #source.exclude_patterns = license,images/*/*.jpg



 # (str) Application versioning (method 1)

 version = 0.1



 # (str) Application versioning (method 2)

 # version.regex = __version__ = ['"](.*)['"]

 # version.filename = %(source.dir)s/main.py



 # (list) Application requirements

 # comma separated e.g. requirements = sqlite3,kivy

 requirements = python3,kivy,android,plyer



 # (str) Custom source folders for requirements

 # Sets custom source for any requirements with recipes

 # requirements.source.kivy = ../../kivy



 # (list) Garden requirements

 #garden_requirements =



 # (str) Presplash of the application

 #presplash.filename = %(source.dir)s/data/presplash.png



 # (str) Icon of the application

 #icon.filename = %(source.dir)s/data/icon.png



 # (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)

 orientation = portrait



 # (list) List of service to declare

 #services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY



 #

 # OSX Specific

 #



 #

 # author = © Copyright Info



 # change the major version of python used by the app

 osx.python_version = 3



 # Kivy version to use

 osx.kivy_version = 1.9.1



 #

 # Android specific

 #



 # (bool) Indicate if the application should be fullscreen or not

 fullscreen = 0



 # (string) Presplash background color (for new android toolchain)

 # Supported formats are: #RRGGBB #AARRGGBB or one of the following names:

 # red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,

 # darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,

 # olive, purple, silver, teal.

 #android.presplash_color = #FFFFFF



 # (list) Permissions

 #android.permissions = INTERNET



 # (int) Target Android API, should be as high as possible.

 #android.api = 27



 # (int) Minimum API your APK will support.

 #android.minapi = 21



 # (int) Android SDK version to use

 #android.sdk = 20



 # (str) Android NDK version to use

 #android.ndk = 17c



 # (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.

 #android.ndk_api = 21



 # (bool) Use --private data storage (True) or --dir public storage (False)

Возможно, я что-то не понимаю или есть другой способ открыть HTML-код вбраузер.Мне просто нужно открыть этот файл в браузере.

...