Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Syng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Stahl
Syng
Commits
4ce5df41
Commit
4ce5df41
authored
11 months ago
by
Christoph Stahl
Browse files
Options
Downloads
Patches
Plain Diff
Reworked tk gui in preparation for migration to qt
parent
e2655a48
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
syng/gui.py
+54
-63
54 additions, 63 deletions
syng/gui.py
with
54 additions
and
63 deletions
syng/gui.py
+
54
−
63
View file @
4ce5df41
...
...
@@ -5,7 +5,6 @@ from datetime import datetime, date, time
import
os
import
builtins
from
functools
import
partial
from
sys
import
argv
,
stderr
from
typing
import
TYPE_CHECKING
,
Any
,
Optional
import
webbrowser
import
multiprocessing
...
...
@@ -296,6 +295,7 @@ class GeneralConfig(OptionFrame):
)
self
.
add_date_time_option
(
"
last_song
"
,
"
Time of last song
"
,
config
[
"
last_song
"
])
self
.
add_string_option
(
"
preview_duration
"
,
"
Preview Duration
"
,
config
[
"
preview_duration
"
])
self
.
add_string_option
(
"
key
"
,
"
Key for server
"
,
config
[
"
key
"
])
def
get_config
(
self
)
->
dict
[
str
,
Any
]:
config
=
super
().
get_config
()
...
...
@@ -320,6 +320,53 @@ class SyngGui(customtkinter.CTk): # type:ignore
self
.
withdraw
()
self
.
destroy
()
def
add_buttons
(
self
)
->
None
:
button_line
=
customtkinter
.
CTkFrame
(
self
)
button_line
.
pack
(
side
=
"
bottom
"
,
fill
=
"
x
"
)
self
.
startsyng_serverbutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Start Local Server
"
,
command
=
self
.
start_syng_server
)
self
.
startsyng_serverbutton
.
pack
(
side
=
"
left
"
,
expand
=
True
,
anchor
=
"
w
"
,
padx
=
10
,
pady
=
5
)
savebutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Save
"
,
command
=
self
.
save_config
)
savebutton
.
pack
(
side
=
"
left
"
,
padx
=
10
,
pady
=
5
)
self
.
startbutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Save and Start
"
,
command
=
self
.
start_syng_client
)
self
.
startbutton
.
pack
(
side
=
"
left
"
,
padx
=
10
,
pady
=
10
)
def
init_frame
(
self
):
self
.
frm
=
customtkinter
.
CTkFrame
(
self
)
self
.
frm
.
pack
(
ipadx
=
10
,
padx
=
10
,
fill
=
"
both
"
,
expand
=
True
)
def
init_tabs
(
self
):
self
.
tabview
=
customtkinter
.
CTkTabview
(
self
.
frm
,
width
=
600
,
height
=
500
)
self
.
tabview
.
pack
(
side
=
"
right
"
,
padx
=
10
,
pady
=
10
,
fill
=
"
both
"
,
expand
=
True
)
self
.
tabview
.
add
(
"
General
"
)
for
source
in
available_sources
:
self
.
tabview
.
add
(
source
)
self
.
tabview
.
set
(
"
General
"
)
def
add_qr
(
self
)
->
None
:
self
.
qrlabel
=
customtkinter
.
CTkLabel
(
self
.
frm
,
text
=
""
)
self
.
qrlabel
.
pack
(
side
=
"
top
"
,
anchor
=
"
n
"
,
padx
=
10
,
pady
=
10
)
self
.
linklabel
=
customtkinter
.
CTkLabel
(
self
.
frm
,
text
=
""
)
self
.
linklabel
.
bind
(
"
<Button-1>
"
,
lambda
_
:
self
.
open_web
())
self
.
linklabel
.
pack
()
def
add_general_config
(
self
,
config
:
dict
[
str
,
Any
])
->
None
:
self
.
general_config
=
GeneralConfig
(
self
.
tabview
.
tab
(
"
General
"
),
config
,
self
.
update_qr
)
self
.
general_config
.
pack
(
ipadx
=
10
,
fill
=
"
both
"
,
expand
=
True
)
def
add_source_config
(
self
,
source_name
:
str
,
source_config
:
dict
[
str
,
Any
])
->
None
:
self
.
tabs
[
source_name
]
=
SourceTab
(
self
.
tabview
.
tab
(
source_name
),
source_name
,
source_config
)
self
.
tabs
[
source_name
].
pack
(
ipadx
=
10
,
expand
=
True
,
fill
=
"
both
"
)
def
__init__
(
self
)
->
None
:
super
().
__init__
(
className
=
"
Syng
"
)
self
.
protocol
(
"
WM_DELETE_WINDOW
"
,
self
.
on_close
)
...
...
@@ -347,9 +394,6 @@ class SyngGui(customtkinter.CTk): # type:ignore
except
(
KeyError
,
TypeError
):
print
(
"
Could not load config
"
)
# if "config" in loaded_config:
# config["config"] |= loaded_config["config"]
if
not
config
[
"
config
"
][
"
secret
"
]:
config
[
"
config
"
][
"
secret
"
]
=
""
.
join
(
secrets
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
8
)
...
...
@@ -357,51 +401,11 @@ class SyngGui(customtkinter.CTk): # type:ignore
self
.
wm_title
(
"
Syng
"
)
# Buttons
button_line
=
customtkinter
.
CTkFrame
(
self
)
button_line
.
pack
(
side
=
"
bottom
"
,
fill
=
"
x
"
)
self
.
startsyng_serverbutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Start Local Server
"
,
command
=
self
.
start_syng_server
)
self
.
startsyng_serverbutton
.
pack
(
side
=
"
left
"
,
expand
=
True
,
anchor
=
"
w
"
,
padx
=
10
,
pady
=
5
)
savebutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Save
"
,
command
=
self
.
save_config
)
savebutton
.
pack
(
side
=
"
left
"
,
padx
=
10
,
pady
=
5
)
# open_web_button = customtkinter.CTkButton(
# button_line, text="Open Web", command=self.open_web
# )
# open_web_button.pack(side="left", pady=5)
self
.
startbutton
=
customtkinter
.
CTkButton
(
button_line
,
text
=
"
Save and Start
"
,
command
=
self
.
start_syng_client
)
self
.
startbutton
.
pack
(
side
=
"
left
"
,
padx
=
10
,
pady
=
10
)
# Tabs and QR Code
frm
=
customtkinter
.
CTkFrame
(
self
)
frm
.
pack
(
ipadx
=
10
,
padx
=
10
,
fill
=
"
both
"
,
expand
=
True
)
tabview
=
customtkinter
.
CTkTabview
(
frm
,
width
=
600
,
height
=
500
)
tabview
.
pack
(
side
=
"
right
"
,
padx
=
10
,
pady
=
10
,
fill
=
"
both
"
,
expand
=
True
)
tabview
.
add
(
"
General
"
)
for
source
in
available_sources
:
tabview
.
add
(
source
)
tabview
.
set
(
"
General
"
)
self
.
qrlabel
=
customtkinter
.
CTkLabel
(
frm
,
text
=
""
)
self
.
qrlabel
.
pack
(
side
=
"
top
"
,
anchor
=
"
n
"
,
padx
=
10
,
pady
=
10
)
self
.
linklabel
=
customtkinter
.
CTkLabel
(
frm
,
text
=
""
)
self
.
linklabel
.
bind
(
"
<Button-1>
"
,
lambda
_
:
self
.
open_web
())
self
.
linklabel
.
pack
()
self
.
general_config
=
GeneralConfig
(
tabview
.
tab
(
"
General
"
),
config
[
"
config
"
],
self
.
update_qr
)
self
.
general_config
.
pack
(
ipadx
=
10
,
fill
=
"
both
"
,
expand
=
True
)
self
.
add_buttons
()
self
.
init_frame
()
self
.
init_tabs
()
self
.
add_qr
()
self
.
add_general_config
(
config
[
"
config
"
])
self
.
tabs
=
{}
for
source_name
in
available_sources
:
...
...
@@ -410,8 +414,7 @@ class SyngGui(customtkinter.CTk): # type:ignore
except
(
KeyError
,
TypeError
):
source_config
=
{}
self
.
tabs
[
source_name
]
=
SourceTab
(
tabview
.
tab
(
source_name
),
source_name
,
source_config
)
self
.
tabs
[
source_name
].
pack
(
ipadx
=
10
,
expand
=
True
,
fill
=
"
both
"
)
self
.
add_source_config
(
source_name
,
source_config
)
self
.
update_qr
()
...
...
@@ -493,15 +496,3 @@ class SyngGui(customtkinter.CTk): # type:ignore
def
run_gui
()
->
None
:
SyngGui
().
mainloop
()
def
main
()
->
None
:
print
(
f
"
Starting the gui with
{
argv
[
0
]
}
is deprecated. Please use `syng gui` to start the gui
"
,
file
=
stderr
,
)
run_gui
()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment