-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from sebastian-muthwill/dev-gui
First version of GUI
- Loading branch information
Showing
17 changed files
with
436 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
src/* | ||
__pycache* | ||
build/* | ||
.vscode/* | ||
dist/d/* | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule d
added at
b629db
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#:include docstring_gui/screens/result_screen/result_screen.kv | ||
|
||
ScreenManager: | ||
MainScreen: | ||
ResultScreen: | ||
|
||
<MainScreen> | ||
name: "main-screen" | ||
|
||
source: source | ||
output: output | ||
config: config | ||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
adaptive_height: False | ||
spacing: 20 | ||
|
||
MDToolbar: | ||
title: "Power Apps - Docstring" | ||
|
||
MDRectangleFlatIconButton: | ||
icon: "bug-outline" | ||
text: "Issue" | ||
theme_text_color: "Custom" | ||
text_color: 1, 1, 1, 1 | ||
line_color: 0, 0, 0, 0 | ||
icon_color: 1, 1, 1, 1 | ||
pos_hint: { 'center_y' : .5} | ||
halign: "right" | ||
padding: [0, 0, 50, 0] | ||
on_press: root.open_new_issue() | ||
|
||
MDRectangleFlatIconButton: | ||
icon: "github" | ||
text: "Documentation" | ||
theme_text_color: "Custom" | ||
text_color: 1, 1, 1, 1 | ||
line_color: 0, 0, 0, 0 | ||
icon_color: 1, 1, 1, 1 | ||
pos_hint: { 'center_y' : .5} | ||
halign: "right" | ||
padding: [0, 0, 50, 0] | ||
on_press: root.open_github() | ||
|
||
|
||
MDIconButton: | ||
halign: "right" | ||
pos_hint: { 'center_y' : .5} | ||
icon: "close" | ||
theme_text_color: "Custom" | ||
text_color: "white" | ||
on_press: app.stop() | ||
|
||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
size_hint: (0.8, 1) | ||
pos_hint: { 'left' : .9, 'right': .9} | ||
adaptive_height: False | ||
spacing: 20 | ||
|
||
MDLabel: | ||
text: "Create documentation from Power Apps source code" | ||
font_style: "H5" | ||
halign: "center" | ||
|
||
MDLabel: | ||
text: "Provide the path to your source folder of your unpacked Power App as well as the output folder where the documentation is stored. Additionaly the path to a config.yaml can be spcified. If no custom config is provided, standard config.yaml will be used. Please find a detailed description on GitHub." | ||
halign: "center" | ||
|
||
MDTextField: | ||
id: source | ||
hint_text: "Source path" | ||
mode: "fill" | ||
required: True | ||
helper_text: "/path/to/src/app/" | ||
helper_text_mode: "on_focus" | ||
|
||
MDTextField: | ||
id: output | ||
hint_text: "Output path" | ||
mode: "fill" | ||
required: True | ||
helper_text: "./output/" | ||
helper_text_mode: "on_focus" | ||
|
||
MDTextField: | ||
id: config | ||
hint_text: "Config path (optional)" | ||
mode: "fill" | ||
required: False | ||
helper_text: "/path/to/config.yaml" | ||
helper_text_mode: "on_focus" | ||
|
||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
|
||
MDProgressBar: | ||
orientation: "horizontal" | ||
value: 50 | ||
|
||
MDBoxLayout: | ||
orientation: "horizontal" | ||
#size_hint: (0.8, 1) | ||
#pos_hint: { 'right': .9} | ||
adaptive_height: False | ||
|
||
MDLabel: | ||
text: "Step 1" | ||
halign: "left" | ||
pos_hint: { 'center_y' : .8} | ||
|
||
MDRaisedButton: | ||
text: "Create" | ||
halign: "right" | ||
background_color : 0, 0, 0, 1 | ||
#padding_y: 50 | ||
pos_hint: {'center_y' : .8} | ||
on_press: | ||
root.create_documentation() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import os, sys | ||
import yaml | ||
import webbrowser | ||
from kivy.core.window import Window | ||
from kivy.lang import Builder | ||
from kivy.properties import ObjectProperty | ||
from kivy.uix.screenmanager import (FadeTransition, Screen, ScreenManager, | ||
TransitionBase) | ||
from kivymd.app import MDApp | ||
from kivymd.uix.button import MDRectangleFlatButton | ||
from kivy.resources import resource_add_path, resource_find | ||
|
||
# import powerapps classes | ||
from powerapps_docstring.documentation import Docstring | ||
|
||
# import screen classes | ||
from docstring_gui.screens.result_screen.result_screen import ResultScreen | ||
|
||
|
||
class MainScreen(Screen): | ||
source = ObjectProperty(None) | ||
output = ObjectProperty(None) | ||
config = ObjectProperty(None) | ||
|
||
def create_documentation(self): | ||
#docstring = Docstring(pa_src_path, output_path, config) | ||
# docstring.create_documentation() | ||
|
||
# Spot check on CanvasManifest.json file. If this exists, it should be | ||
# a correct power apps source path | ||
if not os.path.isfile(self.source.text + "CanvasManifest.json"): | ||
self.source.error = True | ||
self.source.helper_text = "Path is not an Power Apps source" | ||
if not self.source.text.endswith("\\"): | ||
self.source.text = self.source.text + "\\" | ||
return | ||
else: | ||
self.source.error = False | ||
self.source.helper_text = "/path/to/src/app/" | ||
|
||
# check if output path is existing | ||
if not os.path.isdir(self.output.text) or self.output.text == "": | ||
self.output.error = True | ||
self.output.helper_text = "Not a directory or not existing" | ||
return | ||
else: | ||
self.output.error = False | ||
self.output.helper_text = "./output/" | ||
|
||
# check config file | ||
if not os.path.isfile(self.config.text): | ||
print(resource_find("config.yaml")) | ||
config_file = resource_find("config.yaml") | ||
else: | ||
config_file = self.config.text | ||
|
||
with open(config_file, "r", encoding='utf8') as file: | ||
config_instance = yaml.safe_load(file) | ||
|
||
# create documentation | ||
# TODO: add try block and show error page if somethin went wrong | ||
docstring = Docstring(self.source.text, self.output.text, config_instance) | ||
output_file_path = docstring.create_documentation() | ||
|
||
# navigate to succeed page | ||
self.manager.transition.direction = "left" | ||
self.manager.current = "result-screen" | ||
|
||
self.manager.get_screen("result-screen").output_file.text = output_file_path | ||
|
||
print("Created") | ||
|
||
def open_github(self): | ||
webbrowser.open_new_tab("https://github.com/sebastian-muthwill/powerapps-docstring") | ||
|
||
def open_new_issue(self): | ||
webbrowser.open_new_tab("https://github.com/sebastian-muthwill/powerapps-docstring/issues/new") | ||
|
||
|
||
class MainApp(MDApp): | ||
def build(self): | ||
Window.size = (1080, 720) | ||
self.theme_cls.theme_style = "Light" # "Light" | ||
#Builder.load_file("./docstring_gui/main.kv") | ||
#self.theme_cls.primary_palette = "Teal" | ||
|
||
def on_start(self): | ||
pass | ||
|
||
|
||
# the ScreenManager handles all screens and changes | ||
# screen change can be called from kv with: | ||
# on_press: | ||
# root.manager.transition.direction = 'left' | ||
# root.manager.current = "result-screen" | ||
sm = ScreenManager() | ||
sm.add_widget(MainScreen(name="main-screen")) | ||
sm.add_widget(ResultScreen(name="result-screen")) | ||
|
||
# needed for pyinstaller onefile exe | ||
if hasattr(sys, '_MEIPASS'): | ||
resource_add_path(os.path.join(sys._MEIPASS)) | ||
|
||
MainApp().run() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<ConfigScreen> | ||
name: "config-screen" | ||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
adaptive_height: False | ||
spacing: 50 | ||
|
||
|
||
MDToolbar: | ||
title: "Configuration " | ||
|
||
|
||
MDLabel: | ||
text: "Create documentation from Power Apps source code." | ||
halign: "center" | ||
valign: "top" | ||
|
||
MDRaisedButton: | ||
text: "create documentation" | ||
background_color : 0, 0, 0, 1 | ||
#padding: 50 | ||
pos_hint: { 'top' : .9, 'right': .9} | ||
on_press: | ||
root.manager.transition.direction = 'right' | ||
root.manager.current = "main-screen" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from kivy.uix.screenmanager import Screen | ||
|
||
|
||
class ConfigScreen(Screen): | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<ResultScreen> | ||
name: "result-screen" | ||
|
||
output_file: output_file | ||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
adaptive_height: False | ||
spacing: 50 | ||
|
||
|
||
MDToolbar: | ||
title: "Power Apps - Docstring" | ||
|
||
MDIconButton: | ||
halign: "right" | ||
pos_hint: { 'center_y' : .5} | ||
icon: "close" | ||
theme_text_color: "Custom" | ||
text_color: "white" | ||
on_press: app.stop() | ||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
size_hint: (0.8, 1) | ||
pos_hint: { 'left' : .9, 'right': .9} | ||
adaptive_height: False | ||
|
||
MDLabel: | ||
text: "" | ||
halign: "center" | ||
|
||
MDIconButton: | ||
pos_hint: { 'center_x' : .5, 'center_y': .5} | ||
icon: "check-decagram" | ||
theme_text_color: "Custom" | ||
text_color: "green" | ||
user_font_size: 128 | ||
|
||
MDLabel: | ||
text: "Documentation created!" | ||
halign: "center" | ||
pos_hint: { 'top' : .1} | ||
|
||
MDFlatButton: | ||
id: output_file | ||
text: "placeholder" | ||
halign: "center" | ||
pos_hint: { 'top' : .1, 'center_x': .5} | ||
#on_press: root.open_file(self.text) | ||
|
||
MDBoxLayout: | ||
orientation: "vertical" | ||
|
||
MDProgressBar: | ||
orientation: "horizontal" | ||
value: 100 | ||
|
||
MDBoxLayout: | ||
orientation: "horizontal" | ||
spacing: 25 | ||
adaptive_height: False | ||
|
||
MDLabel: | ||
text: "" | ||
halign: "left" | ||
pos_hint: { 'center_y' : .5} | ||
|
||
MDFlatButton: | ||
text: "back" | ||
halign: "right" | ||
background_color : 0, 0, 0, 1 | ||
#padding_y: 50 | ||
pos_hint: { 'top' : .8} | ||
on_press: | ||
root.manager.transition.direction = 'right' | ||
root.manager.current = "main-screen" | ||
|
||
MDRaisedButton: | ||
text: "Close" | ||
background_color : 0, 0, 0, 1 | ||
#padding: 50 | ||
pos_hint: { 'top' : .8} | ||
on_press: app.stop() |
Oops, something went wrong.