Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tuneit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladimir Vaskov
tuneit
Commits
835c07ea
Commit
835c07ea
authored
Jan 11, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new widget - NumStepper
parent
84da74a8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
__init__.py
src/settings/__init__.py
+12
-1
backends.py
src/settings/backends.py
+1
-1
NumStepper.py
src/settings/widgets/NumStepper.py
+29
-0
__init__.py
src/settings/widgets/__init__.py
+4
-1
No files found.
src/settings/__init__.py
View file @
835c07ea
...
...
@@ -27,12 +27,23 @@ class Setting:
if
self
.
type
==
'choice'
:
# Дефолтная карта для выборов
map
=
{}
range
=
self
.
_get_backend_range
()
range
=
self
.
_get_backend_range
()
[
1
]
for
var
in
range
:
print
(
var
)
map
[
var
[
0
]
.
upper
()
+
var
[
1
:]]
=
var
return
map
if
self
.
type
==
'number'
:
map
=
{}
range
=
self
.
_get_backend_range
()[
1
]
map
[
"upper"
]
=
range
[
1
]
map
[
"lower"
]
=
range
[
0
]
# Кол-во после запятой
map
[
"digits"
]
=
len
(
str
(
range
[
0
])
.
split
(
'.'
)[
-
1
])
if
'.'
in
str
(
range
[
0
])
else
0
# Минимальное число с этим количеством
map
[
"step"
]
=
10
**
-
map
[
"digits"
]
if
map
[
"digits"
]
>
0
else
0
return
map
return
{}
def
create_row
(
self
):
...
...
src/settings/backends.py
View file @
835c07ea
...
...
@@ -31,7 +31,7 @@ class GSettingsBackend(Backend):
print
(
f
"[DEBUG] Получение значения: schema={schema_name}, key={key_name}, gtype={gtype}"
)
try
:
value
=
schema
.
get_range
(
key_name
)
return
value
.
unpack
()
[
1
]
return
value
.
unpack
()
except
Exception
as
e
:
print
(
f
"[ERROR] Ошибка при получении значения {key}: {e}"
)
return
None
...
...
src/settings/widgets/NumStepper.py
0 → 100644
View file @
835c07ea
from
docutils.nodes
import
subtitle
from
gi.repository
import
Adw
,
Gtk
from
.BaseWidget
import
BaseWidget
class
NumStepper
(
BaseWidget
):
def
create_row
(
self
):
map
=
self
.
setting
.
map
map_keys
=
list
(
self
.
setting
.
map
.
keys
())
row
=
Adw
.
SpinRow
(
title
=
self
.
setting
.
name
,
subtitle
=
self
.
setting
.
help
)
adjustment
=
Gtk
.
Adjustment
(
value
=
self
.
setting
.
_get_backend_value
(),
lower
=
map
[
"lower"
],
upper
=
map
[
"upper"
],
step_increment
=
map
[
"step"
],
)
row
.
set_adjustment
(
adjustment
)
if
"digits"
in
map_keys
:
row
.
set_digits
(
map
[
"digits"
])
adjustment
.
connect
(
"value_changed"
,
self
.
_on_num_changed
)
return
row
def
_on_num_changed
(
self
,
adj
):
selected_value
=
adj
.
get_value
()
self
.
setting
.
_set_backend_value
(
selected_value
)
src/settings/widgets/__init__.py
View file @
835c07ea
from
.BooleanWidget
import
BooleanWidget
from
.ChoiceWidget
import
ChoiceWidget
from
.EntryWidget
import
EntryWidget
from
.NumStepper
import
NumStepper
class
WidgetFactory
:
widget_map
=
{
'choice'
:
ChoiceWidget
,
'boolean'
:
BooleanWidget
,
'entry'
:
EntryWidget
'entry'
:
EntryWidget
,
'number'
:
NumStepper
,
}
@staticmethod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment