1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
'''
Created on 12 mai 2011
@author: laurent_bernabe
'''
from gettext import gettext as _
from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.InputDialog import \
InputDialog
import pygtk
pygtk.require('2.0')
import gtk
class MenuActions(object):
'''
Wraps codes for the menu actions in both
pure pygtk mode and in sugar mode
'''
def __init__(self, wrappedDrawingArea):
'''
Constructor
=> wrappedDrawingArea argument : the instance of
TheDrawingAreaEventBox to act upon
=> MenuActions(wrappedDrawingArea)
'''
self.__wrappedDrawingArea = wrappedDrawingArea
def manageDrawingWrite(self):
'''
manageDrawingWrite()
Wraps code for menu Drawing->Write
'''
dialog = InputDialog(_("Line thickness value ?\n(I advice you 5)"))
user_value = dialog.run()
if user_value != None :
try:
line_thickness = int(user_value)
assert line_thickness > 0
except (ValueError, AssertionError) :
message = _("As you did not give an correct integer value,\n5 will be taken")
message_dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK,
message)
message_dialog.run()
message_dialog.destroy()
line_thickness = 5
self.__wrappedDrawingArea.setRecordingMode(line_thickness)
def manageDrawingRead(self):
'''
manageDrawingRead()
Wraps code for menu Drawing->Read
'''
dialog = InputDialog(_("Steps drawing delays (milliseconds) ?\n(I advice you 10)"))
user_value = dialog.run()
if user_value != None :
try:
delay_milliseconds = int(user_value)
assert delay_milliseconds > 0
except (ValueError, AssertionError) :
message = _("As you did not give an correct integer value,\n10 will be taken")
message_dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_OK,
message)
message_dialog.run()
message_dialog.destroy()
delay_milliseconds = 10
self.__wrappedDrawingArea.setReadingMode(delay_milliseconds)
|