Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
diStyApps committed Apr 23, 2023
1 parent f9b8ee1 commit 631103f
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 53 deletions.
50 changes: 28 additions & 22 deletions layout/image_carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
from util.creations_data import creations_data
import requests

# url = "http://seait.surge.sh/creations_data.json"

# response = requests.get(url)

# if response.status_code == 200:
# creations_data = response.json()
# else:
# print(f"Failed to fetch JSON data: {response.status_code}")
# creations_data = []

def create_layout(lang_data):
return sg.Frame('',[
[
Expand All @@ -25,42 +15,58 @@ def create_layout(lang_data):
[
sg.Frame('',[
[
sg.Button("@intoinstgram",k="-creator_url-",
expand_x=True,expand_y=False,mouseover_colors=(color.DARK_GRAY,color.PURPLE),button_color=(color.DARK_GRAY,color.PURPLE),pad=(2,2)),
],
[
sg.Button("Send to seait.create@gmail.com",size=(25,None),
expand_x=True,expand_y=False,mouseover_colors=(color.PURPLE,color.DARK_GRAY),button_color=(color.PURPLE,color.DARK_GRAY),pad=(2,2),
sg.Button("",k="-creator_url-",visible=False),
sg.Button("",k="-title-",
expand_x=True,expand_y=False,mouseover_colors=(color.DARK_GRAY,color.PURPLE),button_color=(color.DARK_GRAY,color.PURPLE),pad=(2,2)),
sg.Button("Send to seait.create@gmail.com",
expand_x=False,expand_y=False,mouseover_colors=(color.PURPLE,color.DARK_GRAY),button_color=(color.PURPLE,color.DARK_GRAY),pad=(2,2),
disabled=True,disabled_button_color=(color.PURPLE,color.DARK_GRAY)),
],
],
[
sg.Image(creations_data[0]['creation'],visible=True,key='-image_carousel-',background_color=color.DARK_GRAY,expand_x=True,expand_y=False,pad=(2,2)),
sg.Image(visible=True,enable_events=True,key='-image_carousel-',background_color=color.GRAY_1111,expand_x=True,expand_y=False,pad=(2,2)),
],
],expand_x=False,expand_y=False,border_width=0,size=(550,350),relief=sg.RELIEF_FLAT,element_justification="c",background_color=color.PURPLE)
],expand_x=True,expand_y=False,border_width=0,size=(600,400),relief=sg.RELIEF_FLAT,element_justification="l",background_color=color.GRAY_1111)
],
],expand_x=True,expand_y=False,border_width=0,relief=sg.RELIEF_FLAT,element_justification="c",background_color=color.GRAY_1111)

import random

def update_image(window, interval=5):
try:
creation_index = 0
creation_index = random.randint(0, len(creations_data) - 1)
while not window["-image_carousel-"].metadata:
creation = creations_data[creation_index]
# window['-image_carousel-'].update(visible=True)

window['-image_carousel-'].update(creation["creation"])
window['-creator_url-'].update(creation["url"])
window['-title-'].update(f'{creation["title"]} - {creation["creator"]}')

creation_index = (creation_index + 1) % len(creations_data)
time.sleep(interval)
except:
pass


def start(window,interval):
Thread(target=update_image, args=(window,interval,), daemon=True).start()

def stop_carousel(window):
window["-image_carousel-"].metadata = True

def buttons(window,event):
if event == "-creator_url-":
webbrowser.open(window[event].GetText())
if event == "-title-":
webbrowser.open(window['-creator_url-'].GetText())
# if event == "-image_carousel-":
# webbrowser.open(window['-creator_url-'].GetText())


# url = "http://seait.surge.sh/creations_data.json"

# response = requests.get(url)

# if response.status_code == 200:
# creations_data = response.json()
# else:
# print(f"Failed to fetch JSON data: {response.status_code}")
# creations_data = []
7 changes: 5 additions & 2 deletions layout/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import subprocess
import time
import layout.image_carousel as image_carousel
import util.json_tools as jt

python = "Python"
git = "Git"
Expand Down Expand Up @@ -79,8 +80,10 @@ def create_layout(lang_data):
],expand_x=True,expand_y=False,visible=False,k=LOCAL_CHECK_PYTHON_PATH_LBL,border_width=5,pad=(10,10),relief=sg.RELIEF_FLAT,element_justification="l",background_color=color.DARK_GRAY)
],
[
# image_carousel.create_layout(lang_data),
],
image_carousel.create_layout(lang_data),
]
if jt.load_preference('show_creations_carousel') or jt.load_preference('show_creations_carousel')==None else []

]
return layout

Expand Down
38 changes: 21 additions & 17 deletions layout/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
import util.support as support
import util.repos as repos
import util.icons as ic
import util.json_tools as jt

def create_layout(lang_data,languages):

show_creations_carousel = jt.load_preference('show_creations_carousel')
if show_creations_carousel == None:
show_creations_carousel = True
native_name = lang_data[LOCAL_NATIVE]

