Skip to content

Commit

Permalink
- Changed repository structure.
Browse files Browse the repository at this point in the history
- Simplified code for GUI version.
- Moved screenshots to `"./docs"` folder.

Signed-off-by: schlopp96 <[email protected]>
  • Loading branch information
schlopp96 committed Apr 6, 2022
1 parent 915c96d commit 4210af0
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 65 deletions.
109 changes: 53 additions & 56 deletions src/DocuPort_PSG.pyw → DocuPort_PSG/DocuPort_PSG.pyw
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
#& DocuPort - PySimpleGUI v2.3.3b

#! Simple GUI Script to open user-specified chapter of the Online-Documentation for PySimpleGUI.
#@ =============================== Libraries =============================== @#
from random import choice as rChoice
Expand All @@ -10,24 +10,23 @@ import PySimpleGUI as sg
#@ ========================================================================= @#
#$ =============================== Functions =============================== $#

__version__ = '2.3.3b'

#> Changes the base color layout each time the app is opened.
theme: str = rChoice(sg.theme_list())
sg.theme(theme)
rtheme: str = rChoice(sg.theme_list())
sg.theme(rtheme)


def open_PSGUI(title: str, url: str) -> bool:
def open_PSGUI(url: str) -> bool:
"""Open a specific PySimpleGUI documentation section in the user's default browser.
---
Parameters
:param title: title of the documentation-section selected.
:type title: str
:param url: URL of the doc-section to open in user's default browser.
:type url: str
:return: opens new page/tab in browser.
:rtype: None
"""
window_MAIN['-TEXT_TOP-'].update(f'Opening Doc Section: {title}')
window_MAIN.refresh()
return open(url, new=2, autoraise=True)


