Skip to content

Commit

Permalink
Fix Bugs and add Clipboard functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ScheerleJo committed Jul 1, 2022
1 parent c413bd0 commit 1922290
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 31 additions & 14 deletions scripts/gui.py
Original file line number Diff line number Diff line change
@@ -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"""
Expand All @@ -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:
Expand Down Expand Up @@ -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= [
[
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -173,4 +190,4 @@ def createContent():
else:
visibleElements(False)

window.close()
window.close()
4 changes: 2 additions & 2 deletions scripts/thumbGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from icalendar import Calendar
from datetime import datetime, timedelta
import os
import error
import message

fontSize1 = 90
fontSize2 = 90
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 1922290

Please sign in to comment.