Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Archive
gcompris
Commits
73e37f51
Commit
73e37f51
authored
Aug 14, 2005
by
Yves Combe
Browse files
pass configuartion sample into pythontest
parent
2d06ebf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
73e37f51
2005-08-14 Yves Combe <yves@ycombe.net>
pass configuartion sample into pythontest
* src/boards/python/pythontest.py:
* src/boards/python/tuxpaint.py:
2005-08-14 Yves Combe <yves@ycombe.net>
gcompris_spin_int configuration utility function, for integer valued spin buttons. Binded in python (gcompris.spin_int). Sample in colors.c and tuxpaint.py.
...
...
src/boards/python/pythontest.py
View file @
73e37f51
...
...
@@ -21,6 +21,11 @@ class Gcompris_pythontest:
self
.
colors
[
'circle_out'
]
=
gcompris
.
skin
.
get_color
(
"pythontest/circle out"
)
self
.
colors
[
'line'
]
=
gcompris
.
skin
.
get_color
(
"pythontest/line"
)
# Just for config demo
self
.
config_colors
=
{
'red'
:
0xFF0000FF
L
,
'green'
:
0x00FF00FF
L
,
'blue'
:
0x0000FFFF
L
}
self
.
movingline
=
'none'
print
(
"Gcompris_pythontest __init__."
)
...
...
@@ -31,6 +36,17 @@ class Gcompris_pythontest:
self
.
gcomprisBoard
.
maxlevel
=
1
self
.
gcomprisBoard
.
sublevel
=
1
self
.
gcomprisBoard
.
number_of_sublevel
=
1
self
.
config_dict
=
gcompris
.
get_board_conf
()
# self.colors['line'] s set in init.
# I put here the configuration use
color_name
=
self
.
config_colors
.
keys
()[
self
.
init_conf
(
'color_line'
,
0
)]
print
'color name'
,
color_name
self
.
colors
[
'line'
]
=
self
.
config_colors
[
color_name
]
gcompris
.
bar_set
(
0
)
gcompris
.
set_background
(
self
.
gcomprisBoard
.
canvas
.
root
(),
gcompris
.
skin
.
image_to_skin
(
"gcompris-bg.jpg"
))
...
...
@@ -44,11 +60,25 @@ class Gcompris_pythontest:
y
=
0.0
)
# distance is used to demo of gcompris.spin_int
distance
=
self
.
init_conf
(
'distance_circle'
,
100
)
# pattern is for gcompris.radio_buttons
pattern
=
self
.
init_conf_str
(
'pattern'
,
'circle'
)
patterns
=
{
'circle'
:
gnome
.
canvas
.
CanvasEllipse
,
'rectangle'
:
gnome
.
canvas
.
CanvasRect
}
#error check
if
not
patterns
.
has_key
(
pattern
):
pattern
=
'circle'
self
.
canvasitems
[
1
]
=
self
.
rootitem
.
add
(
gnome
.
canvas
.
CanvasEllipse
,
x1
=
3
00.0
,
patterns
[
pattern
]
,
x1
=
4
00.0
-
distance
,
y1
=
200.0
,
x2
=
2
80.0
,
x2
=
3
80.0
-
distance
,
y2
=
220.0
,
fill_color_rgba
=
self
.
colors
[
'circle_in'
],
outline_color_rgba
=
self
.
colors
[
'circle_out'
],
...
...
@@ -57,10 +87,10 @@ class Gcompris_pythontest:
self
.
canvasitems
[
1
].
connect
(
"event"
,
self
.
circle_item_event
)
self
.
canvasitems
[
2
]
=
self
.
rootitem
.
add
(
gnome
.
canvas
.
CanvasEllipse
,
x1
=
5
00.0
,
patterns
[
pattern
]
,
x1
=
4
00.0
+
distance
,
y1
=
200.0
,
x2
=
5
20.0
,
x2
=
4
20.0
+
distance
,
y2
=
220.0
,
fill_color_rgba
=
self
.
colors
[
'circle_in'
],
outline_color_rgba
=
self
.
colors
[
'circle_out'
],
...
...
@@ -262,8 +292,10 @@ class Gcompris_pythontest:
self
.
timer_inc
=
gtk
.
timeout_add
(
self
.
timerinc
,
self
.
timer_inc_display
)
def
circle_item_event
(
self
,
widget
,
event
=
None
):
if
self
.
init_conf
(
'disable_line'
,
True
):
return
False
if
event
.
type
==
gtk
.
gdk
.
BUTTON_PRESS
:
if
event
.
button
==
1
:
bounds
=
widget
.
get_bounds
()
...
...
@@ -274,7 +306,7 @@ class Gcompris_pythontest:
self
.
canvasitems
[
'line 1'
]
=
self
.
rootitem
.
add
(
gnome
.
canvas
.
CanvasLine
,
points
=
(
self
.
pos_x
,
self
.
pos_y
,
event
.
x
,
event
.
y
),
fill_color_rgba
=
self
.
colors
[
'
circle_
in'
],
fill_color_rgba
=
self
.
colors
[
'
l
in
e
'
],
width_units
=
5.0
)
self
.
movingline
=
'line 1'
...
...
@@ -292,3 +324,92 @@ class Gcompris_pythontest:
return
True
return
False
###################################################
# Configuration system
###################################################
#mandatory but unused yet
def
config_stop
(
self
):
pass
# Configuration function.
def
config_start
(
self
,
profile
):
# keep profile in mind
self
.
configuring_profile
=
profile
#get the configured values for that profile
self
.
config_dict
=
gcompris
.
get_conf
(
profile
,
self
.
gcomprisBoard
)
# Init configuration window:
# all the configuration functions will use it
# all the configuration functions returns values for their key in
# the dict passed to the apply_callback
# the returned value is the main GtkVBox of the window,
#we can add what you want in it.
self
.
main_vbox
=
gcompris
.
configuration_window
(
\
_
(
'<b>%s</b> configuration
\n
for profile <b>%s</b>'
)
%
(
'Pythontest'
,
profile
.
name
),
self
.
apply_callback
)
# toggle box
control_line
=
gcompris
.
boolean_box
(
_
(
'Disable line drawing in circle'
),
'disable_line'
,
self
.
init_conf
(
'disable_line'
,
True
)
)
# sample of control in python
control_line
.
connect
(
"toggled"
,
self
.
color_disable
)
# combo box
self
.
color_choice
=
\
gcompris
.
combo_box
(
_
(
'Color line'
),
self
.
config_colors
.
keys
(),
'color_line'
,
self
.
init_conf
(
'color_line'
,
0
)
)
self
.
color_choice
.
set_sensitive
(
not
self
.
init_conf
(
'disable_line'
,
True
))
#spin button for int
self
.
distance_box
=
\
gcompris
.
spin_int
(
_
(
'Distance between circles'
),
'distance_circle'
,
20
,
200
,
20
,
self
.
init_conf
(
'distance_circle'
,
100
)
)
#radio buttons for circle or rectangle
patterns
=
{
'circle'
:
_
(
'Use circles'
),
'rectangle'
:
_
(
'Use rectangles'
)
}
gcompris
.
radio_buttons
(
_
(
'Choice of pattern'
),
'pattern'
,
patterns
,
self
.
init_conf_str
(
'pattern'
,
'circle'
)
)
# Get value from config_dict or value passed
def
init_conf
(
self
,
key
,
value
):
if
self
.
config_dict
.
has_key
(
key
):
return
eval
(
self
.
config_dict
[
key
])
else
:
return
value
# Get value from config_dict or value passed, with string type values
def
init_conf_str
(
self
,
key
,
value
):
if
self
.
config_dict
.
has_key
(
key
):
return
self
.
config_dict
[
key
]
else
:
return
value
def
color_disable
(
self
,
button
):
self
.
color_choice
.
set_sensitive
(
not
button
.
get_active
())
def
apply_callback
(
self
,
table
):
print
_
(
'Keys and values returned by PythonTest config window:'
)
for
key
,
value
in
table
.
iteritems
():
print
'%20s:%20s '
%
(
key
,
value
)
gcompris
.
set_board_conf
(
self
.
configuring_profile
,
self
.
gcomprisBoard
,
key
,
value
)
src/boards/python/tuxpaint.py
View file @
73e37f51
...
...
@@ -149,50 +149,32 @@ class Gcompris_tuxpaint:
print
"Config"
pass
def
config_stop
(
self
):
print
"config_stop"
,
self
self
.
config_window
.
destroy
()
pass
def
config_start
(
self
,
profile
):
self
.
configure_profile
=
profile
self
.
config_values
=
{}
self
.
main_vbox
=
gcompris
.
configuration_window
(
_
(
'<b>%s</b> configuration
\n
for profile <b>%s</b>'
)
%
(
'Tuxpaint'
,
profile
.
name
),
self
.
apply_callback
)
self
.
config_dict
=
gcompris
.
get_conf
(
profile
,
self
.
gcomprisBoard
)
gcompris
.
boolean_box
(
'Disable shape rotation'
,
'disable_shape_rotation'
,
self
.
configuration
(
'disable_shape_rotation'
))
gcompris
.
boolean_box
(
'Follow gcompris fullscreen'
,
'fullscreen'
,
self
.
configuration
(
'fullscreen'
))
gcompris
.
boolean_box
(
'Show Uppercase text only'
,
'uppercase_text'
,
self
.
configuration
(
'uppercase_text'
))
stamps
=
gcompris
.
boolean_box
(
'Disable stamps'
,
'disable_stamps'
,
self
.
configuration
(
'disable_stamps'
))
self
.
stamps_control
=
gcompris
.
boolean_box
(
'Disable stamps control'
,
'disable_stamps_control'
,
self
.
configuration
(
'disable_stamps_control'
))
self
.
stamps_control
.
set_sensitive
(
self
.
configuration
(
'disable_stamps'
))
gcompris
.
boolean_box
(
_
(
'Disable shape rotation'
),
'disable_shape_rotation'
,
self
.
configuration
(
'disable_shape_rotation'
))
gcompris
.
combo_box
(
'ComboBox Test '
,
[
'red'
,
'blue'
,
'g
reen'
]
,
'combo_test'
,
1
)
gcompris
.
boolean_box
(
_
(
'Follow gcompris fullscreen'
),
'fullsc
reen'
,
self
.
configuration
(
'fullscreen'
)
)
gcompris
.
radio_buttons
(
'<b>Radio Buttons</b> Test'
,
'radio_test'
,
{
'red'
:
'Red Carpet'
,
'blue'
:
'Blue Hotel'
,
'green'
:
'Yellow Submarine'
},
'green'
)
gcompris
.
boolean_box
(
_
(
'Show Uppercase text only'
),
'uppercase_text'
,
self
.
configuration
(
'uppercase_text'
))
stamps
=
gcompris
.
boolean_box
(
_
(
'Disable stamps'
),
'disable_stamps'
,
self
.
configuration
(
'disable_stamps'
))
stamps
.
connect
(
"toggled"
,
self
.
stamps_changed
)
gcompris
.
spin_int
(
'<b>Spin Button</b> Test'
,
'spin_test'
,
-
12
,
12
,
2
,
0
)
self
.
stamps_control
=
gcompris
.
boolean_box
(
'Disable stamps control'
,
'disable_stamps_control'
,
self
.
configuration
(
'disable_stamps_control'
))
self
.
stamps_control
.
set_sensitive
(
self
.
configuration
(
'disable_stamps'
))
def
stamps_changed
(
self
,
button
):
self
.
stamps_control
.
set_sensitive
(
button
.
get_active
())
...
...
Write
Preview
Supports
Markdown
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