Expand Down Expand Up @@ -71,13 +70,13 @@ menu_choices: dict = {
'Multiple Windows':
r'https://pysimplegui.readthedocs.io/en/latest/#running-multiple-windows',
'Debug':
'https://pysimplegui.readthedocs.io/en/latest/#the-pysimplegui-debugger',
r'https://pysimplegui.readthedocs.io/en/latest/#the-pysimplegui-debugger',
'User Settings API':
r'https://pysimplegui.readthedocs.io/en/latest/#user-settings-api',
'Extensions':
r'https://pysimplegui.readthedocs.io/en/latest/#extending-pysimplegui',
'Demo Apps':
'https://pysimplegui.readthedocs.io/en/latest/#demo-programs-applications',
r'https://pysimplegui.readthedocs.io/en/latest/#demo-programs-applications',
'Create .EXE':
r'https://pysimplegui.readthedocs.io/en/latest/#creating-a-windows-exe-file',
'Create .MAC':
Expand All @@ -87,12 +86,12 @@ menu_choices: dict = {
#& ========================================================================= &#
#> ================================ Layouts ================================ <#
winlayout = [
[ #* Top Row Text
[
sg.Text('Choose Topic from PySimpleGUI Docs to Browse',
key='-TEXT_TOP-',
justification='Center')
],
[ #* Option Menu & Open URL Buttons
[
sg.OptionMenu(key='-OPTION_MENU-',
values=list(menu_choices.keys()),
default_value=list(menu_choices.keys())[0],
Expand All @@ -103,60 +102,58 @@ winlayout = [
tooltip=
'Open selected section from online PySimpleGUI documentation using your default browser.'
)
],
#* Exit Button
[sg.Exit(tooltip='Exit the program.')],
#* Small Text to Display Current Theme
[sg.Text(f'Current Color Theme: {theme}', font='_ 8')],
#[
# sg.Button('Random Theme',
# k='-CHANGE_THEME-',
# tooltip='Click for a random color scheme.',
# font='_ 8')
#]
], [sg.Exit(tooltip='Exit the program.')],
[sg.Text(f'Current Color Theme: {rtheme}', font='_ 8')]
]

#@ Displays Window:
window_MAIN = sg.Window(title='DocuPort - PySimpleGUI',
layout=winlayout,
element_justification='Center',
auto_size_buttons=True,
auto_size_text=True,
keep_on_top=True,
element_padding=(1, 1),
margins=((3, 3)))


#> ========================================================================= <#
#$ ============================= Window Events ============================= $#
while True: #* Main event loop.
event, values = window_MAIN.read()
#print(event,values) #NOTE: #? Enable to print stdout to console. #DEFAULT: -> OFF

#@ Closes Window upon clicking 'x' or sg.Exit() Button.
if event in [sg.WIN_CLOSED, 'Exit']:
break
if event == '-OPEN_URL-':
docs_section: str = values['-OPTION_MENU-']
if docs_section in menu_choices:
choice = menu_choices[docs_section]

#> If chosen option is a valid function:
if callable(choice):
choice() #< Call chosen function.

#* If chosen option is a string variable:
else:
open_PSGUI(title=docs_section, url=choice)
s(1.5)
window_MAIN['-TEXT_TOP-'].update('Done!')
window_MAIN.Refresh()
s(1)
#if event == '-CHANGE_THEME-':
# sg.theme(new_theme=rChoice(sg.theme_list()))
# window_MAIN['-TEXT_TOP-'].update(f'Theme changed to: {theme}!')
# window_MAIN.Finalize()
# s(0.5)
window_MAIN['-TEXT_TOP-'].update(
'Choose Topic from PySimpleGUI Docs to Browse')

#! Close program and release computer resources:
window_MAIN.close()
def main():
while True:
event, values = window_MAIN.read()
print(event, values
) #NOTE: #? Enable to print stdout to console. #DEFAULT: -> OFF

#@ Closes Window upon clicking 'x' or sg.Exit() Button.
if event in [sg.WIN_CLOSED, 'Exit']:
break
if event == '-OPEN_URL-':
docs_section: str = values['-OPTION_MENU-']
if docs_section in menu_choices:
choice = menu_choices[docs_section]

#> If chosen option is a valid function:
if callable(choice):
choice() #< Call chosen function.

#* If chosen option is a string variable:
else:
open_PSGUI(url=choice)
window_MAIN['-TEXT_TOP-'].update(
f'Opening Doc Section: {docs_section}')
window_MAIN.refresh()
s(1.5)
window_MAIN['-TEXT_TOP-'].update('Done!')
window_MAIN.Refresh()
s(1)
window_MAIN['-TEXT_TOP-'].update(
'Choose Topic from PySimpleGUI Docs to Browse')

window_MAIN.close()


if __name__ == '__main__':
main()

#$ ========================================================================= $#
5 changes: 2 additions & 3 deletions src/DocuPort_PSG_CLI.py → DocuPort_PSG/DocuPort_PSG_CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#> Primitive CLI-Script to Open PySimpleGUI's Online-Documentation Within Your Default Browser. #

from webbrowser import open as openURL
from loadSequence import load
from PyLoadBar import load
from sys import exit as ex
from time import sleep as s

Expand Down Expand Up @@ -230,8 +230,7 @@ def createMAC() -> None:
inputCount += 1
createMAC()
elif menuchoice == '22':
load('Exiting', 'GoodBye!', False)
s(0.2)
load('Exiting', 'GoodBye!', enable_display=False)
ex(0)
else:
inputCount = 0
Expand Down
Empty file added DocuPort_PSG/__init__.py
Empty file.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# DocuPort - PySimpleGUI

> **_A.k.a. DocuPort PSG_**
>
> - _A PySimpleGUI Online Documentation Portal_
> - v2.3.3b
---

Expand Down Expand Up @@ -31,9 +28,9 @@ As a result, users must go online anytime the documentation is needed, which is
- To exit or close the app, simply click the "X" at the top of the screen, or the "Exit" button at the bottom of the window.
- **_That's it!_**

![DocuPort PSG](DP_PSG_screenshot.png)
![DocuPort PSG](./docs/DP_PSG_screenshot.png)

![DocuPort PSG](DP_PSG_screenshot2.png)
![DocuPort PSG](./docs/DP_PSG_screenshot2.png)

---

Expand All @@ -47,6 +44,6 @@ As a result, users must go online anytime the documentation is needed, which is
- Simply follow the instructions displayed on screen, and you'll be fine!
- The URL menu is **re-printed to the console every 5 user-inputs, or if user-input is anything that is not between [1-22]** _(e.g. if an incorrect input is entered)_.

![DocuPort PSG CLI-Version](DP_PSG_CLI_screenshot.png)
![DocuPort PSG CLI-Version](./docs/DP_PSG_CLI_screenshot.png)

---
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 4210af0

Please sign in to comment.