From 1922290160e893a3c99ca2e07c1da33afd288e14 Mon Sep 17 00:00:00 2001 From: Josia Date: Fri, 1 Jul 2022 21:47:14 +0200 Subject: [PATCH] Fix Bugs and add Clipboard functionality --- README.md | 2 -- scripts/gui.py | 45 +++++++++++++++++++++++++++++++-------------- scripts/thumbGen.py | 4 ++-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b4f0df8..c6197ee 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ If you want to use its full potential, you can download the .ics file [here](htt ## ToDo - [ ] Look for possibility to fetch calendar data from the website directly instead of having to download the calendar -- [x] Create Logic for Title and Video-Description. -- [ ] fix sync Bug with Dropdown-Menu ## Developer diff --git a/scripts/gui.py b/scripts/gui.py index ff609c4..7bd06ba 100644 --- a/scripts/gui.py +++ b/scripts/gui.py @@ -1,11 +1,12 @@ -from ast import Return import PySimpleGUI as sg import thumbGen as tg +import clipboard + dropValues = tg.listSundays() current = tg.nextSunday() imgSource = './Images/cache/Thumbnail.png' - +activeTab = '-THUMBNAIL-' def visibleElements(visible:bool): """Handle visibility for the 'special Event' functionality""" @@ -21,8 +22,10 @@ def synconizeTabs(): """Handle the syncronisation between the two tabs for common elements""" components = [ '-DROPDOWN', '-LESSON', '-SP_DATE', '-SP_EVENT'] for element in components: - window[element + '-'].update(value=values[element + '_CONTENT-']) - window[element + '_CONTENT-'].update(value=values[element + '-']) + if activeTab == '-THUMBNAIL-': + window[element + '_CONTENT-'].update(value=values[element + '-']) + else: + window[element + '-'].update(value=values[element + '_CONTENT-']) def createContent(): if values['-SPECIAL-'] == True: @@ -92,11 +95,13 @@ def createContent(): ] content_preview_layout = [ [ - sg.Text('Titel:', background_color='#303030'), + sg.Text('Titel: ', background_color='#303030'), sg.In(default_text='', key='-TITLE-', size=(66, 1)) ], + [sg.Button('In die Zwischenablage kopieren', key='-COPY_TITLE-', size=(63, ), button_color='#640000')], [sg.Text('Videobeschreibung:', background_color='#303030')], - [sg.Multiline(default_text='', key='-DESCRIPTION-', size=(70, 10), sbar_background_color='#640000')] + [sg.Multiline(default_text='', key='-DESCRIPTION-', size=(70, 10), sbar_background_color='#640000')], + [sg.Button('In die Zwischenablage kopieren', key='-COPY_DESCRIPTION-', size=(63, 2), button_color='#640000')] ] layout= [ [ @@ -108,16 +113,16 @@ def createContent(): sg.VSeparator(), sg.Column(layout = preview_column, background_color='#303030'), ] - ], background_color='#303030'), + ], background_color='#303030', key='-THUMBNAIL-'), sg.Tab('Video Content', [ [ sg.Column(layout=content_properties_layout, background_color='#303030', vertical_alignment='top'), sg.VSeperator(), sg.Column(layout=content_preview_layout, background_color='#303030', vertical_alignment='top'), ] - ], background_color='#303030') + ], background_color='#303030', key='-CONTENT-') ] - ], key='-group1-', tab_location='top', selected_title_color='#640000', background_color='#282828', border_width=1, tab_background_color='#444444', selected_background_color='#444444', title_color='#FFFFFF') + ], key='-GROUP-', tab_location='top', selected_title_color='#640000', background_color='#282828', border_width=1, tab_background_color='#444444', selected_background_color='#444444', title_color='#FFFFFF', enable_events=True) ] ] # endregion @@ -133,15 +138,14 @@ def createContent(): # Main-Loop while True: event, values = window.read() - - spDate = values['-SP_DATE-'] - spName = values['-SP_EVENT-'] - synconizeTabs() if event == sg.WIN_CLOSED: break + spDate = values['-SP_DATE-'] + spName = values['-SP_EVENT-'] + match event: case '-CREATE-': if values['-SPECIAL-'] == True: @@ -157,6 +161,19 @@ def createContent(): case '-CREATE_CONTENT-': createContent() + case '-GROUP-': + activeTab = values['-GROUP-'] + if values['-SPECIAL-'] == True: + tg.updateThumbnail(values, [spDate, spName], show = False) + else: + tg.updateThumbnail(values, False) + window['-IMAGE-'].update(imgSource, subsample=3) + + case '-COPY_DESCRIPTION-': + clipboard.copy(values['-DESCRIPTION-']) + + case '-COPY_TITLE-': + clipboard.copy(values['-TITLE-']) case '-DROPDOWN-': tg.updateThumbnail(values, False) @@ -173,4 +190,4 @@ def createContent(): else: visibleElements(False) -window.close() +window.close() \ No newline at end of file diff --git a/scripts/thumbGen.py b/scripts/thumbGen.py index a45da3a..6c02064 100644 --- a/scripts/thumbGen.py +++ b/scripts/thumbGen.py @@ -3,7 +3,7 @@ from icalendar import Calendar from datetime import datetime, timedelta import os -import error +import message fontSize1 = 90 fontSize2 = 90 @@ -87,7 +87,7 @@ def getName(date): g.close() return name g.close() - error.message('No matching result was found! Check if the Calendar is up to date.') + message.error('No matching result was found! Check if the Calendar is up to date.') def listSundays() -> list: """Create a list for the Dropdown-menu in the Gui."""