def __init__(self, **kwargs): super().__init__(**kwargs) self.BACK_SCREEN = "Splash" if "covers" not in os.listdir(helper.get_app_path() + APP_NAME + "/"): os.mkdir(helper.get_app_path() + APP_NAME + "/covers") if "texts" not in os.listdir(helper.get_app_path() + APP_NAME + "/"): os.mkdir(helper.get_app_path() + APP_NAME + "/texts")
def entered(self): self.page = 1 self.book_label = self.children[0].children[1].children[0].children[0] self.scroll = self.children[0].children[1].children[0] with open(helper.get_app_path() + APP_NAME + "/texts/" + self.book_filename + ".txt") as f: text = f.read() self.pages = [text[i:i + 5000] for i in range(0, len(text), 5000)] self.book_label.text = self.pages[0] self.progress_label = self.children[0].children[0].children[2] self.progress_label.text = "{}/{}".format(self.page, len(self.pages)) self.previous_page = self.children[0].children[0].children[1] self.previous_page.on_press = self.show_previous_page self.next_page = self.children[0].children[0].children[0] self.next_page.on_press = self.show_next_page
def format_book(self): self.info = self.children[0].children[1].children[0] self.progress = self.children[0].children[2].children[0] self.queue.put("0:100:Reading EPUB") pub = epub.read_epub(self.filepath) self.queue.put("100:100:Reading EPUB") docs = [d for d in pub.get_items_of_type(ebooklib.ITEM_DOCUMENT)] self.queue.put("0:{}:Extracting relevant HTML".format(len(docs))) html_text = "" for i, d in enumerate(docs): html_text += d.get_body_content().decode() self.queue.put("{}:{}:Extracting relevant HTML".format(i, len(docs))) whole_text = "" self.queue.put("0:100:Making the Soup - might take a while") strainer = bs4.SoupStrainer("p") self.queue.put("20:100:Making the Soup - might take a while") soup = bs4.BeautifulSoup(html_text, "lxml", parse_only=strainer) self.queue.put("100:100:Soup made!") paras = [p for p in soup.find_all("p")] self.queue.put("0:{}:Extracting text".format(len(paras))) whole_text = "" for i, para in enumerate(paras): if para.text != "": whole_text += para.text + "\n" if i %100 == 0: self.queue.put("{}:{}:Extracting text".format(i, len(paras))) self.queue.put("0:100:Writing to disk...") path_to_save = helper.get_app_path() + "Reader/texts/{}.txt".format(self.filepath.split("/")[-1].split(".")[0]) with open(path_to_save, "w") as f: f.write(whole_text) self.queue.put("100:100:All done! Feel free to leave.")
import kivy kivy.require('1.10.1') from kivy.app import App from kivy.lang import Builder from kivy.config import Config from kivy.uix.screenmanager import Screen, ScreenManager from helperbee import helper APP_NAME = "BEE-testapp" Builder.load_file(helper.get_app_path() + APP_NAME + "/testapp.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') class MainScreen(Screen): pass controller = ScreenManager() controller.add_widget(MainScreen(name="Main")) def get_app(): return controller def get_icon(): return "testicon.png"
def entered(self): grid = self.children[0].children[0] grid.clear_widgets() self.books = [] self.book_filepaths = [ helper.get_resources_path() + "/books/" + b for b in os.listdir(helper.get_resources_path() + "/books/") ] self.titles = [] if self.book_filepaths == []: grid.add_widget(Label(text="No books found :(")) n = 0 for b in self.book_filepaths: n += 1 if n % 2 == 0: grid.height = 200 + n * 200 n = 0 for b in self.book_filepaths: n += 1 button = Button(on_press=self.goto_read) button.size_hint = (None, None) button.size = (200, 200) self.children[0].children[0].add_widget(button) layout = BoxLayout() button.add_widget(layout) x = ((1 - (n % 2)) * 240) + 70 y = grid.height - ((((n - 1) / 2) - (((n - 1) / 2) % 1)) * 240) - 250 layout.pos = (x, y) layout.size = button.size layout.orientation = "vertical" self.book_filename = b.split("/")[-1].split(".")[0] book = EPUBEE(b) cover = book.get_cover() if cover != "": cover_path = helper.get_app_path( ) + APP_NAME + "/covers/" + self.book_filename + ".jpeg" cover.save(cover_path) self.books.append(book) img = Image(source=cover_path) img.size_hint_x = None img.width = 100 img.height = 100 if len(book.title) > 18: text = book.title[:15] + "..." else: text = book.title self.titles.append(text) lbl = Label(text=text, color=[.5, .5, .5, 1], size_hint=(None, None), pos=(button.pos[0], button.pos[1])) if cover != "": layout.add_widget(img) print("adding") layout.add_widget(lbl)
from kivy.lang import Builder from kivy.config import Config from kivy.uix.label import Label from kivy.uix.image import Image from kivy.uix.button import Button from kivy.uix.boxlayout import BoxLayout from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition from helperbee import helper from EPUBEE import EPUBEE APP_NAME = "Reader" FIRST = False Builder.load_file(helper.get_app_path() + APP_NAME + "/reader.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') class BooksScreen(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) self.BACK_SCREEN = "Splash" if "covers" not in os.listdir(helper.get_app_path() + APP_NAME + "/"): os.mkdir(helper.get_app_path() + APP_NAME + "/covers") if "texts" not in os.listdir(helper.get_app_path() + APP_NAME + "/"): os.mkdir(helper.get_app_path() + APP_NAME + "/texts") def entered(self): grid = self.children[0].children[0]
import kivy kivy.require('1.10.1') from kivy.app import App from kivy.clock import Clock from kivy.lang import Builder from kivy.config import Config from kivy.uix.screenmanager import Screen, ScreenManager from helperbee import helper APP_NAME = "Thermometer" FIRST = False Builder.load_file(helper.get_app_path() + APP_NAME + "/thermometer.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') class TemperatureScreen(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) def entered(self): self.info = self.children[0].children[1] self.temp = self.children[0].children[2].children[0] self.update_temperature(None) Clock.schedule_interval(self.update_temperature, 0.5) def update_temperature(self, dt):
from kivy.app import App from kivy.clock import Clock from kivy.lang import Builder from kivy.config import Config from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.screenmanager import Screen, ScreenManager from MusicBEE import player from helperbee import helper APP_NAME = "Music" FIRST = False Builder.load_file(helper.get_app_path() + APP_NAME + "/music.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') class ChoicesScreen(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) self.BACK_SCREEN = "Main" def entered(self): self.grid = self.children[0].children[1].children[0].children[0] self.playlist = self.children[0].children[2].children[0] self.pause_button = self.children[0].children[0].children[0] self.pause_button.on_press = self.toggle_pause self.song_name = self.children[0].children[0].children[1]
from kivy.lang import Builder from kivy.config import Config from kivy.uix.button import Button from kivy.uix.label import Label from kivy.core.window import Window from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition from Renderer import Renderer from helperbee import helper from device_info import set_password, set_home_image, set_lock_image APP_NAME = "Settings" Builder.load_file(helper.get_app_path() + APP_NAME + "/settings.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') SUBSETTINGS_CATEGORIES = ["Wifi", "Security", "Wallpaper", "Update Resources", "Brightness"] BOOK_EXTENSIONS = ["epub"] MUSIC_EXTENSIONS = ["mp3"] FIRST = False class SplashScreen(Screen): def entered(self): self.BACK_SCREEN = "Splash" self.parent.transition = FadeTransition() self.parent.get_screen("Main").entered() self.parent.current = "Main"
from kivy.uix.boxlayout import BoxLayout from kivy.uix.image import Image, AsyncImage from kivy.uix.screenmanager import Screen, ScreenManager, FadeTransition from helperbee import helper import xml.etree.ElementTree as ET import threading import requests import queue import subprocess APP_NAME = "BEEStore" FIRST = False Builder.load_file(helper.get_app_path() + APP_NAME + "/BEEStore.kv") Config.set('graphics', 'width', '480') Config.set('graphics', 'height', '800') class MainScreen(Screen): def __init__(self, **kwargs): super().__init__(**kwargs) self.applist_queue = queue.Queue() self.thread = threading.Thread(None, self.get_applist) self.thread.setDaemon(True) def entered(self): self.thread.start()