Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/illustrate.py
diff options
context:
space:
mode:
Diffstat (limited to 'illustrate.py')
-rw-r--r--illustrate.py99
1 files changed, 50 insertions, 49 deletions
diff --git a/illustrate.py b/illustrate.py
index 0a33540..4782d30 100644
--- a/illustrate.py
+++ b/illustrate.py
@@ -43,22 +43,22 @@ from dialogs import ExampleDialog
def rgb2html(color):
- """Returns a html string from a Gdk color"""
- red = "%x" % int(color.red / 65535.0 * 255)
+ '''Returns a html string from a Gdk color'''
+ red = '%x' % int(color.red / 65535.0 * 255)
if len(red) == 1:
- red = "0%s" % red
+ red = '0%s' % red
- green = "%x" % int(color.green / 65535.0 * 255)
+ green = '%x' % int(color.green / 65535.0 * 255)
if len(green) == 1:
- green = "0%s" % green
+ green = '0%s' % green
- blue = "%x" % int(color.blue / 65535.0 * 255)
+ blue = '%x' % int(color.blue / 65535.0 * 255)
if len(blue) == 1:
- blue = "0%s" % blue
+ blue = '0%s' % blue
- new_color = "#%s%s%s" % (red, green, blue)
+ new_color = '#%s%s%s' % (red, green, blue)
return new_color
@@ -73,10 +73,10 @@ class IllustrateActivity(activity.Activity):
# The Activity Button:
activity_button = ActivityToolbarButton(self)
- open_from_journal_button = ToolButton("open-from-journal")
- open_from_journal_button.connect("clicked", self.load_objectchooser)
+ open_from_journal_button = ToolButton('open-from-journal')
+ open_from_journal_button.connect('clicked', self.load_objectchooser)
open_from_journal_button.props.tooltip = \
- _("Load text from Sugar Journal")
+ _('Load text from Sugar Journal')
open_from_journal_button.show()
# Insert a button in the activity button toolbar
@@ -90,14 +90,14 @@ class IllustrateActivity(activity.Activity):
separator.set_draw(True)
toolbarbox.toolbar.insert(separator, -1)
- dialog_btn = ToolButton("dialog-icon")
- dialog_btn.set_tooltip(_("Dialog example"))
- dialog_btn.connect("clicked", self._show_example_dialog)
+ dialog_btn = ToolButton('dialog-icon')
+ dialog_btn.set_tooltip(_('Dialog example'))
+ dialog_btn.connect('clicked', self._show_example_dialog)
toolbarbox.toolbar.insert(dialog_btn, -1)
- alert_btn = ToolButton("alert-icon")
- alert_btn.set_tooltip(_("Alert example"))
- alert_btn.connect("clicked", self._show_alert_btn_pallete)
+ alert_btn = ToolButton('alert-icon')
+ alert_btn.set_tooltip(_('Alert example'))
+ alert_btn.connect('clicked', self._show_alert_btn_pallete)
toolbarbox.toolbar.insert(alert_btn, -1)
separator = gtk.SeparatorToolItem()
@@ -107,18 +107,19 @@ class IllustrateActivity(activity.Activity):
# RadioToolButton
self._circle_btn = RadioToolButton()
- self._circle_btn.props.icon_name = "sugar-integration"
- self._circle_btn.connect("clicked", self._set_background)
+ self._circle_btn.props.icon_name = 'sugar-integration'
+ self._circle_btn.props.accelerator = '<Ctrl>I'
+ self._circle_btn.connect('clicked', self._set_background)
self._spiral_btn = RadioToolButton()
- self._spiral_btn.props.icon_name = "spiral"
+ self._spiral_btn.props.icon_name = 'spiral'
self._spiral_btn.props.group = self._circle_btn
- self._spiral_btn.connect("clicked", self._set_background)
+ self._spiral_btn.connect('clicked', self._set_background)
self._box_btn = RadioToolButton()
- self._box_btn.props.icon_name = "box"
+ self._box_btn.props.icon_name = 'box'
self._box_btn.props.group = self._circle_btn
- self._box_btn.connect("clicked", self._set_background)
+ self._box_btn.connect('clicked', self._set_background)
toolbarbox.toolbar.insert(self._circle_btn, -1)
toolbarbox.toolbar.insert(self._spiral_btn, -1)
@@ -135,7 +136,7 @@ class IllustrateActivity(activity.Activity):
# Add a gtk.Label in a toolbar using gtk.ToolItem
toolitem = gtk.ToolItem()
- toolitem.add(gtk.Label(_("Color Button example: ")))
+ toolitem.add(gtk.Label(_('Color Button example: ')))
options_toolbar.insert(toolitem, -1)
# Get the profile color
@@ -145,14 +146,14 @@ class IllustrateActivity(activity.Activity):
self.fill_color_btn = ColorToolButton()
self.fill_color_btn.set_color(gtk.gdk.Color(
profile_color.get_fill_color()))
- self.fill_color_btn.set_title(_("Fill Color"))
+ self.fill_color_btn.set_title(_('Fill Color'))
self.fill_color_btn.connect('notify::color', self._set_fill_color)
options_toolbar.insert(self.fill_color_btn, -1)
self.stroke_color_btn = ColorToolButton()
self.stroke_color_btn.set_color(gtk.gdk.Color(
profile_color.get_stroke_color()))
- self.stroke_color_btn.set_title(_("Stroke Color"))
+ self.stroke_color_btn.set_title(_('Stroke Color'))
self.stroke_color_btn.connect('notify::color',
self._set_stroke_color)
options_toolbar.insert(self.stroke_color_btn, -1)
@@ -176,7 +177,7 @@ class IllustrateActivity(activity.Activity):
# For a white background:
canvas = gtk.EventBox()
- canvas.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
+ canvas.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
self.set_canvas(canvas)
@@ -195,11 +196,11 @@ class IllustrateActivity(activity.Activity):
palette = button.get_palette()
hbox = gtk.HBox()
- simple = ToolButton("alert-icon")
- simple.connect("clicked", self._show_example_alert, False)
+ simple = ToolButton('alert-icon')
+ simple.connect('clicked', self._show_example_alert, False)
- notify = ToolButton("notify-alert-icon")
- notify.connect("clicked", self._show_example_alert, True)
+ notify = ToolButton('notify-alert-icon')
+ notify.connect('clicked', self._show_example_alert, True)
hbox.pack_start(simple, False, True, 0)
hbox.pack_end(notify, False, True, 0)
@@ -214,7 +215,7 @@ class IllustrateActivity(activity.Activity):
result = chooser.run()
if result == gtk.RESPONSE_ACCEPT:
jobject = chooser.get_selected_object()
- _file = open(str(jobject.get_file_path()), "r")
+ _file = open(str(jobject.get_file_path()), 'r')
text = _file.read()
_file.close()
alert = NotifyAlert(10)
@@ -279,28 +280,28 @@ class IllustrateActivity(activity.Activity):
def _helpbutton(self, toolbarbox):
helpbutton = HelpButton()
- helpbutton.add_section(_("A section"))
- helpbutton.add_paragraph(_("A paragraph with an icon"), "help-icon")
+ helpbutton.add_section(_('A section'))
+ helpbutton.add_paragraph(_('A paragraph with an icon'), 'help-icon')
helpbutton.add_paragraph(
- _("You can add as many paragraphs you'd like."))
+ _('You can add as many paragraphs you\'d like.'))
helpbutton.add_section(
- _("Why should your activity be well integrated?"))
- helpbutton.add_paragraph(_("There are many Sugar activities;\
+ _('Why should your activity be well integrated?'))
+ helpbutton.add_paragraph(_('There are many Sugar activities;\
if they all work in a similar way,\
- the children and teachers who use Sugar will be more comfortable."))
- helpbutton.add_section(_("About"))
+ the children and teachers who use Sugar will be more comfortable.'))
+ helpbutton.add_section(_('About'))
helpbutton.add_paragraph(
- _("This Sugar Activity integrates examples."))
- helpbutton.add_paragraph(_("Thanks for using our activity!"))
+ _('This Sugar Activity integrates examples.'))
+ helpbutton.add_paragraph(_('Thanks for using our activity!'))
toolbarbox.toolbar.insert(helpbutton, -1)
def write_file(self, file_path):
- jfile = open(file_path, "w")
+ jfile = open(file_path, 'w')
- icon_props = {"fill": self._icon.props.fill_color,
- "stroke": self._icon.props.stroke_color,
- "icon-name": self._icon.props.icon_name}
+ icon_props = {'fill': self._icon.props.fill_color,
+ 'stroke': self._icon.props.stroke_color,
+ 'icon-name': self._icon.props.icon_name}
try:
json.dump(icon_props, jfile)
@@ -308,15 +309,15 @@ class IllustrateActivity(activity.Activity):
jfile.close()
def read_file(self, file_path):
- jfile = open(file_path, "r")
+ jfile = open(file_path, 'r')
try:
icon_props = json.load(jfile)
finally:
jfile.close()
- self.fill_color_btn.set_color(gtk.gdk.Color(icon_props["fill"]))
- self.stroke_color_btn.set_color(gtk.gdk.Color(icon_props["stroke"]))
+ self.fill_color_btn.set_color(gtk.gdk.Color(icon_props['fill']))
+ self.stroke_color_btn.set_color(gtk.gdk.Color(icon_props['stroke']))
for i in [self._circle_btn, self._spiral_btn, self._box_btn]:
- if i.props.icon_name == icon_props["icon-name"]:
+ if i.props.icon_name == icon_props['icon-name']:
i.set_active(1)