diff options
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/activity.py b/activity.py index 9a36f98..2990b34 100644 --- a/activity.py +++ b/activity.py @@ -1,4 +1,4 @@ -# Copyright 2009 Simon Schampijer +# Copyright (C) 2009, Tomeu Vizoso # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,29 +14,37 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -"""HelloWorld Activity: A case study for developing an activity.""" - -import gtk +import os +import sys import logging - from gettext import gettext as _ -from sugar.activity import activity +from PyQt4 import QtCore, QtGui + +from qtactivity import QActivity, QActivityToolBar -class HelloWorldActivity(activity.Activity): - """HelloWorldActivity class as specified in activity.info""" +class HelloWorldQtActivity(QActivity): def __init__(self, handle): """Set up the HelloWorld activity.""" - activity.Activity.__init__(self, handle) + QActivity.__init__(self, handle) + + activity_tool_bar = QActivityToolBar(self) + toolbar = self.addToolBar(activity_tool_bar) + + self._textEdit = QtGui.QTextEdit() + self.setCentralWidget(self._textEdit) + + def read_file(self, file_path): + f = open(file_path, 'r') + text = f.read() + f.close() - # top toolbar with close button - toolbox = activity.ActivityToolbox(self) - self.set_toolbox(toolbox) - toolbox.show() + self._textEdit.setPlainText(text) - # label with the text - label = gtk.Label(_("Hello World!")) - self.set_canvas(label) - label.show() + def write_file(self, file_path): + text = self._textEdit.toPlainText() + f = open(file_path, 'w') + f.write(text) + f.close() |