Skip to content

Commit 4210af0

Browse files
committed
- Changed repository structure.
- Simplified code for GUI version. - Moved screenshots to `"./docs"` folder. Signed-off-by: schlopp96 <[email protected]>
1 parent 915c96d commit 4210af0

File tree

7 files changed

+58
-65
lines changed

7 files changed

+58
-65
lines changed
Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
#& DocuPort - PySimpleGUI v2.3.3b
2+
33
#! Simple GUI Script to open user-specified chapter of the Online-Documentation for PySimpleGUI.
44
#@ =============================== Libraries =============================== @#
55
from random import choice as rChoice
@@ -10,24 +10,23 @@ import PySimpleGUI as sg
1010
#@ ========================================================================= @#
1111
#$ =============================== Functions =============================== $#
1212

13+
__version__ = '2.3.3b'
14+
1315
#> Changes the base color layout each time the app is opened.
14-
theme: str = rChoice(sg.theme_list())
15-
sg.theme(theme)
16+
rtheme: str = rChoice(sg.theme_list())
17+
sg.theme(rtheme)
1618

1719

18-
def open_PSGUI(title: str, url: str) -> bool:
20+
def open_PSGUI(url: str) -> bool:
1921
"""Open a specific PySimpleGUI documentation section in the user's default browser.
2022
23+
---
2124
Parameters
22-
:param title: title of the documentation-section selected.
23-
:type title: str
2425
:param url: URL of the doc-section to open in user's default browser.
2526
:type url: str
2627
:return: opens new page/tab in browser.
2728
:rtype: None
2829
"""
29-
window_MAIN['-TEXT_TOP-'].update(f'Opening Doc Section: {title}')
30-
window_MAIN.refresh()
3130
return open(url, new=2, autoraise=True)
3231

3332

