Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
3946378c
Commit
3946378c
authored
Jun 04, 2013
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement resetting an option to its default value
parent
94ed9f35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
pronterface_widgets.py
printrun/pronterface_widgets.py
+7
-2
pronsole.py
pronsole.py
+11
-2
No files found.
printrun/pronterface_widgets.py
View file @
3946378c
...
...
@@ -152,8 +152,13 @@ class PronterOptionsDialog(wx.Dialog):
grid
.
AddGrowableCol
(
1
)
grid
.
SetNonFlexibleGrowMode
(
wx
.
FLEX_GROWMODE_SPECIFIED
)
for
setting
in
settings
:
grid
.
Add
(
setting
.
get_label
(
grouppanel
),
0
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
ALIGN_RIGHT
)
grid
.
Add
(
setting
.
get_widget
(
grouppanel
),
1
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
EXPAND
)
label
,
widget
=
setting
.
get_label
(
grouppanel
),
setting
.
get_widget
(
grouppanel
)
grid
.
Add
(
label
,
0
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
ALIGN_RIGHT
)
grid
.
Add
(
widget
,
1
,
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALL
|
wx
.
EXPAND
)
if
hasattr
(
label
,
"set_default"
):
label
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
label
.
set_default
)
if
hasattr
(
widget
,
"Bind"
):
widget
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
label
.
set_default
)
grouppanel
.
SetSizer
(
grid
)
sbox
.
Add
(
notebook
,
1
,
wx
.
EXPAND
)
panel
.
SetSizer
(
sbox
)
...
...
pronsole.py
View file @
3946378c
...
...
@@ -68,10 +68,11 @@ def setting_add_tooltip(func):
sep
=
"
\n\n
"
if
self
.
default
is
not
""
:
deftxt
=
_
(
"Default: "
)
resethelp
=
_
(
"(Control-doubleclick to reset to default value)"
)
if
len
(
repr
(
self
.
default
))
>
10
:
deftxt
+=
"
\n
"
+
repr
(
self
.
default
)
.
strip
(
"'"
)
deftxt
+=
"
\n
"
+
repr
(
self
.
default
)
.
strip
(
"'"
)
+
"
\n
"
+
resethelp
else
:
deftxt
+=
repr
(
self
.
default
)
deftxt
+=
repr
(
self
.
default
)
+
" "
+
resethelp
helptxt
+=
sep
+
deftxt
if
len
(
helptxt
):
widget
.
SetToolTipString
(
helptxt
)
...
...
@@ -98,10 +99,18 @@ class Setting(object):
raise
NotImplementedError
value
=
property
(
_get_value
,
_set_value
)
def
set_default
(
self
,
e
):
import
wx
if
e
.
CmdDown
()
and
e
.
ButtonDClick
()
and
self
.
default
is
not
""
:
confirmation
=
wx
.
MessageDialog
(
None
,
_
(
"Are you sure you want to reset the setting to the default value: {0!r} ?"
)
.
format
(
self
.
default
),
_
(
"Confirm set default"
),
wx
.
ICON_EXCLAMATION
|
wx
.
YES_NO
|
wx
.
NO_DEFAULT
)
if
confirmation
.
ShowModal
()
==
wx
.
ID_YES
:
self
.
_set_value
(
self
.
default
)
@
setting_add_tooltip
def
get_label
(
self
,
parent
):
import
wx
widget
=
wx
.
StaticText
(
parent
,
-
1
,
self
.
label
or
self
.
name
)
widget
.
set_default
=
self
.
set_default
return
widget
@
setting_add_tooltip
...
...
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