def getprefdir(package): if (TOOLKIT == 'kivy'): from pysollib.kivy.LApp import get_platform plat = get_platform() if plat == 'android': os.environ['HOME'] = '/sdcard' if os.name == "nt": return win32_getprefdir(package) home = os.environ.get("HOME", "").strip() if not home or not os.path.isdir(home): home = os.curdir return os.path.join(home, ".PySolFC")
def display(self, url, add=1, relpath=1, xview=0, yview=0): # for some reason we have to stop the PySol demo # (is this a multithread problem with Tkinter ?) if self.app and self.app.game: self.app.game.stopDemo() # self.app.game._cancelDrag() # pass # ftp: and http: would work if we use urllib, but this widget is # far too limited to display anything but our documentation... for p in REMOTE_PROTOCOLS: if url.startswith(p): plat = get_platform() if plat == 'android': pass print("Open url: %s (TBD)" % url) # import android # tbd. # start android webbrowser. with url # ??? elif not openURL(url): return # locate the file relative to the current url url = self.basejoin(url, relpath=relpath) # read the file try: file = None if 0: import urllib file = urllib.urlopen(url) else: file, url = self.openfile(url) data = file.read() file.close() file = None except Exception: print("Open url(1) - Exception: %s" % url) if file: file.close() ''' self.errorDialog(_("Unable to service request:\n") + url) ''' return self.url = url if self.home is None: self.home = self.url if add: self.addHistory(self.url, xview=xview, yview=yview) # print self.history.index, self.history.list if self.history.index > 1: self.backButton.config(state="normal") else: self.backButton.config(state="disabled") if self.history.index < len(self.history.list): self.forwardButton.config(state="normal") else: self.forwardButton.config(state="disabled") old_c1, old_c2 = self.defcursor, self.handcursor self.defcursor = self.handcursor = "watch" self.text.config(cursor=self.defcursor) self.text.update_idletasks() # self.frame.config(cursor=self.defcursor) # self.frame.update_idletasks() self.text.config(state="normal") self.text.delete("1.0", "end") # self.images = {} self.text.textbuffer = '' writer = tkHTMLWriter(self.text, self, self.app) fmt = formatter.AbstractFormatter(writer) parser = tkHTMLParser(fmt) parser.feed(data) parser.close() self.text.config(state="disabled") if 0.0 <= xview <= 1.0: self.text.xview_moveto(xview) if 0.0 <= yview <= 1.0: self.text.yview_moveto(yview) # self.parent.wm_title(parser.title) self.window.titleline.text = parser.title self.parent.wm_iconname(parser.title) self.defcursor, self.handcursor = old_c1, old_c2 self.text.config(cursor=self.defcursor)
from pysollib.kivy.LApp import LScrollView from pysollib.kivy.LApp import LPopCommander from pysollib.kivy.LApp import get_platform from pysollib.pysoltk import MfxMessageDialog from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.button import Button REMOTE_PROTOCOLS = ("ftp:", "gopher:", "http:", "mailto:", "news:", "telnet:") # ************************************************************************ # * # ************************************************************************ if get_platform() == 'android': from jnius import autoclass from jnius import cast def startAndroidBrowser(www): # init java classes PythonActivity = autoclass('org.kivy.android.PythonActivity') Intent = autoclass('android.content.Intent') Uri = autoclass('android.net.Uri') # String = autoclass('java.lang.String') # get the Java object # prepare activity # PythonActivity.mActivity is the instance of the current Activity # BUT, startActivity is a method from the Activity class, not from our # PythonActivity. # We need to cast our class into an activity and use it
from pysollib.kivy.LApp import LScrollView from pysollib.kivy.LApp import LTopLevel from pysollib.kivy.LApp import get_platform from pysollib.mfxutil import Struct, openURL from pysollib.mygettext import _ from pysollib.pysoltk import MfxMessageDialog from pysollib.settings import TITLE REMOTE_PROTOCOLS = ("ftp:", "gopher:", "http:", "mailto:", "news:", "telnet:") # ************************************************************************ # * # ************************************************************************ if get_platform() == 'android': from jnius import autoclass from jnius import cast def startAndroidBrowser(www): # init java classes PythonActivity = autoclass('org.kivy.android.PythonActivity') Intent = autoclass('android.content.Intent') Uri = autoclass('android.net.Uri') # String = autoclass('java.lang.String') # get the Java object # prepare activity # PythonActivity.mActivity is the instance of the current Activity # BUT, startActivity is a method from the Activity class, not from our # PythonActivity. # We need to cast our class into an activity and use it