@@ -71,13 +70,13 @@ menu_choices: dict = {
7170
'Multiple Windows':
7271
r'https://pysimplegui.readthedocs.io/en/latest/#running-multiple-windows',
7372
'Debug':
74-
'https://pysimplegui.readthedocs.io/en/latest/#the-pysimplegui-debugger',
73+
r'https://pysimplegui.readthedocs.io/en/latest/#the-pysimplegui-debugger',
7574
'User Settings API':
7675
r'https://pysimplegui.readthedocs.io/en/latest/#user-settings-api',
7776
'Extensions':
7877
r'https://pysimplegui.readthedocs.io/en/latest/#extending-pysimplegui',
7978
'Demo Apps':
80-
'https://pysimplegui.readthedocs.io/en/latest/#demo-programs-applications',
79+
r'https://pysimplegui.readthedocs.io/en/latest/#demo-programs-applications',
8180
'Create .EXE':
8281
r'https://pysimplegui.readthedocs.io/en/latest/#creating-a-windows-exe-file',
8382
'Create .MAC':
@@ -87,12 +86,12 @@ menu_choices: dict = {
8786
#& ========================================================================= &#
8887
#> ================================ Layouts ================================ <#
8988
winlayout = [
90-
[ #* Top Row Text
89+
[
9190
sg.Text('Choose Topic from PySimpleGUI Docs to Browse',
9291
key='-TEXT_TOP-',
9392
justification='Center')
9493
],
95-
[ #* Option Menu & Open URL Buttons
94+
[
9695
sg.OptionMenu(key='-OPTION_MENU-',
9796
values=list(menu_choices.keys()),
9897
default_value=list(menu_choices.keys())[0],
@@ -103,60 +102,58 @@ winlayout = [
103102
tooltip=
104103
'Open selected section from online PySimpleGUI documentation using your default browser.'
105104
)
106-
],
107-
#* Exit Button
108-
[sg.Exit(tooltip='Exit the program.')],
109-
#* Small Text to Display Current Theme
110-
[sg.Text(f'Current Color Theme: {theme}', font='_ 8')],
111-
#[
112-
# sg.Button('Random Theme',
113-
# k='-CHANGE_THEME-',
114-
# tooltip='Click for a random color scheme.',
115-
# font='_ 8')
116-
#]
105+
], [sg.Exit(tooltip='Exit the program.')],
106+
[sg.Text(f'Current Color Theme: {rtheme}', font='_ 8')]
117107
]
118108

119109
#@ Displays Window:
120110
window_MAIN = sg.Window(title='DocuPort - PySimpleGUI',
121111
layout=winlayout,
122112
element_justification='Center',
123113
auto_size_buttons=True,
114+
auto_size_text=True,
124115
keep_on_top=True,
125116
element_padding=(1, 1),
126117
margins=((3, 3)))
118+
119+
127120
#> ========================================================================= <#
128121
#$ ============================= Window Events ============================= $#
129-
while True: #* Main event loop.
130-
event, values = window_MAIN.read()
131-
#print(event,values) #NOTE: #? Enable to print stdout to console. #DEFAULT: -> OFF
132-
133-
#@ Closes Window upon clicking 'x' or sg.Exit() Button.
134-
if event in [sg.WIN_CLOSED, 'Exit']:
135-
break
136-
if event == '-OPEN_URL-':
137-
docs_section: str = values['-OPTION_MENU-']
138-
if docs_section in menu_choices:
139-
choice = menu_choices[docs_section]
140-
141-
#> If chosen option is a valid function:
142-
if callable(choice):
143-
choice() #< Call chosen function.
144-
145-
#* If chosen option is a string variable:
146-
else:
147-
open_PSGUI(title=docs_section, url=choice)
148-
s(1.5)
149-
window_MAIN['-TEXT_TOP-'].update('Done!')
150-
window_MAIN.Refresh()
151-
s(1)
152-
#if event == '-CHANGE_THEME-':
153-
# sg.theme(new_theme=rChoice(sg.theme_list()))
154-
# window_MAIN['-TEXT_TOP-'].update(f'Theme changed to: {theme}!')
155-
# window_MAIN.Finalize()
156-
# s(0.5)
157-
window_MAIN['-TEXT_TOP-'].update(
158-
'Choose Topic from PySimpleGUI Docs to Browse')
159-
160-
#! Close program and release computer resources:
161-
window_MAIN.close()
122+
def main():
123+
while True:
124+
event, values = window_MAIN.read()
125+
print(event, values
126+
) #NOTE: #? Enable to print stdout to console. #DEFAULT: -> OFF
127+
128+
#@ Closes Window upon clicking 'x' or sg.Exit() Button.
129+
if event in [sg.WIN_CLOSED, 'Exit']:
130+
break
131+
if event == '-OPEN_URL-':
132+
docs_section: str = values['-OPTION_MENU-']
133+
if docs_section in menu_choices:
134+
choice = menu_choices[docs_section]
135+
136+
#> If chosen option is a valid function:
137+
if callable(choice):
138+
choice() #< Call chosen function.
139+
140+
#* If chosen option is a string variable:
141+
else:
142+
open_PSGUI(url=choice)
143+
window_MAIN['-TEXT_TOP-'].update(
144+
f'Opening Doc Section: {docs_section}')
145+
window_MAIN.refresh()
146+
s(1.5)
147+
window_MAIN['-TEXT_TOP-'].update('Done!')
148+
window_MAIN.Refresh()
149+
s(1)
150+
window_MAIN['-TEXT_TOP-'].update(
151+
'Choose Topic from PySimpleGUI Docs to Browse')
152+
153+
window_MAIN.close()
154+
155+
156+
if __name__ == '__main__':
157+
main()
158+
162159
#$ ========================================================================= $#

src/DocuPort_PSG_CLI.py renamed to DocuPort_PSG/DocuPort_PSG_CLI.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#> Primitive CLI-Script to Open PySimpleGUI's Online-Documentation Within Your Default Browser. #
33

44
from webbrowser import open as openURL
5-
from loadSequence import load
5+
from PyLoadBar import load
66
from sys import exit as ex
77
from time import sleep as s
88

@@ -230,8 +230,7 @@ def createMAC() -> None:
230230
inputCount += 1
231231
createMAC()
232232
elif menuchoice == '22':
233-
load('Exiting', 'GoodBye!', False)
234-
s(0.2)
233+
load('Exiting', 'GoodBye!', enable_display=False)
235234
ex(0)
236235
else:
237236
inputCount = 0

DocuPort_PSG/__init__.py

Whitespace-only changes.

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# DocuPort - PySimpleGUI
22

3-
> **_A.k.a. DocuPort PSG_**
4-
>
53
> - _A PySimpleGUI Online Documentation Portal_
6-
> - v2.3.3b
74
85
---
96

@@ -31,9 +28,9 @@ As a result, users must go online anytime the documentation is needed, which is
3128
- 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.
3229
- **_That's it!_**
3330

34-
![DocuPort PSG](DP_PSG_screenshot.png)
31+
![DocuPort PSG](./docs/DP_PSG_screenshot.png)
3532

36-
![DocuPort PSG](DP_PSG_screenshot2.png)
33+
![DocuPort PSG](./docs/DP_PSG_screenshot2.png)
3734

3835
---
3936

@@ -47,6 +44,6 @@ As a result, users must go online anytime the documentation is needed, which is
4744
- Simply follow the instructions displayed on screen, and you'll be fine!
4845
- 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)_.
4946

50-
![DocuPort PSG CLI-Version](DP_PSG_CLI_screenshot.png)
47+
![DocuPort PSG CLI-Version](./docs/DP_PSG_CLI_screenshot.png)
5148

5249
---
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)