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