![]() |
|---|
| © Karobben |
由於語法渲染問題而影響閱讀體驗, 請移步博客閱讀~
本文GitPage地址
CryptoWatch-Kivy 1.13Kivy 2.0.0Kivy-Garden 0.1.4kivy-garden.wordcloud 1.0.0kivymd 0.104.2.dev0
Quick Review
tree
.├── 123.fa├── 123.html├── Karobben_logo_horizontal_800.png├── LICENSE├── Layout│ ├── Blog.kv│ ├── CV_cm.kv│ ├── CV_test.kv│ ├── Data_table.kv│ ├── Font.kv│ ├── Navigation_Draw.kv│ ├── Navigation_Tabs.kv│ ├── Seq.kv│ ├── editor.kv│ ├── filechooser.kv│ └── menu.kv├── README.md├── alipay.jpg├── buildozer.spec├── config│ ├── Navi.json│ └── home.json├── custom_camera│ ├── __init__.py│ ├── custom_camera.kv│ └── custom_camera.py├── demo│ ├── clustal│ └── echart├── favicon.ico├── font│ ├── ArtificialBox-WdD4.ttf│ ├── FangZhengHeiTiFanTi-1.ttf│ ├── FangZhengHeiTiJianTi-1.ttf│ ├── FangZhengKaiTiPinYinZiKu-1.ttf│ ├── FangzhenXiaozhuan.ttf│ ├── HuaKangXinZhuanTi-1.ttf│ ├── JingDianFanJiaoZhuan-1.ttf│ ├── heydings-controls-1.ttf│ ├── heydings-icons-1.ttf│ ├── heydings-icons-2.ttf│ └── icon-works-webfont-2.ttf├── image_processing│ ├── __init__.py│ ├── cascades│ │ └── haarcascade_frontalface_default.xml│ └── image_processing.py├── libWidget│ ├── Blog.py│ ├── CV_cm.py│ ├── CV_test.py│ ├── Data_table.py│ ├── Font.py│ ├── Seq.py│ ├── editor.py│ ├── filechooser.py│ ├── menu.py│ └── model.txt├── libs│ ├── bio_seq.py│ ├── clustalo.py│ ├── clustalo.pytxt│ ├── web_open.py│ └── webview.py├── logo.png├── main.py└── wepay.png
Function for Close Tab
Because I was using my blog project to doing the test with this server, so I called it as Blog.py
Function run_sever is for starting the http server so you can render CSS and applying js, close_blog could close the server and back to home directory.
from kivy.lang import Builderfrom kivy.uix.popup import Popupfrom kivy.uix.floatlayout import FloatLayoutfrom kivy.uix.screenmanager import Screenfrom kivy.properties import ObjectPropertyfrom kivy.utils import platformimport osimport webbrowser, timeimport threadingclass FunctionWidget():def main(self):Builder.unload_file("Layout/Blog.kv")self.Function_page = Builder.load_file("Layout/Blog.kv")self.Function_page.ids.buton_start.on_release = self.open_blogself.Function_page.ids.buton_close.on_release = self.close_blogreturn self.Function_pagedef run_sever(self):import http.serverimport socketserverPORT = 5500Handler = http.server.SimpleHTTPRequestHandlerwith socketserver.TCPServer(("", PORT), Handler) as self.httpd:print("serving at port", PORT)self.httpd.serve_forever()def close_blog(self):PATH = os.path.abspath(__file__).split("libWidget")[0].replace("appc","app")print(PATH)try:self.httpd.shutdown()os.chdir(PATH)except:os.chdir(PATH)def open_blog(self, *args):if platform == "android":from libs.webview import WebViewos.chdir("Blog")PATH = os.path.abspath(__file__).split("libWidget")[0].replace("appc","app")URL = 'file://'+PATH+'/demo/clustal/123.html',URL = 'http://127.0.0.1:5500/'print("URL = ", URL)x = threading.Thread(target=self.run_sever, args=())x.start()print("Started, test")if platform == "android":self.browser = Noneself.browser = WebView(URL,enable_javascript = True,enable_downloads = True,enable_zoom = True)else:try:webbrowser.open('http://127.0.0.1:5500/')except:pass
Layout
Blog.py
MDBoxLayout:MDRectangleFlatButton:id: buton_starttext: "Start Server"on_release: Nonepos_hint: {"center_x": .5, "center_y": .5}MDRectangleFlatButton:id: buton_closetext: "Close Server"on_release: Nonepos_hint: {"center_x": .5, "center_y": .5}
Functions for webview
This function was written by RobertFlatt and published in RobertFlatt /Android-for-Python . He also contributed lots of other awesome functions and examples of widgets.
I copied his webview.py to libs directory. An example of using it:
if platform == "android":from libs.webview import WebViewself.browser = Noneself.browser = WebView(URL,enable_javascript = True,enable_downloads = True,enable_zoom = True)
Enjoy~
由於語法渲染問題而影響閱讀體驗, 請移步博客閱讀~
本文GitPage地址
GitHub: Karobben
Blog:Karobben
BiliBili:史上最不正經的生物狗

