Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Update 3.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszPerczak committed Mar 12, 2020
1 parent 7de5457 commit a7d568b
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 64 deletions.
99 changes: 47 additions & 52 deletions src/Sounder3.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
music_bitrate: ClassVar = StringVar()
debug_info: ClassVar = StringVar()
config: Dict = {}
version: str = "3.1.6"
version: str = "3.1.7"
played_songs: List = []
songs: List = []
current_song: int = 0
Expand Down Expand Up @@ -82,6 +82,7 @@ def dump(error_obj: ClassVar) -> None:
show(main_error_frame)
logging.error(error_obj, exc_info=True)


# end


Expand Down Expand Up @@ -462,6 +463,8 @@ def apply_settings() -> bool:
main_window.attributes('-alpha', 0.8)
if config["debug"]:
main_window.bind('<F12>', debug)
if config["update"]:
Thread(target=check_for_update, daemon=True).start()
logging.basicConfig(filename=sounder_dir + "\\errors.log", level=logging.ERROR)
except Exception as e:
dump(e)
Expand All @@ -482,17 +485,14 @@ def init_mixer() -> bool:
dump(e)
return False
try:
status_thread = Thread(target=song_stats, )
status_thread.daemon = True
status_thread.start()
Thread(target=song_stats, daemon=True).start()
except Exception as e:
dump(e)
return False
return True


def init_player() -> None:
global config
try:
if load_settings():
verify_settings()
Expand All @@ -503,8 +503,6 @@ def init_player() -> None:
if init_music():
refresh_window()
show(main_player_frame)
if config["update"]:
main_window.after(10, check_for_update)
except Exception as e:
dump(e)

Expand Down Expand Up @@ -746,50 +744,47 @@ def show(window) -> bool:


def check_for_update() -> None:
global version, sounder_dir
if os.path.isfile(sounder_dir + "\\Updater.exe"):
try:
server_version = get(
"https://raw.githubusercontent.com/losek1/Sounder3/master/updates/version.txt").text.strip()
global version, sounder_dir, config
try:
if os.path.isfile(sounder_dir + "\\Updater.exe"):
server_version = get("https://raw.githubusercontent.com/losek1/Sounder3/master/updates/version.txt").text
if int(version.replace(".", "")) < int(server_version.replace(".", "")):
update_window: ClassVar = Toplevel()
update_window.withdraw()
update_window.title("Update Available")
update_window.geometry(
'400x200+{0}+{1}'.format(main_window.winfo_x() + 200, main_window.winfo_y() + 150))
update_window.iconbitmap(sounder_dir + "\\icon.ico")
update_window.grab_set()
update_window.resizable(width=FALSE, height=FALSE)
update_label: ClassVar = ttk.Label(update_window, text="New update is available", anchor="center"
, font='Bahnschrift 14')
current_version_label: ClassVar = ttk.Label(update_window, text="Current version: \n" + str(version)
, anchor="center", font='Bahnschrift 12', justify="center")
new_version_label: ClassVar = ttk.Label(update_window, text="New version: \n" + str(server_version)
, anchor="center", font='Bahnschrift 12', justify="center")
update_now_button: ClassVar = ttk.Button(update_window, text="Update now", takefocus=0, cursor="hand2"
, command=lambda: close("update"))
update_later_button: ClassVar = ttk.Button(update_window, text="Update later", takefocus=0,
cursor="hand2"
, command=lambda: update_window.destroy())
update_label.place(relx=0, rely=0.02, relwidth=1)
current_version_label.place(relx=0, rely=0.3, relwidth=0.5)
new_version_label.place(relx=0.5, rely=0.3, relwidth=0.5)
update_now_button.place(relx=0.5, rely=0.828, relwidth=0.5)
update_later_button.place(relx=0, rely=0.828, relwidth=0.5)
if config["theme"] == "light":
update_window.configure(background="#fff")
update_label.configure(background="#fff", foreground="#000")
current_version_label.configure(background="#fff", foreground="#000")
new_version_label.configure(background="#fff", foreground="#000")
else:
update_window.configure(background="#000")
update_label.configure(background="#000", foreground="#fff")
current_version_label.configure(background="#000", foreground="#fff")
new_version_label.configure(background="#000", foreground="#fff")
update_window.deiconify()
update_window.mainloop()
except Exception as e:
dump(e)
main_window.after_idle(update_choice)
else:
config["update"] = False
except:
pass


