globalforest/main.py

100 lines
2.4 KiB
Python
Raw Normal View History

2020-10-18 19:16:32 -04:00
__author__ = "afx"
__version__ = "0.2"
# Import system modules
2020-10-25 16:05:46 -04:00
from multiprocessing import Process, Queue
2020-10-17 12:22:22 -04:00
import random
2020-09-28 23:18:26 -04:00
import sqlite3
2020-09-25 10:20:37 -04:00
# Import Kivy modules
2020-10-14 00:19:43 -04:00
from kivymd.app import MDApp
2020-09-28 18:38:35 -04:00
from kivy.lang import Builder
2020-09-25 10:20:37 -04:00
2020-09-28 18:38:35 -04:00
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.boxlayout import BoxLayout
2020-09-20 10:51:02 -04:00
from kivy.uix.label import Label
2020-09-25 10:20:37 -04:00
2020-09-28 18:38:35 -04:00
from kivy.core.window import Window
2020-09-21 17:13:51 -04:00
from kivy.graphics import Rectangle
2020-09-20 10:51:02 -04:00
# Import local modules
from forestmapview import ForestMapView
#from searchpopupmenu import SearchPopupMenu
from gpshelper import GpsHelper
from settings import SampleBoxLayout
from game import GameWidget
2020-10-18 13:53:02 -04:00
from cncbot import CnCApp
2020-10-17 12:22:22 -04:00
# Welcome message
MOTD = """]
2020-10-18 19:16:32 -04:00
] GlobalForest {} by afx""".format(__version__)
2020-10-14 08:29:53 -04:00
2020-09-28 18:38:35 -04:00
Builder.load_string("""
<ScreenOne>:
BoxLayout:
Button:
text: "Go to Screen 2"
on_press:
root.manager.transition.direction = "left"
root.manager.transition.duration = 1
root.manager.current = "screen_two"
<ScreenTwo>:
BoxLayout:
Button:
text: "Go to Screen 1"
on_press:
root.manager.transition.direction = "right"
root.manager.transition.duration = 1
root.manager.current = "screen_one"
""")
class ScreenOne(Screen):
pass
class ScreenTwo(Screen):
pass
2020-10-14 00:19:43 -04:00
class MainApp(MDApp):
connection = None
cursor = None
search_menu = None
2020-09-28 18:38:35 -04:00
def build(self):
pass
#Window.clearcolor = (0, 0, 0, 0)
#return SampleBoxLayout()
2020-09-28 18:38:35 -04:00
def on_start(self):
# Welcome
2020-10-17 12:22:22 -04:00
print(MOTD)
self.logqueue.put('] Framework started.')
self.theme_cls.primary_palette = 'BlueGray'
2020-09-28 23:18:26 -04:00
# Initialize GPS
GpsHelper().run()
2020-09-28 23:18:26 -04:00
# Connect to database
self.connection = sqlite3.connect("databases/fountains.db")
2020-09-28 23:18:26 -04:00
self.cursor = self.connection.cursor()
# Instantiate SearchPopupMenu
#self.search_menu = SearchPopupMenu()
2020-10-25 16:05:46 -04:00
if __name__ == '__main__':
2020-10-18 13:53:02 -04:00
# Start the Command and Control bot. Mainly for reporting.
logqueue = Queue()
cnc = Process(target=CnCApp, args=((logqueue),))
2020-10-18 13:53:02 -04:00
cnc.start()
2020-10-17 12:22:22 -04:00
2020-10-18 13:53:02 -04:00
# Start the Kivy Framework main loop
2020-10-17 12:22:22 -04:00
kivyapp = MainApp()
kivyapp.logqueue = logqueue
2020-10-17 12:22:22 -04:00
kivyapp.run()
2020-10-18 13:53:02 -04:00
# Cleanup subprocesses
2020-10-25 16:05:46 -04:00
print('] Framework terminated.')
2020-10-18 19:16:32 -04:00
cnc.kill()