first step for slider class
This commit is contained in:
130
controldeck.py
130
controldeck.py
@@ -259,6 +259,69 @@ class Button(QBtn):
|
|||||||
# self.style += "border-bottom: 1px solid var(--c-light-blue);"
|
# self.style += "border-bottom: 1px solid var(--c-light-blue);"
|
||||||
|
|
||||||
|
|
||||||
|
class Slider(Div):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
# instance vars
|
||||||
|
self.slider = None # for handle methods to access slider
|
||||||
|
self.toggled = False
|
||||||
|
|
||||||
|
# default **kwargs
|
||||||
|
self.wtype = 'slider' # slider (atm the only option)
|
||||||
|
self.name = '' # id name
|
||||||
|
self.description = '' # badge name
|
||||||
|
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.style = "width:286px;" # three buttons and the two spaces
|
||||||
|
|
||||||
|
self.cmdl_toggle = '' # cmd for the button left
|
||||||
|
self.cmdl_value = '' # cmd for the slider value
|
||||||
|
|
||||||
|
# local vars
|
||||||
|
badge_name = self.description if self.description else self.name
|
||||||
|
value = 0
|
||||||
|
|
||||||
|
badge = QBadge(
|
||||||
|
text=badge_name,
|
||||||
|
outline=True,
|
||||||
|
color=COLOR_PRIME_TEXT,
|
||||||
|
style="max-width:286px;", # 3*90 + 2*8
|
||||||
|
classes="ellipsis",
|
||||||
|
a=self,
|
||||||
|
)
|
||||||
|
tt = QTooltip(
|
||||||
|
a=badge, text=badge_name, delay=500, anchor='center left',
|
||||||
|
offset=[0, 14], transition_show='jump-right', transition_hide='jump-left')
|
||||||
|
tt.self='center left'
|
||||||
|
item = QItem(
|
||||||
|
a=self,
|
||||||
|
dense=True, # dense: less spacing: vertical little higher
|
||||||
|
)
|
||||||
|
item_section = QItemSection(
|
||||||
|
side=True, # side=True unstreched btn
|
||||||
|
a=item,
|
||||||
|
)
|
||||||
|
|
||||||
|
item_section2 = QItemSection(a=item)
|
||||||
|
def handle_slider(widget_self, msg):
|
||||||
|
# process(cmdl_value.format(name=self.name,value=msg.value), shell=True, output=False)
|
||||||
|
pass
|
||||||
|
self.slider = QSlider(
|
||||||
|
value=value,
|
||||||
|
min=0,
|
||||||
|
max=100,
|
||||||
|
step=5,
|
||||||
|
label=True,
|
||||||
|
a=item_section2,
|
||||||
|
input=handle_slider,
|
||||||
|
color=COLOR_SELECT,
|
||||||
|
style="opacity: 0.6 !important;" if self.is_toggled() else "opacity: unset !important;",
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: toggle?
|
||||||
|
def is_toggled(self):
|
||||||
|
self.toggled = not self.toggled
|
||||||
|
return self.toggled
|
||||||
|
|
||||||
class Volume(Div):
|
class Volume(Div):
|
||||||
# class variables
|
# class variables
|
||||||
data = {} # pulseaudio info for all sinks
|
data = {} # pulseaudio info for all sinks
|
||||||
@@ -463,7 +526,7 @@ def widget_load(config) -> dict:
|
|||||||
iname = None
|
iname = None
|
||||||
#iname = re.search(r"^([0-9]*:?)([0-9]*\.?)(button|empty)", i, flags=re.IGNORECASE)
|
#iname = re.search(r"^([0-9]*:?)([0-9]*\.?)(button|empty)", i, flags=re.IGNORECASE)
|
||||||
iname = re.search(
|
iname = re.search(
|
||||||
r"^([0-9a-z]*:)?([0-9]*\.)?(empty|label|button|sink-inputs|sink|source)", # sink-inputs BEFORE sink!
|
r"^([0-9a-z]*:)?([0-9]*\.)?(empty|label|button|slider|sink-inputs|sink|source)", # sink-inputs BEFORE sink!
|
||||||
i, flags=re.IGNORECASE)
|
i, flags=re.IGNORECASE)
|
||||||
if iname is not None:
|
if iname is not None:
|
||||||
tab_name = iname.group(1)[:-1] if iname.group(1) is not None else '' # remove collon, id is '' if nothing is given
|
tab_name = iname.group(1)[:-1] if iname.group(1) is not None else '' # remove collon, id is '' if nothing is given
|
||||||
@@ -477,15 +540,16 @@ def widget_load(config) -> dict:
|
|||||||
# print('wid_name', wid_name)
|
# print('wid_name', wid_name)
|
||||||
# print('')
|
# print('')
|
||||||
if wid_type == 'empty':
|
if wid_type == 'empty':
|
||||||
|
# TODO: empty using label class, like an alias?
|
||||||
args = [{'widget-class': 'Empty',
|
args = [{'widget-class': 'Empty',
|
||||||
'type': wid_type}]
|
'type': wid_type}]
|
||||||
if wid_type == 'label':
|
if wid_type == 'label':
|
||||||
args = [{'widget-class': 'Label',
|
args = [{'widget-class': Label,
|
||||||
'type': wid_type,
|
'type': wid_type,
|
||||||
'text': wid_name}]
|
'text': wid_name}]
|
||||||
elif wid_type == 'button':
|
elif wid_type == 'button':
|
||||||
# button or empty
|
# button or empty
|
||||||
args = [{'widget-class': 'Button',
|
args = [{'widget-class': Button,
|
||||||
'type': wid_type,
|
'type': wid_type,
|
||||||
'text': wid_name,
|
'text': wid_name,
|
||||||
'text-alt': config.get(i, 'text-alt', fallback=''),
|
'text-alt': config.get(i, 'text-alt', fallback=''),
|
||||||
@@ -500,16 +564,23 @@ def widget_load(config) -> dict:
|
|||||||
'icon-alt': config.get(i, 'icon-alt', fallback=''),
|
'icon-alt': config.get(i, 'icon-alt', fallback=''),
|
||||||
'image': config.get(i, 'image', fallback=''),
|
'image': config.get(i, 'image', fallback=''),
|
||||||
'image-alt': config.get(i, 'image-alt', fallback='')}]
|
'image-alt': config.get(i, 'image-alt', fallback='')}]
|
||||||
|
elif wid_type == 'slider':
|
||||||
|
# sliders
|
||||||
|
args = [{'widget-class': Slider,
|
||||||
|
'type': wid_type,
|
||||||
|
'name': wid_name,
|
||||||
|
'description': config.get(i, 'description', fallback=''),
|
||||||
|
}]
|
||||||
elif wid_type == 'sink':
|
elif wid_type == 'sink':
|
||||||
# volume sliders
|
# volume sliders
|
||||||
args = [{'widget-class': 'Volume',
|
args = [{'widget-class': Volume,
|
||||||
'type': wid_type,
|
'type': wid_type,
|
||||||
'name': wid_name,
|
'name': wid_name,
|
||||||
'description': config.get(i, 'description', fallback=''),
|
'description': config.get(i, 'description', fallback=''),
|
||||||
}]
|
}]
|
||||||
elif wid_type == 'sink-inputs':
|
elif wid_type == 'sink-inputs':
|
||||||
# multiple volume sliders
|
# multiple volume sliders
|
||||||
args = [{'widget-class': 'VolumeGroup',
|
args = [{'widget-class': VolumeGroup,
|
||||||
'type': wid_type,
|
'type': wid_type,
|
||||||
}]
|
}]
|
||||||
if tab_name not in widget_dict:
|
if tab_name not in widget_dict:
|
||||||
@@ -864,30 +935,39 @@ async def application(request):
|
|||||||
name=var,
|
name=var,
|
||||||
classes="row q-pa-sm q-gutter-sm",
|
classes="row q-pa-sm q-gutter-sm",
|
||||||
a=tab_panel[tab_name])
|
a=tab_panel[tab_name])
|
||||||
|
# TODO: empty using label class, like an alias?
|
||||||
if j['widget-class'] == 'Empty':
|
if j['widget-class'] == 'Empty':
|
||||||
Label(text='',
|
Label(text='',
|
||||||
wtype=j['type'],
|
wtype=j['type'],
|
||||||
a=eval(var))
|
a=eval(var))
|
||||||
if j['widget-class'] == 'Label':
|
if j['widget-class'] == Label:
|
||||||
Label(text=j['text'],
|
j['widget-class'](
|
||||||
wtype=j['type'],
|
text=j['text'],
|
||||||
a=eval(var))
|
wtype=j['type'],
|
||||||
if j['widget-class'] == 'Button':
|
a=eval(var))
|
||||||
Button(text=j['text'], text_alt=j['text-alt'],
|
if j['widget-class'] == Button:
|
||||||
wtype=j['type'],
|
j['widget-class'](
|
||||||
command=j['command'], command_alt=j['command-alt'],
|
text=j['text'], text_alt=j['text-alt'],
|
||||||
color_bg=j['color-bg'], color_fg=j['color-fg'],
|
wtype=j['type'],
|
||||||
state_pattern=j['state'], state_pattern_alt=j['state-alt'],
|
command=j['command'], command_alt=j['command-alt'],
|
||||||
state_command=j['state-command'],
|
color_bg=j['color-bg'], color_fg=j['color-fg'],
|
||||||
icon=j['icon'], icon_alt=j['icon-alt'],
|
state_pattern=j['state'], state_pattern_alt=j['state-alt'],
|
||||||
image=j['image'], image_alt=j['image-alt'],
|
state_command=j['state-command'],
|
||||||
a=eval(var))
|
icon=j['icon'], icon_alt=j['icon-alt'],
|
||||||
elif j['widget-class'] == 'Volume':
|
image=j['image'], image_alt=j['image-alt'],
|
||||||
Volume(name=j['name'], description=j['description'],
|
a=eval(var))
|
||||||
wtype=j['type'],
|
elif j['widget-class'] == Slider:
|
||||||
a=eval(var))
|
j['widget-class'](
|
||||||
elif j['widget-class'] == 'VolumeGroup':
|
name=j['name'], description=j['description'],
|
||||||
VolumeGroup(wtype=j['type'], a=eval(var))
|
wtype=j['type'],
|
||||||
|
a=eval(var))
|
||||||
|
elif j['widget-class'] == Volume:
|
||||||
|
j['widget-class'](
|
||||||
|
name=j['name'], description=j['description'],
|
||||||
|
wtype=j['type'],
|
||||||
|
a=eval(var))
|
||||||
|
elif j['widget-class'] == VolumeGroup:
|
||||||
|
j['widget-class'](wtype=j['type'], a=eval(var))
|
||||||
|
|
||||||
# TODO: change reference wp.components to ...
|
# TODO: change reference wp.components to ...
|
||||||
if not wp.components:
|
if not wp.components:
|
||||||
|
|||||||
Reference in New Issue
Block a user