layout = [
Expand All @@ -25,26 +30,25 @@ def create_layout(lang_data,languages):

],expand_x=False,expand_y=False,size=(500,100),border_width=5,pad=(5,5),relief=sg.RELIEF_FLAT,element_justification="l",background_color=color.DARK_GRAY)
],
# [
# sg.Frame('',[
# [
# sg.Image(data=ic.args,background_color=color.DARK_GRAY),
# sg.Text("Your creations",font=FONT,text_color=color.LIGHT_GRAY,background_color=color.DARK_GRAY),
# ],
# [
# sg.Checkbox("Show 'Your creations' carousel on startup",
# default=True,text_color=color.DIM_BLUE,background_color=color.GRAY,
# k='-SHOW_CREATIONS_CAROUSEL-',enable_events=True, expand_x=True, expand_y=False)
# ],

# ],expand_x=False,expand_y=False,size=(500,100),border_width=5,pad=(5,5),relief=sg.RELIEF_FLAT,element_justification="l",background_color=color.DARK_GRAY)

# ],
[
sg.Frame('',[
[
sg.Image(data=ic.args,background_color=color.DARK_GRAY),
sg.Text("Your creations",font=FONT,text_color=color.LIGHT_GRAY,background_color=color.DARK_GRAY),
],
[
sg.Checkbox("Show 'Your creations' carousel on startup",
default=show_creations_carousel,text_color=color.DIM_BLUE,background_color=color.GRAY,
k='-SHOW_CREATIONS_CAROUSEL-',enable_events=True, expand_x=True, expand_y=False)
],
],expand_x=False,expand_y=False,size=(500,100),border_width=5,pad=(5,5),relief=sg.RELIEF_FLAT,element_justification="l",background_color=color.DARK_GRAY)
],
],expand_x=True,expand_y=True,border_width=0,pad=(10,10),relief=sg.RELIEF_FLAT,element_justification="l")
],
]
return layout

def events(event):
def events(event,values):
if event == '-SHOW_CREATIONS_CAROUSEL-':
print(event)
print(values['-SHOW_CREATIONS_CAROUSEL-'])
jt.save_preference('show_creations_carousel',values['-SHOW_CREATIONS_CAROUSEL-'])
Binary file added media/preview/0.1.1/1_0.1.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/preview/0.1.1/2_0.1.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/preview/0.1.1/3_0.1.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 6 additions & 10 deletions seait.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def main():
# sg.Column(system_stats_layout, key=SYSTEM_INFO_COL, element_justification='c', expand_x=True,expand_y=True,visible=False),
],
]]

window = sg.Window(APP_TITLE,layout,finalize=True,size=(window_width,849),ttk_theme='alt', resizable=True,enable_close_attempted_event=False,background_color=color.GRAY_9900,icon=ic.icon3)

#region nav
Expand Down Expand Up @@ -107,18 +106,15 @@ def set_project_path(window, id_number, input_project_path,trigger_event=True):
requirements_layout.git_event_handler(window,lang_data)
requirements_layout.python_event_handler(window,lang_data)

# image_carousel.start(window,4)
# image_carousel.stop_carousel(window)
if jt.load_preference('show_creations_carousel') or jt.load_preference('show_creations_carousel')==None:
image_carousel.start(window,5)

while True:
event, values = window.read()

if event == sg.WIN_CLOSED:
break

# print("INIT",event,values["INIT"])
pass


if event == SET_LANGUAGE:
jt.save_preference(PREF_SELECTED_LANG,localizations.get_language_by_native(values[SET_LANGUAGE]))
reopen_window(window)
Expand All @@ -127,7 +123,8 @@ def set_project_path(window, id_number, input_project_path,trigger_event=True):
navigation_layout.handle_tab_event(event, nav_elements, nav_btn_elements, nav_active_color, nav_inactive_color)

if event.startswith(SELECT_APP) and event.endswith("_btn-"):
# image_carousel.stop_carousel(window)
if jt.load_preference('show_creations_carousel') or jt.load_preference('show_creations_carousel') == None:
image_carousel.stop_carousel(window)

id_number = project_util.get_project_id(event)
# print("select_app_",event)
Expand Down Expand Up @@ -283,8 +280,7 @@ def set_project_path(window, id_number, input_project_path,trigger_event=True):

about_layout.events(event)
image_carousel.buttons(window,event)
settings_layout.events(event)

settings_layout.events(event,values)


if __name__ == '__main__':
Expand Down
35 changes: 35 additions & 0 deletions util/creations_data.py

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions util/json_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def read_json_file_full_path(filename_path):
return x

def save_preference(preference_name,preference_value):
# print('save_preference',preference_name,preference_value)
try:
file = read_json_file(PREFERENCES_FILE_NAME)
file[preference_name]=preference_value
Expand Down Expand Up @@ -78,9 +79,10 @@ def load_preference(preference_key):
preference_value=preference[preference_key]
return preference_value
except KeyError as e:
print('setup','preference not set yet',preference_key)
# print('setup','preference not set yet',preference_key)
pass

# def save_preference(values,preference_key):
# preference_value = values[f'-{preference_key}-']
# # print(save_preference,'preference_value',preference_value)
# save_preference(preference_key,preference_value)
# save_preference(preference_key,preference_value)

0 comments on commit 631103f

Please sign in to comment.