From 1a60b684611c83b2c32f60dffd38eae70fdc4612 Mon Sep 17 00:00:00 2001 From: janis Date: Sat, 26 Feb 2022 16:44:03 +0100 Subject: [PATCH] Initial GUI-Development progress - 2022-02-26-16:42 --- .idea/vcs.xml | 6 ++ bin/modules/configurator.py | 12 +-- bin/price_extractor/price_scrapper_v2.py | 45 --------- data/config.csv | 0 data/prices.csv | 6 +- dev_tools/hotreloader.py | 32 +++++++ gui_main/configurator.kv | 16 ++++ gui_main/main-gui.kv | 31 +++++++ gui_main/splashscreen.kv | 24 +++++ simplePCBuilding-PC-Configurator-alpha1.py | 103 ++++++++++----------- 10 files changed, 161 insertions(+), 114 deletions(-) create mode 100644 .idea/vcs.xml delete mode 100644 bin/price_extractor/price_scrapper_v2.py create mode 100644 data/config.csv create mode 100644 dev_tools/hotreloader.py create mode 100644 gui_main/configurator.kv create mode 100644 gui_main/main-gui.kv create mode 100644 gui_main/splashscreen.kv diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bin/modules/configurator.py b/bin/modules/configurator.py index 6d0d05b..5d9814f 100644 --- a/bin/modules/configurator.py +++ b/bin/modules/configurator.py @@ -5,14 +5,4 @@ This module configures PCs but relies heavily on external modules that are inclu class ConfigCreator: def __init__(self): - print(""" - - - -Welcome to the PC-Configurator! --------------------------------- - -We still need a couple of informations so we can make sure you get the best configuration possible! - -No more questions? Let's start! -""") + print("") diff --git a/bin/price_extractor/price_scrapper_v2.py b/bin/price_extractor/price_scrapper_v2.py deleted file mode 100644 index 52db1dd..0000000 --- a/bin/price_extractor/price_scrapper_v2.py +++ /dev/null @@ -1,45 +0,0 @@ -import bin.lib.csv_parsers -import requests -import datetime - -cvr = bin.lib.csv_parsers.CsvRead() -cvw = bin.lib.csv_parsers.CsvWrite() - -class PriceExtractor: - def __init__(self): - - def update_all_prices(self, folder): - self.digitec_extractor() - - - def digitec_extractor(self): - """Run through the entire list of links specified in the csv file that was selected either when loading the - function or when specified through the method \"readfile\". NOTE: This method does not require any additional - arguments and also does run through the entire file!""" - while - - while self.__productnumber < self.__productcount: - self.__ingest = self.__raw_list.pop(0) - self.__website = self.__ingest.pop(1) - self.__productnumber = int(self.__ingest.pop(0)) - print("fetching data... This step might take a couple of seconds") - self.__res = requests.get(self.__website) - print("recieved data from", self.__website) - self.__check = str(self.__res) - if self.__check == "": - print("Ressource unavailable, skipping..") - else: - self.__request_done = self.__res.text - self.__priceIdx = self.__request_done.index('property="product:price:amount') - self.__raw_price = self.__request_done[self.__priceIdx + 41:self.__priceIdx + 60] - self.__price_extract = "" - for buchstabe in self.__raw_price: - if buchstabe == "\"": - break - else: - self.__price_extract += buchstabe - self.__price = float(self.__price_extract) - print("The price is following: ", self.__price, "CHF\n") - with open("../../data/prices.csv", "a") as pricedata: - writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) - writing.writerow([self.__productnumber, self.__price]) diff --git a/data/config.csv b/data/config.csv new file mode 100644 index 0000000..e69de29 diff --git a/data/prices.csv b/data/prices.csv index 846c1a0..8fe97fe 100644 --- a/data/prices.csv +++ b/data/prices.csv @@ -1,5 +1,5 @@ -version from,2022-02-17 09:30:53.233664 -1,559.0 +version from,2022-02-26 11:06:52.832345 +1,495.0 2,290.0 -3,9.2 +3,9.3 4,359.0 diff --git a/dev_tools/hotreloader.py b/dev_tools/hotreloader.py new file mode 100644 index 0000000..04f956e --- /dev/null +++ b/dev_tools/hotreloader.py @@ -0,0 +1,32 @@ +from kivy.lang import Builder + +from kivymd.app import MDApp + +KV = ''' +#:import KivyLexer kivy.extras.highlight.KivyLexer +#:import HotReloadViewer kivymd.utils.hot_reload_viewer.HotReloadViewer + + +BoxLayout: + HotReloadViewer: + size_hint_x: .3 + path: app.path_to_kv_file + errors: True + errors_text_color: 1, 1, 0, 1 + errors_background_color: app.theme_cls.bg_dark +''' + + +class Example(MDApp): + path_to_kv_file = "../gui_main/configurator.kv" + + def build(self): + self.theme_cls.theme_style = "Dark" + return Builder.load_string(KV) + + def update_kv_file(self, text): + with open(self.path_to_kv_file, "w") as kv_file: + kv_file.write(text) + + +Example().run() diff --git a/gui_main/configurator.kv b/gui_main/configurator.kv new file mode 100644 index 0000000..685d6a7 --- /dev/null +++ b/gui_main/configurator.kv @@ -0,0 +1,16 @@ +MDScreen: + name: "Config" + md_bg_color: (0,0,1,0.5) + MDFloatLayout: + cols:1 + MDFlatButton: + text: "Back" + pos_hint: {"x": 0.15, "y": 0.1} + font_size: 20 + md_bg_color: (0, 0, 0, 1) + size_hint: 0.1, 0.05 + on_release: + app.root.current = "HomeScreen" + root.manager.transition.direction = "left" + MDFlatButton: + text: "Test" \ No newline at end of file diff --git a/gui_main/main-gui.kv b/gui_main/main-gui.kv new file mode 100644 index 0000000..763b249 --- /dev/null +++ b/gui_main/main-gui.kv @@ -0,0 +1,31 @@ +Home: + name: "HomeScreen" + radius: [25, 25, 25, 25] + md_bg_color: app.theme_cls.accent_color + GridLayout: + cols: 1 + Label: + text: "PC-Configurator" + font_size: 50 + color: (50, 50, 255, 1) + bold: True + italic: True + FloatLayout: + GridLayout: + cols: 3 + size_hint: 0.94, 0.8 + pos_hint: {"x":0.03, "y":0.1} + Button: + text: "Configure" + background_color: (0.1, 0.1, 1, 0.5) + on_release: + app.root.current = "Config" + root.manager.transition.direction = "right" + Button: + text: "Settings" + background_color: (0.1, 0.1, 1, 0.5) + on_release: + root.test() + Button: + text: "Quit" + background_color: (0.1, 0.1, 1, 0.5) diff --git a/gui_main/splashscreen.kv b/gui_main/splashscreen.kv new file mode 100644 index 0000000..127a338 --- /dev/null +++ b/gui_main/splashscreen.kv @@ -0,0 +1,24 @@ +MDScreen: + name: "Splash" + on_enter: self.ids.progress.start() + md_bg_color: app.theme_cls.accent_color + GridLayout: + cols: 1 + Label: + text: "PC-Configurator" + bold: True + italic: True + font_size: 40 + color: app.theme_cls.primary_color + FloatLayout: + BoxLayout: + pos_hint: {"center_y": .3, "center_x": .5} + padding: "10dp" + size_hint_x: .7 + + MDProgressBar: + id: progress + orientation: "horizontal" + type: "indeterminate" + running_duration: 1 + catching_duration: 1 \ No newline at end of file diff --git a/simplePCBuilding-PC-Configurator-alpha1.py b/simplePCBuilding-PC-Configurator-alpha1.py index 9a04954..26f96ab 100644 --- a/simplePCBuilding-PC-Configurator-alpha1.py +++ b/simplePCBuilding-PC-Configurator-alpha1.py @@ -1,69 +1,62 @@ # This is the main runtime of the simplePCBuilding-PC-Configurator # IMPORTS import time - +from kivy.uix.screenmanager import Screen, ScreenManager +from kivy.uix.popup import Popup +from kivy.app import App +from kivy.lang import Builder +from kivy.clock import mainthread +from kivymd.app import MDApp +from kivymd.uix.screen import MDScreen +from kivy.clock import Clock version = "alpha 1.0" -print(""" --------------------------------------------------------------------- - WELCOME TO THE simplePCBuilding PC CONFIGURATOR - YOU ARE CURRENTLY RUNNING VERSION""", version, """ ----------------------------------------------------------------------""") -time.sleep(1) -print(""" +print(f"Launching the simplePCBuilding-PC-Configurator Version {version}!...\nthis might take some time...") -Please note that this software is developed and distributed by simplePCBuilding -and as such you are not allowed to sell and / or distribute this software on -your own. If you want to share this project with others, please refer to our -guidelines and do only provide the official download-link. -""") -time.sleep(1) -print("""This software is split up into different modules you can use. -Select the appropriate one: -MODULE LIST: -- Configurator (c) -- Updater (u) -- Package manager (p) -- Quit (q) +########### +# SCREENS +########### -To select a module, please type the correct letter (found in brackets behind -the module name in the above list) in through your keyboard -""") -i = input("please choose the module you want to use: ") -go = 1 -while go == 1: - if i == "c": - print("starting configurator...") - go = 0 +class Splash(MDScreen): + pass - elif i == "u": - print("starting updater...") - go = 0 - elif i == "p": - print("starting package manager...") - go = 0 +class Home(MDScreen): + def test(self): + print("class") - elif i == "q": - print("killing processes....") - time.sleep(0.5) - print("Terminating...") - go = 0 - else: - print("\nUnknown entry, please retry.\n ") - time.sleep(0.5) - print("""This software is split up into different modules you can use. -Select the appropriate one: - MODULE LIST: - - Configurator (c) - - Updater (u) - - Package manager (p) - - Quit (q) +class ConfigureScreen(MDScreen): + pass - To select a module, please type the correct letter (found in brackets behind - the module name in the above list) in through your keyboard - """) - i = input("Please select a module and type in the corresponding letter: ") + +################# +# SCREEN-MANAGER +################# + + +class PCConfigurator(MDApp): + global screen_manager + screen_manager = ScreenManager() + def build(self): + self.title = "simplePCBuilding-PC-Configurator" + self.theme_cls.primary_palette = "Blue" + self.theme_cls.accent_palette = "BlueGray" + # self.icon = "./BiogasControllerAppLogo.png" + screen_manager.add_widget(Builder.load_file("./gui_main/splashscreen.kv")) + screen_manager.add_widget(Builder.load_file("./gui_main/main-gui.kv")) + screen_manager.add_widget(Builder.load_file("./gui_main/configurator.kv")) + + return screen_manager + + def on_start(self): + Clock.schedule_once(self.launch_app, 1) + + def launch_app(self, dt): + screen_manager.current = "HomeScreen" + + +if __name__ == "__main__": + PCConfigurator().run()