def update_choice():
try:
update_window: ClassVar = Toplevel()
update_window.withdraw()
update_window.grab_set()
update_window.title("Update Available")
update_window.geometry(f"375x100+{main_window.winfo_x() + 215}+{main_window.winfo_y() + 200}")
update_window.iconbitmap(sounder_dir + "\\icon.ico")
update_window.resizable(width=FALSE, height=FALSE)
choice_label: ClassVar = ttk.Label(update_window, text="A new version of Sounder is available.\n"
"Would you like to install it?", font='Bahnschrift 11',
anchor=CENTER, justify=CENTER)
choice_install_button: ClassVar = ttk.Button(update_window, text="UPDATE NOW", cursor="hand2", takefocus=False,
command=lambda: close("update"))
choice_exit_button: ClassVar = ttk.Button(update_window, text="UPDATE LATER", cursor="hand2", takefocus=False,
command=lambda: update_window.destroy())
choice_label.place(relx=0.5, rely=0.1, anchor="n")
choice_install_button.place(relx=0.7, rely=0.6, relwidth=0.35, anchor="n")
choice_exit_button.place(relx=0.3, rely=0.6, relwidth=0.35, anchor="n")
if config["theme"] == "light":
update_window.configure(background="#fff")
choice_label.configure(background="#fff", foreground="#000")
else:
update_window.configure(background="#000")
choice_label.configure(background="#000", foreground="#fff")
update_window.deiconify()
update_window.mainloop()
except Exception as e:
dump(e)


def close(action: str = "close") -> None:
Expand Down Expand Up @@ -845,7 +840,7 @@ def toggle_theme() -> None:
try:
show(main_init_frame)
main_init_frame.update()
sleep(0.25)
sleep(0.1)
if config["theme"] == "light":
config["theme"] = "dark"
elif config["theme"] == "dark":
Expand Down Expand Up @@ -1204,7 +1199,7 @@ def changelog():
# end
# main
show(main_init_frame)
init_thread = Thread(target=init_player, daemon=True).start()
init_thread: ClassVar = Thread(target=init_player, daemon=True).start()
# end
left_player_music_list.bind("<<ListboxSelect>>", list_box_play)
main_window.protocol("WM_DELETE_WINDOW", close)
Expand Down
Binary file modified src/Updater.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
updater_window.configure(background="#fff")
# images
sounder_logo = PhotoImage(file="logo_1.png")
update_img: ClassVar = PhotoImage(file=sounder_dir + "\\download.png")
update_img: ClassVar = PhotoImage(file=sounder_dir + "\\download_light.png")
# theme
updater_theme = ttk.Style()
updater_theme.theme_use('clam')
Expand Down
2 changes: 1 addition & 1 deletion src/cfg.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"refresh_time": 1.0, "theme": "dark", "version": "3.1.5", "transition_duration": 0.0, "gtr_buffer": false, "last_song": "June.mp3", "continue": false, "fade": false, "mode": "s_p", "debug": true, "path": "C:/Users/Mateusz/Music", "update": true, "fst_buffer": false}
{"refresh_time": 1.0, "theme": "light", "version": "3.1.5", "transition_duration": 0.0, "gtr_buffer": false, "last_song": "Restart.mp3", "continue": false, "fade": false, "mode": "s_p", "debug": true, "path": "C:/Users/Mateusz/Music", "update": false, "fst_buffer": false}
10 changes: 1 addition & 9 deletions src/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
+Added new updater
+Some code optimizations.
~Changed the way how shuffle play works.
+Added transition timer.
+Added history of shuffle play that can be accessed with the back button when shuffle play is selected.
~Changed the update function.
~Changed the debug menu.
+Added animation for changing the theme.
~Fixed update window not showing up.
~Fixed update window that was causing Sounder to hang up.

Binary file added src/download_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from tkinter import *

import threading # should use the threading module instead!
import Queue

import os


class ThreadSafeConsole(Text):
def __init__(self, master, **options):
Text.__init__(self, master, **options)
self.queue = Queue.Queue()
self.update_me()

def write(self, line):
self.queue.put(line)

def clear(self):
self.queue.put(None)

def update_me(self):
try:
while 1:
line = self.queue.get_nowait()
if line is None:
self.delete(1.0, END)
else:
self.insert(END, str(line))
self.see(END)
self.update_idletasks()
except Queue.Empty:
pass
self.after(100, self.update_me)


# this function pipes input to an widget
def pipeToWidget(input, widget):
widget.clear()
while 1:
line = input.readline()
if not line:
break
widget.write(line)


def funcThread(widget):
input = os.popen('dir', 'r')
pipeToWidget(input, widget)


# uber-main
root = Tk()
widget = ThreadSafeConsole(root)
widget.pack(side=TOP, expand=YES, fill=BOTH)
threading.start_new(funcThread, (widget,))
threading.start_new(funcThread, (widget,))
threading.start_new(funcThread, (widget,))
threading.start_new(funcThread, (widget,))
threading.start_new(funcThread, (widget,))
root.mainloop()
2 changes: 1 addition & 1 deletion updates/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.6
3.1.7

0 comments on commit a7d568b

Please sign in to comment.