Webbrowser尝试在浏览器中打开PDF文件而不是html

时间:2019-04-11 14:50:00

标签: android python kivy python-webbrowser

我正在尝试使用webbrowser模块在kivy应用程序中使用Python在浏览器中打开文件。 这是我的代码:

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 我的“ map.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代码的方法。 我只需要在浏览器中打开此文件。

0 个答案:

没有答案