maj readme
This commit is contained in:
parent
e9dd04b649
commit
ecddf328b8
14
README.md
14
README.md
@ -2,15 +2,15 @@
|
||||
|
||||
Client Android pour API en python avec kivy (UI) et buildozer (build)
|
||||
|
||||
## PRE REQUIS
|
||||
## PRE REQUIS :paperclip:
|
||||
|
||||
- Python3
|
||||
|
||||
## CONFIGURATION
|
||||
## CONFIGURATION :wrench:
|
||||
|
||||
> Renseigner les champs api_key et api_url en fonction de votre configuration.
|
||||
|
||||
## UTILISATION
|
||||
## UTILISATION :rocket:
|
||||
|
||||
- Installer les dépendances:
|
||||
```bash
|
||||
@ -22,7 +22,9 @@ python3 -m pip install -r requirements.txt
|
||||
python3 main.py
|
||||
```
|
||||
|
||||
### BUILD APK
|
||||
:warning: Nécéssite une api_url fonctionnelle avec son api_key
|
||||
|
||||
### BUILD APK :iphone:
|
||||
|
||||
```bash
|
||||
buildozer -v android debug
|
||||
@ -30,11 +32,11 @@ buildozer -v android debug
|
||||
|
||||
> Le fichier APK se trouve dans le dossier bin/
|
||||
|
||||
## TODO
|
||||
## TODO :bookmark_tabs:
|
||||
|
||||
- [X] Splashcreen
|
||||
- [X] Make background random
|
||||
- [X] Images in folder
|
||||
- [X] Button CSS
|
||||
- [ ] Lien code source
|
||||
- [ ] Load API_KEY
|
||||
- [ ] Load API_KEY on startup if not found
|
||||
|
||||
14
main.py
14
main.py
@ -1,23 +1,20 @@
|
||||
import requests, json, os, random
|
||||
from kivy.app import App
|
||||
from kivy.uix.label import Label
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.graphics import Rectangle
|
||||
from kivy.uix.image import Image
|
||||
from kivy.uix.button import Button
|
||||
from kivy.core.window import Window
|
||||
from kivymd.app import MDApp
|
||||
from kivymd.uix.button import MDRectangleFlatButton
|
||||
import requests, json, os, random
|
||||
|
||||
# API key
|
||||
api_key="A RECUPERER DU SERVEUR API"
|
||||
api_url = "https://citations.domaine.tld/api/citations/random"
|
||||
|
||||
|
||||
class MainApp(MDApp):
|
||||
def build(self):
|
||||
return MainWidget()
|
||||
|
||||
# class widget
|
||||
class MainWidget(BoxLayout):
|
||||
def __init__(self, **kwargs):
|
||||
super(MainWidget, self).__init__(orientation='vertical', **kwargs)
|
||||
@ -29,7 +26,6 @@ class MainWidget(BoxLayout):
|
||||
self.add_widget(self.quote_label)
|
||||
|
||||
# bouton
|
||||
#button = Button(text='Recharger', size_hint=(None, None), size=(300, 100), pos_hint={'center_x': 0.5, 'center_y': 0.1})
|
||||
button = MDRectangleFlatButton(text='Recharger', size_hint=(None, None), size=(300, 100), pos_hint={'center_x': 0.5, 'center_y': 0.1}, line_color="white", text_color="white")
|
||||
button.bind(on_press=self.load_citation)
|
||||
self.add_widget(button)
|
||||
@ -40,7 +36,7 @@ class MainWidget(BoxLayout):
|
||||
|
||||
# for button
|
||||
def load_citation(self, instance=None):
|
||||
quote = get_citation()
|
||||
quote = get_citation(api_url)
|
||||
auteur = quote[1]
|
||||
citation = split_string(quote[0], 40)
|
||||
|
||||
@ -53,8 +49,8 @@ class MainWidget(BoxLayout):
|
||||
|
||||
|
||||
# fonction pour récupérer la citation de l'API
|
||||
def get_citation():
|
||||
api_url = "https://citations.gregandev.fr/api/citations/random"
|
||||
def get_citation(api_url):
|
||||
|
||||
try:
|
||||
headers = {
|
||||
"API-Key": api_key
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user