-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--- - Fixed bug causing incorrect cwd to be set. - Enhanced app logging. - Changed `PyLoadBar` dependency version to 0.1.0 - Changed all `PyLoadBar` use cases to conform to new version params. - Additions to docstrings. - Added comments to source code. Signed-off-by: schlopp96 <[email protected]>
- Loading branch information
Showing
7 changed files
with
86 additions
and
60 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,48 +1,63 @@ | ||
from random import uniform | ||
from time import sleep | ||
|
||
from PyFiTransfer.appevents.events import events, exit_program, logger | ||
from PyFiTransfer.appgui.gui import sg, window | ||
|
||
|
||
def GUI_loop() -> None: | ||
"""GUI program event loop. | ||
"""Main GUI loop. | ||
- Starts processing of window events. | ||
--- | ||
:return: run GUI program. | ||
:return: program window | ||
:rtype: None | ||
""" | ||
|
||
while True: | ||
event, vals = window.read() | ||
event, vals = window.read() # Get events from GUI window | ||
|
||
logger.info(f'{event} : {vals}') | ||
logger.info(f'{event} : {vals}') # Log events | ||
|
||
if event in [sg.WIN_CLOSED, 'Exit']: | ||
if event in [sg.WIN_CLOSED, 'Exit']: # Exit events | ||
break | ||
|
||
if event == '-Transfer-': | ||
if event == '-Transfer-': # Process Transfer button event | ||
|
||
# No source directory entered | ||
if len(vals['-SourceFolderInput-']) < 1: | ||
sg.Popup('Make sure all fields are filled out!') | ||
continue | ||
|
||
# No target directory entered | ||
if len(vals['-TargetFolderInput-']) < 1: | ||
sg.Popup('Make sure all fields are filled out!') | ||
continue | ||
|
||
# No file extension entered | ||
if len(vals['-FileExtensionInput-']) < 1: | ||
sg.Popup('Make sure all fields are filled out!') | ||
continue | ||
|
||
# Start Transfer | ||
transfer: int = events.transfer(vals['-SourceFolderInput-'], | ||
vals['-TargetFolderInput-'], | ||
vals['-FileExtensionInput-'], | ||
gui=True) | ||
if transfer > 0: | ||
for _ in range(50): | ||
|
||
if transfer > 0: # Enable progress bar | ||
for _ in range(25): | ||
window.refresh() | ||
sleep(uniform(0.01, 0.25)) | ||
sleep(uniform(0.01, 0.2)) | ||
window['-ProgressBar-'].update(_ + 1) | ||
print(f'Successfully transferred {transfer} files!\n') | ||
window['-ProgressBar-'].update(0) | ||
|
||
window.close() | ||
print(f'Successfully transferred {transfer} files!\n' | ||
) # Log success | ||
|
||
window['-ProgressBar-'].update(0) # Reset progress bar | ||
|
||
window.close() # Close window and return system resources | ||
|
||
return exit_program.success() | ||
return exit_program.success() # Return successful exit status |
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
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
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
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
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,3 +1,3 @@ | ||
PyLoadBar>=0.0.8 | ||
PyLoadBar>=0.1.0 | ||
PySimpleGUI>=4.60.1 | ||
setuptools>=58.1.0 |
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