diff options
author | flavio <fdanesse@gmail.com> | 2012-06-15 20:08:28 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2012-06-15 20:08:28 (GMT) |
commit | ebae32267a9369ed9cdf389571581f43c871b38c (patch) | |
tree | 3f8febac7ae9e1994372929a3ee3a0f15283a237 | |
parent | 7058c4b3d7d92442a46de28befec64f141664eb3 (diff) |
Port Gtk3 Base
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | activity.py | 62 | ||||
-rw-r--r-- | groupthink/gtk_tools.py | 42 | ||||
-rw-r--r-- | groupthink/sugar_tools.py | 112 | ||||
-rwxr-xr-x | library/pippy/physics/Box2D2.py | 138 | ||||
-rw-r--r-- | library/pippy/physics/add_objects.py | 96 | ||||
-rwxr-xr-x | library/pippy/physics/callbacks.py | 16 | ||||
-rwxr-xr-x | library/pippy/physics/camera.py | 10 | ||||
-rwxr-xr-x | library/pippy/physics/drawing.py | 50 | ||||
-rw-r--r-- | library/pippy/physics/elements.py | 54 | ||||
-rwxr-xr-x | library/pippy/physics/locals.py | 4 | ||||
-rw-r--r-- | library/pippy/physics/menu.py | 24 | ||||
-rwxr-xr-x | library/pippy/physics/tools.py | 10 | ||||
-rwxr-xr-x | library/pippy/physics/tools_poly.py | 54 | ||||
-rw-r--r-- | library/pippy/query.py | 4 | ||||
-rwxr-xr-x | library/pippy/sound.py | 6 | ||||
-rw-r--r-- | pippy_app.py | 245 | ||||
-rw-r--r-- | port/style.py | 2 | ||||
-rwxr-xr-x | setup.py | 2 |
19 files changed, 451 insertions, 481 deletions
@@ -1,4 +1,5 @@ Connect-*.xo *.pyc *.kpf +*.bak .*.sw[op] diff --git a/activity.py b/activity.py index 0b0ddae..c845edc 100755 --- a/activity.py +++ b/activity.py @@ -17,8 +17,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """Pippy activity helper classes.""" -from sugar.activity import activity +import gi +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import Pango +from gi.repository import GObject +from sugar3.activity import activity class ViewSourceActivity(activity.Activity): """Activity subclass which handles the 'view source' key.""" @@ -28,8 +33,7 @@ class ViewSourceActivity(activity.Activity): self.connect('key-press-event', self._key_press_cb) def _key_press_cb(self, widget, event): - import gtk - if gtk.gdk.keyval_name(event.keyval) == 'XF86Start': + if Gdk.keyval_name(event.keyval) == 'XF86Start': self.view_source() return True return False @@ -38,12 +42,13 @@ class ViewSourceActivity(activity.Activity): """Implement the 'view source' key by saving pippy_app.py to the datastore, and then telling the Journal to view it.""" if self.__source_object_id is None: - from sugar import profile - from sugar.datastore import datastore - from sugar.activity.activity \ - import get_bundle_name, get_bundle_path + from sugar3 import profile + from sugar3.datastore import datastore + from sugar3.activity.activity import get_bundle_name + from sugar3.activity.activity import get_bundle_path from gettext import gettext as _ import os.path + jobject = datastore.create() metadata = { 'title': _('%s Source') % get_bundle_name(), @@ -64,21 +69,18 @@ class ViewSourceActivity(activity.Activity): """Invoke journal_show_object from sugar.activity.activity if it exists.""" try: - from sugar.activity.activity import show_object_in_journal + from sugar3.activity.activity import show_object_in_journal show_object_in_journal(object_id) except ImportError: pass # no love from sugar. TARGET_TYPE_TEXT = 80 - class VteActivity(ViewSourceActivity): """Activity subclass built around the Vte terminal widget.""" def __init__(self, handle): - import gtk - import pango - import vte - from sugar.graphics.toolbutton import ToolButton + from gi.repository import Vte + from sugar3.graphics.toolbutton import ToolButton from gettext import gettext as _ super(VteActivity, self).__init__(handle) toolbox = activity.ActivityToolbox(self) @@ -98,23 +100,23 @@ class VteActivity(ViewSourceActivity): self._copy_button = edittoolbar.copy # creates vte widget - self._vte = vte.Terminal() + self._vte = Vte.Terminal() self._vte.set_size(30, 5) self._vte.set_size_request(200, 300) font = 'Monospace 10' - self._vte.set_font(pango.FontDescription(font)) - self._vte.set_colors(gtk.gdk.color_parse('#000000'), - gtk.gdk.color_parse('#E7E7E7'), + self._vte.set_font(Pango.FontDescription(font)) + self._vte.set_colors(Gdk.color_parse('#000000'), + Gdk.color_parse('#E7E7E7'), []) self._vte.connect('selection-changed', self._on_selection_changed_cb) - self._vte.drag_dest_set(gtk.DEST_DEFAULT_ALL, + self._vte.drag_dest_set(Gtk.DEST_DEFAULT_ALL, [("text/plain", 0, TARGET_TYPE_TEXT)], - gtk.gdk.ACTION_COPY) + Gdk.DragAction.COPY) self._vte.connect('drag_data_received', self._on_drop_cb) # ...and its scrollbar - vtebox = gtk.HBox() - vtebox.pack_start(self._vte) - vtesb = gtk.VScrollbar(self._vte.get_adjustment()) + vtebox = Gtk.HBox() + vtebox.pack_start(self._vte, True, True, 0) + vtesb = Gtk.VScrollbar(self._vte.get_adjustment()) vtesb.show() vtebox.pack_start(vtesb, False, False, 0) self.set_canvas(vtebox) @@ -157,7 +159,6 @@ class VteActivity(ViewSourceActivity): """This method is invoked when the user's script exits.""" pass # override in subclass - class PyGameActivity(ViewSourceActivity): """Activity wrapper for a pygame.""" def __init__(self, handle): @@ -178,30 +179,27 @@ class PyGameActivity(ViewSourceActivity): execfile(pippy_app_path, g, g) # start pygame sys.exit(0) super(PyGameActivity, self).__init__(handle) - import gobject - import gtk toolbox = activity.ActivityToolbox(self) toolbar = toolbox.get_activity_toolbar() self.set_toolbox(toolbox) toolbox.show() - socket = gtk.Socket() - socket.set_flags(socket.flags() | gtk.CAN_FOCUS) + socket = Gtk.Socket() + socket.set_flags(socket.flags() | Gtk.CAN_FOCUS) socket.show() self.set_canvas(socket) socket.add_id(windowid) self.show_all() socket.grab_focus() - gobject.child_watch_add(self.child_pid, lambda pid, cond: self.close()) + GObject.child_watch_add(self.child_pid, lambda pid, cond: self.close()) # hide the buttons we don't use. toolbar.share.hide() # this should share bundle. toolbar.keep.hide() - def _main(): """Launch this activity from the command line.""" - from sugar.activity import activityfactory - from sugar.activity.registry import ActivityInfo - from sugar.bundle.activitybundle import ActivityBundle + from sugar3.activity import activityfactory + from sugar3.activity.registry import ActivityInfo + from sugar3.bundle.activitybundle import ActivityBundle import os ab = ActivityBundle(os.path.dirname(__file__) or '.') ai = ActivityInfo(name=ab.get_name(), diff --git a/groupthink/gtk_tools.py b/groupthink/gtk_tools.py index 0cd4029..2b74276 100644 --- a/groupthink/gtk_tools.py +++ b/groupthink/gtk_tools.py @@ -1,15 +1,19 @@ -import gtk +import gi +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject + import groupthink_base as groupthink import logging import stringtree -class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry): - """RecentEntry is an extension of gtk.Entry that, when attached to a group, +class RecentEntry(groupthink.UnorderedHandlerAcceptor, Gtk.Entry): + """RecentEntry is an extension of Gtk.Entry that, when attached to a group, creates a unified Entry field for all participants""" def __init__(self, *args, **kargs): - gtk.Entry.__init__(self, *args, **kargs) + GObject.GObject.__init__(self, *args, **kargs) self.logger = logging.getLogger('RecentEntry') - self.add_events(gtk.gdk.PROPERTY_CHANGE_MASK) + self.add_events(Gdk.EventMask.PROPERTY_CHANGE_MASK) self._text_changed_handler = self.connect('changed', self._local_change_cb) self._recent = groupthink.Recentest(self.get_text(), groupthink.string_translator) self._recent.register_listener(self._remote_change_cb) @@ -27,12 +31,13 @@ class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry): if self.get_text() != text: #The following code will break if running in any thread other than #the main thread. I do not know how to make code that works with - #both multithreaded gtk _and_ single-threaded gtk. + #both multithreaded gtk _and_ single-threaded Gtk. self.handler_block(self._text_changed_handler) self.set_text(text) self.handler_unblock(self._text_changed_handler) - -class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): + +''' +class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.GenericTreeModel): def __init__(self, columntypes=(), translators=()): self._columntypes = columntypes self._causaltree = groupthink.CausalTree() @@ -60,10 +65,10 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): h = handler.copy(str(i)) self._columndicts[i].set_handler(h) - ### Methods necessary to implement gtk.GenericTreeModel ### + ### Methods necessary to implement Gtk.GenericTreeModel ### def on_get_flags(self): - return gtk.TREE_MODEL_ITERS_PERSIST + return Gtk.TREE_MODEL_ITERS_PERSIST def on_get_n_columns(self): return len(self._columntypes) @@ -186,9 +191,9 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): for cmd in reverse: clean = True if cmd[0] == self._causaltree.SET_PARENT: - if (clean and - cmd[2] in self._causaltree and - (cmd[1] not in self._causaltree or + if (clean and + cmd[2] in self._causaltree and + (cmd[1] not in self._causaltree or cmd[2] != self._causaltree.get_parent(cmd[1]))): clean = False @@ -219,7 +224,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): self.row_has_child_toggled(path, it) self.emit('changed') - ### Methods for resembling gtk.TreeStore ### + ### Methods for resembling Gtk.TreeStore ### def set_value(self, it, column, value): node = self.get_user_data(it) @@ -283,7 +288,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): def move(self, it, newparent): node = self.get_user_data(row) p = self.get_user_data(newparent) - self._causaltree.change_parent(node,p) + self._causaltree.change_parent(node,p)''' class TextBufferUnorderedStringLinker: def __init__(self,tb,us): @@ -320,18 +325,17 @@ class TextBufferUnorderedStringLinker: self._tb.handler_unblock(self._insert_handler) self._tb.handler_unblock(self._delete_handler) - class TextBufferSharePoint(groupthink.UnorderedHandlerAcceptor): def __init__(self, buff): self._us = groupthink.UnorderedString(buff.get_text(buff.get_start_iter(), buff.get_end_iter())) - self._linker = TextBufferUnorderedStringLinker(buff, self._us) + self._linker = TextBufferUnorderedStringLinker(buff, self._us) def set_handler(self, handler): self._us.set_handler(handler) -class SharedTextView(groupthink.UnorderedHandlerAcceptor, gtk.TextView): +class SharedTextView(groupthink.UnorderedHandlerAcceptor, Gtk.TextView): def __init__(self, *args, **kargs): - gtk.TextView.__init__(self, *args, **kargs) + GObject.GObject.__init__(self, *args, **kargs) self._link = TextBufferSharePoint(self.get_buffer()) def set_handler(self, handler): diff --git a/groupthink/sugar_tools.py b/groupthink/sugar_tools.py index 66d4a0e..cb651c6 100644 --- a/groupthink/sugar_tools.py +++ b/groupthink/sugar_tools.py @@ -16,28 +16,21 @@ import logging import telepathy - -from sugar.activity.activity import Activity, ActivityToolbox -from sugar.presence import presenceservice - -from sugar.presence.tubeconn import TubeConnection -from sugar.graphics.window import Window - -import gtk -import gobject - +import gi +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GObject +from sugar3.activity.activity import Activity +from sugar3.presence import presenceservice +from sugar3.presence.tubeconn import TubeConnection +from sugar3.graphics.window import Window +from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton +from sugar3.activity.widgets import ActivityToolbarButton import groupthink_base as groupthink -OLD_TOOLBAR = False -try: - from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton - from sugar.activity.widgets import ActivityToolbarButton -except ImportError: - OLD_TOOLBAR = True - def exhaust_event_loop(): - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() class GroupActivity(Activity): @@ -49,7 +42,7 @@ class GroupActivity(Activity): def __init__(self, handle): # self.initiating indicates whether this instance has initiated sharing # it always starts false, but will be set to true if this activity - # initiates sharing. In particular, if Activity.__init__ calls + # initiates sharing. In particular, if Activity.__init__ calls # self.share(), self.initiating will be set to True. self.initiating = False # self._processed_share indicates whether when_shared() has been called @@ -65,31 +58,26 @@ class GroupActivity(Activity): self._handle = handle - ##gobject.threads_init() + ##GObject.threads_init() - self._sharing_completed = not self._shared_activity + #self._sharing_completed = not self._shared_activity self._readfile_completed = not handle.object_id - if self._shared_activity: - self.message = self.message_joining - elif handle.object_id: - self.message = self.message_loading - else: - self.message = self.message_preparing + #if self._shared_activity: + # self.message = self.message_joining + #elif handle.object_id: + # self.message = self.message_loading + #else: + # self.message = self.message_preparing + self.message = "Shared No Funciona" - if OLD_TOOLBAR: - self.toolbox = ActivityToolbox(self) - self.set_toolbox(self.toolbox) - self.toolbox.show() - self.set_toolbox(self.toolbox) - else: - toolbar_box = ToolbarBox() - self.activity_button = ActivityToolbarButton(self) - toolbar_box.toolbar.insert(self.activity_button, 0) - self.set_toolbar_box(toolbar_box) + toolbar_box = ToolbarBox() + self.activity_button = ActivityToolbarButton(self) + toolbar_box.toolbar.insert(self.activity_button, 0) + self.set_toolbar_box(toolbar_box) - v = gtk.VBox() - self.startup_label = gtk.Label(self.message) - v.pack_start(self.startup_label) + v = Gtk.VBox() + self.startup_label = Gtk.Label(label=self.message) + v.pack_start(self.startup_label, True, True, 0) Window.set_canvas(self,v) self.show_all() @@ -117,22 +105,22 @@ class GroupActivity(Activity): owner = self.pservice.get_owner() self.owner = owner - self.connect('shared', self._shared_cb) - self.connect('joined', self._joined_cb) - if self.get_shared(): - if self.initiating: - self._shared_cb(self) - else: - self._joined_cb(self) + #self.connect('shared', self._shared_cb) + #self.connect('joined', self._joined_cb) + #if self.get_shared(): + # if self.initiating: + # self._shared_cb(self) + # else: + # self._joined_cb(self) - self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) + self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK) self.connect("visibility-notify-event", self._visible_cb) self.connect("notify::active", self._active_cb) if not self._readfile_completed: self.read_file(self._jobject.file_path) - elif not self._shared_activity: - gobject.idle_add(self._initialize_cleanstart) + #elif not self._shared_activity: + # GObject.idle_add(self._initialize_cleanstart) def _initialize_cleanstart(self): self.initialize_cleanstart() @@ -154,18 +142,19 @@ class GroupActivity(Activity): main_widget = self.initialize_display() Window.set_canvas(self, main_widget) self.initialized = True + ''' if self._shared_activity and not self._processed_share: # We are joining a shared activity, but when_shared has not yet # been called self.when_shared() - self._processed_share = True + self._processed_share = True''' self.show_all() def initialize_display(self): """All subclasses must override this method, in order to display their GUI using self.set_canvas()""" raise NotImplementedError - + ''' def share(self, private=False): """The purpose of this function is solely to permit us to determine whether share() has been called. This is necessary because share() may @@ -238,20 +227,21 @@ class GroupActivity(Activity): self.tubebox.insert_tube(tube_conn, self.initiating) self._sharing_completed = True if self._readfile_completed and not self.initialized: - self._initialize_display() + self._initialize_display()''' def read_file(self, file_path): self.cloud.loads(self.load_from_journal(file_path)) self._readfile_completed = True - if self._sharing_completed and not self.initialized: - self._initialize_display() + #if self._sharing_completed and not self.initialized: + # self._initialize_display() + self._initialize_display() pass def load_from_journal(self, file_path): """This implementation of load_from_journal simply returns the contents of the file. Any inheritor overriding this method must return the string provided to save_to_journal as cloudstring.""" - if file_path: + if file_path: f = file(file_path,'rb') s = f.read() f.close() @@ -265,12 +255,12 @@ class GroupActivity(Activity): # read) before writing. if not self._readfile_completed: self.read_file(self._jobject.file_path) - self.save_to_journal(file_path, self.cloud.dumps()) + self.save_to_journal(file_path, self.cloud.dumps()) def save_to_journal(self, file_path, cloudstring): - """This implementation of save_to_journal simply dumps the output of + """This implementation of save_to_journal simply dumps the output of self.cloud.dumps() to disk. Any inheritor who wishes to control file - output should override this method, and must + output should override this method, and must be sure to include cloudstring in its write_file.""" f = file(file_path, 'wb') f.write(cloudstring) @@ -285,7 +275,7 @@ class GroupActivity(Activity): def _visible_cb(self, widget, event): self.logger.debug("_visible_cb") - if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED: + if event.get_state() == Gdk.VisibilityState.FULLY_OBSCURED: self.pause() else: self.resume() diff --git a/library/pippy/physics/Box2D2.py b/library/pippy/physics/Box2D2.py index 5d444e2..294d4ca 100755 --- a/library/pippy/physics/Box2D2.py +++ b/library/pippy/physics/Box2D2.py @@ -79,7 +79,7 @@ class b2Version(_object): __swig_setmethods__["revision"] = _Box2D2.b2Version_revision_set __swig_getmethods__["revision"] = _Box2D2.b2Version_revision_get if _newclass:revision = _swig_property(_Box2D2.b2Version_revision_get, _Box2D2.b2Version_revision_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Version""" this = _Box2D2.new_b2Version(*args) try: self.this.append(this) @@ -125,7 +125,7 @@ class b2Vec2(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2Vec2, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """ __init__(self) -> b2Vec2 __init__(self, float32 x, float32 y) -> b2Vec2 @@ -208,7 +208,7 @@ class b2Mat22(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2Mat22, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """ __init__(self) -> b2Mat22 __init__(self, b2Vec2 c1, b2Vec2 c2) -> b2Mat22 @@ -263,7 +263,7 @@ class b2XForm(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2XForm, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """ __init__(self) -> b2XForm __init__(self, b2Vec2 position, b2Mat22 R) -> b2XForm @@ -319,7 +319,7 @@ class b2Sweep(_object): __swig_setmethods__["t0"] = _Box2D2.b2Sweep_t0_set __swig_getmethods__["t0"] = _Box2D2.b2Sweep_t0_get if _newclass:t0 = _swig_property(_Box2D2.b2Sweep_t0_get, _Box2D2.b2Sweep_t0_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Sweep""" this = _Box2D2.new_b2Sweep(*args) try: self.this.append(this) @@ -390,7 +390,7 @@ class b2ContactID(_object): if _newclass:key = _swig_property(_Box2D2.b2ContactID_key_get, _Box2D2.b2ContactID_key_set) __swig_getmethods__["features"] = _Box2D2.b2ContactID_features_get if _newclass:features = _swig_property(_Box2D2.b2ContactID_features_get) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactID""" this = _Box2D2.new_b2ContactID(*args) try: self.this.append(this) @@ -464,7 +464,7 @@ class b2ContactID_features(_object): __swig_setmethods__["flip"] = _Box2D2.b2ContactID_features_flip_set __swig_getmethods__["flip"] = _Box2D2.b2ContactID_features_flip_get if _newclass:flip = _swig_property(_Box2D2.b2ContactID_features_flip_get, _Box2D2.b2ContactID_features_flip_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactID_features""" this = _Box2D2.new_b2ContactID_features(*args) try: self.this.append(this) @@ -499,7 +499,7 @@ class b2ManifoldPoint(_object): __swig_setmethods__["id"] = _Box2D2.b2ManifoldPoint_id_set __swig_getmethods__["id"] = _Box2D2.b2ManifoldPoint_id_get if _newclass:id = _swig_property(_Box2D2.b2ManifoldPoint_id_get, _Box2D2.b2ManifoldPoint_id_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ManifoldPoint""" this = _Box2D2.new_b2ManifoldPoint(*args) try: self.this.append(this) @@ -525,7 +525,7 @@ class b2Manifold(_object): __swig_setmethods__["pointCount"] = _Box2D2.b2Manifold_pointCount_set __swig_getmethods__["pointCount"] = _Box2D2.b2Manifold_pointCount_get if _newclass:pointCount = _swig_property(_Box2D2.b2Manifold_pointCount_get, _Box2D2.b2Manifold_pointCount_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Manifold""" this = _Box2D2.new_b2Manifold(*args) try: self.this.append(this) @@ -552,7 +552,7 @@ class b2Segment(_object): __swig_setmethods__["p2"] = _Box2D2.b2Segment_p2_set __swig_getmethods__["p2"] = _Box2D2.b2Segment_p2_get if _newclass:p2 = _swig_property(_Box2D2.b2Segment_p2_get, _Box2D2.b2Segment_p2_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Segment""" this = _Box2D2.new_b2Segment(*args) try: self.this.append(this) @@ -579,7 +579,7 @@ class b2AABB(_object): __swig_setmethods__["upperBound"] = _Box2D2.b2AABB_upperBound_set __swig_getmethods__["upperBound"] = _Box2D2.b2AABB_upperBound_get if _newclass:upperBound = _swig_property(_Box2D2.b2AABB_upperBound_get, _Box2D2.b2AABB_upperBound_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2AABB""" this = _Box2D2.new_b2AABB(*args) try: self.this.append(this) @@ -605,7 +605,7 @@ class b2OBB(_object): __swig_setmethods__["extents"] = _Box2D2.b2OBB_extents_set __swig_getmethods__["extents"] = _Box2D2.b2OBB_extents_get if _newclass:extents = _swig_property(_Box2D2.b2OBB_extents_get, _Box2D2.b2OBB_extents_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2OBB""" this = _Box2D2.new_b2OBB(*args) try: self.this.append(this) @@ -618,21 +618,21 @@ b2OBB_swigregister(b2OBB) def b2CollideCircles(*args): """ - b2CollideCircles(b2Manifold manifold, b2CircleShape circle1, b2XForm xf1, + b2CollideCircles(b2Manifold manifold, b2CircleShape circle1, b2XForm xf1, b2CircleShape circle2, b2XForm xf2) """ return _Box2D2.b2CollideCircles(*args) def b2CollidePolygonAndCircle(*args): """ - b2CollidePolygonAndCircle(b2Manifold manifold, b2PolygonShape polygon, b2XForm xf1, + b2CollidePolygonAndCircle(b2Manifold manifold, b2PolygonShape polygon, b2XForm xf1, b2CircleShape circle, b2XForm xf2) """ return _Box2D2.b2CollidePolygonAndCircle(*args) def b2CollidePolygons(*args): """ - b2CollidePolygons(b2Manifold manifold, b2PolygonShape polygon1, b2XForm xf1, + b2CollidePolygons(b2Manifold manifold, b2PolygonShape polygon1, b2XForm xf1, b2PolygonShape polygon2, b2XForm xf2) """ return _Box2D2.b2CollidePolygons(*args) @@ -660,7 +660,7 @@ class b2MassData(_object): __swig_setmethods__["I"] = _Box2D2.b2MassData_I_set __swig_getmethods__["I"] = _Box2D2.b2MassData_I_get if _newclass:I = _swig_property(_Box2D2.b2MassData_I_get, _Box2D2.b2MassData_I_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2MassData""" this = _Box2D2.new_b2MassData(*args) try: self.this.append(this) @@ -673,7 +673,7 @@ b2MassData_swigregister(b2MassData) def b2Distance(*args): """ b2Distance(b2Vec2 a, b2Vec2 b) -> float32 - b2Distance(b2Vec2 x1, b2Vec2 x2, b2Shape shape1, b2XForm xf1, + b2Distance(b2Vec2 x1, b2Vec2 x2, b2Shape shape1, b2XForm xf1, b2Shape shape2, b2XForm xf2) -> float32 """ return _Box2D2.b2Distance(*args) @@ -689,7 +689,7 @@ class b2ShapeDef(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2ShapeDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ShapeDef""" this = _Box2D2.new_b2ShapeDef(*args) try: self.this.append(this) @@ -760,7 +760,7 @@ class b2Shape(_object): def TestSegment(*args): """ - TestSegment(self, b2XForm xf, float32 lambda, b2Vec2 normal, b2Segment segment, + TestSegment(self, b2XForm xf, float32 lambda, b2Vec2 normal, b2Segment segment, float32 maxLambda) -> bool """ return _Box2D2.b2Shape_TestSegment(*args) @@ -894,7 +894,7 @@ class b2CircleDef(b2ShapeDef): for _s in [b2ShapeDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2CircleDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2CircleDef""" this = _Box2D2.new_b2CircleDef(*args) try: self.this.append(this) @@ -925,7 +925,7 @@ class b2CircleShape(b2Shape): def TestSegment(*args): """ - TestSegment(self, b2XForm transform, float32 lambda, b2Vec2 normal, b2Segment segment, + TestSegment(self, b2XForm transform, float32 lambda, b2Vec2 normal, b2Segment segment, float32 maxLambda) -> bool """ return _Box2D2.b2CircleShape_TestSegment(*args) @@ -950,7 +950,7 @@ class b2CircleShape(b2Shape): """GetRadius(self) -> float32""" return _Box2D2.b2CircleShape_GetRadius(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2ShapeDef def) -> b2CircleShape""" this = _Box2D2.new_b2CircleShape(*args) try: self.this.append(this) @@ -979,7 +979,7 @@ class b2PolygonDef(b2ShapeDef): for _s in [b2ShapeDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2PolygonDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2PolygonDef""" this = _Box2D2.new_b2PolygonDef(*args) try: self.this.append(this) @@ -1025,7 +1025,7 @@ class b2PolygonShape(b2Shape): def TestSegment(*args): """ - TestSegment(self, b2XForm transform, float32 lambda, b2Vec2 normal, b2Segment segment, + TestSegment(self, b2XForm transform, float32 lambda, b2Vec2 normal, b2Segment segment, float32 maxLambda) -> bool """ return _Box2D2.b2PolygonShape_TestSegment(*args) @@ -1062,7 +1062,7 @@ class b2PolygonShape(b2Shape): """GetCoreVertices(self) -> b2Vec2""" return _Box2D2.b2PolygonShape_GetCoreVertices(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2ShapeDef def) -> b2PolygonShape""" this = _Box2D2.new_b2PolygonShape(*args) try: self.this.append(this) @@ -1170,7 +1170,7 @@ class b2Pair(_object): __swig_setmethods__["status"] = _Box2D2.b2Pair_status_set __swig_getmethods__["status"] = _Box2D2.b2Pair_status_get if _newclass:status = _swig_property(_Box2D2.b2Pair_status_get, _Box2D2.b2Pair_status_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Pair""" this = _Box2D2.new_b2Pair(*args) try: self.this.append(this) @@ -1197,7 +1197,7 @@ class b2BufferedPair(_object): __swig_setmethods__["proxyId2"] = _Box2D2.b2BufferedPair_proxyId2_set __swig_getmethods__["proxyId2"] = _Box2D2.b2BufferedPair_proxyId2_get if _newclass:proxyId2 = _swig_property(_Box2D2.b2BufferedPair_proxyId2_get, _Box2D2.b2BufferedPair_proxyId2_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2BufferedPair""" this = _Box2D2.new_b2BufferedPair(*args) try: self.this.append(this) @@ -1235,7 +1235,7 @@ class b2PairManager(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2PairManager, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2PairManager""" this = _Box2D2.new_b2PairManager(*args) try: self.this.append(this) @@ -1309,7 +1309,7 @@ class b2Bound(_object): __swig_setmethods__["stabbingCount"] = _Box2D2.b2Bound_stabbingCount_set __swig_getmethods__["stabbingCount"] = _Box2D2.b2Bound_stabbingCount_get if _newclass:stabbingCount = _swig_property(_Box2D2.b2Bound_stabbingCount_get, _Box2D2.b2Bound_stabbingCount_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Bound""" this = _Box2D2.new_b2Bound(*args) try: self.this.append(this) @@ -1355,7 +1355,7 @@ class b2Proxy(_object): __swig_setmethods__["userData"] = _Box2D2.b2Proxy_userData_set __swig_getmethods__["userData"] = _Box2D2.b2Proxy_userData_get if _newclass:userData = _swig_property(_Box2D2.b2Proxy_userData_get, _Box2D2.b2Proxy_userData_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Proxy""" this = _Box2D2.new_b2Proxy(*args) try: self.this.append(this) @@ -1372,7 +1372,7 @@ class b2BroadPhase(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2BroadPhase, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2AABB worldAABB, b2PairCallback callback) -> b2BroadPhase""" this = _Box2D2.new_b2BroadPhase(*args) try: self.this.append(this) @@ -1467,7 +1467,7 @@ class b2DestructionListener(_object): """ return _Box2D2.b2DestructionListener_SayGoodbye(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2DestructionListener""" if self.__class__ == b2DestructionListener: args = (None,) + args @@ -1496,7 +1496,7 @@ class b2BoundaryListener(_object): """Violation(self, b2Body body)""" return _Box2D2.b2BoundaryListener_Violation(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2BoundaryListener""" if self.__class__ == b2BoundaryListener: args = (None,) + args @@ -1525,7 +1525,7 @@ class b2ContactFilter(_object): """ShouldCollide(self, b2Shape shape1, b2Shape shape2) -> bool""" return _Box2D2.b2ContactFilter_ShouldCollide(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactFilter""" this = _Box2D2.new_b2ContactFilter(*args) try: self.this.append(this) @@ -1554,7 +1554,7 @@ class b2ContactListener(_object): """Remove(self, b2ContactPoint point)""" return _Box2D2.b2ContactListener_Remove(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactListener""" if self.__class__ == b2ContactListener: args = (None,) + args @@ -1577,7 +1577,7 @@ class b2Color(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2Color, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """ __init__(self) -> b2Color __init__(self, float32 r, float32 g, float32 b) -> b2Color @@ -1606,7 +1606,7 @@ class b2DebugDraw(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2DebugDraw, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2DebugDraw""" if self.__class__ == b2DebugDraw: args = (None,) + args @@ -1678,7 +1678,7 @@ class b2BlockAllocator(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2BlockAllocator, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2BlockAllocator""" this = _Box2D2.new_b2BlockAllocator(*args) try: self.this.append(this) @@ -1720,7 +1720,7 @@ class b2StackEntry(_object): __swig_setmethods__["usedMalloc"] = _Box2D2.b2StackEntry_usedMalloc_set __swig_getmethods__["usedMalloc"] = _Box2D2.b2StackEntry_usedMalloc_get if _newclass:usedMalloc = _swig_property(_Box2D2.b2StackEntry_usedMalloc_get, _Box2D2.b2StackEntry_usedMalloc_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2StackEntry""" this = _Box2D2.new_b2StackEntry(*args) try: self.this.append(this) @@ -1739,7 +1739,7 @@ class b2StackAllocator(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2StackAllocator, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2StackAllocator""" this = _Box2D2.new_b2StackAllocator(*args) try: self.this.append(this) @@ -1777,7 +1777,7 @@ class b2ContactRegister(_object): __swig_setmethods__["primary"] = _Box2D2.b2ContactRegister_primary_set __swig_getmethods__["primary"] = _Box2D2.b2ContactRegister_primary_get if _newclass:primary = _swig_property(_Box2D2.b2ContactRegister_primary_get, _Box2D2.b2ContactRegister_primary_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactRegister""" this = _Box2D2.new_b2ContactRegister(*args) try: self.this.append(this) @@ -1806,7 +1806,7 @@ class b2ContactEdge(_object): __swig_setmethods__["next"] = _Box2D2.b2ContactEdge_next_set __swig_getmethods__["next"] = _Box2D2.b2ContactEdge_next_get if _newclass:next = _swig_property(_Box2D2.b2ContactEdge_next_get, _Box2D2.b2ContactEdge_next_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactEdge""" this = _Box2D2.new_b2ContactEdge(*args) try: self.this.append(this) @@ -1850,7 +1850,7 @@ class b2ContactPoint(_object): def __repr__(self): return "b2ContactPoint(\n\tShape1: %s\n\tShape2:%s\n\tPosition: %s\n\tNormal: %s)" % (self.shape1, self.shape2, self.position, self.normal) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactPoint""" this = _Box2D2.new_b2ContactPoint(*args) try: self.this.append(this) @@ -1898,7 +1898,7 @@ class b2Contact(_object): e_toiFlag = _Box2D2.b2Contact_e_toiFlag def AddType(*args): """ - AddType(b2ContactCreateFcn createFcn, b2ContactDestroyFcn destroyFcn, + AddType(b2ContactCreateFcn createFcn, b2ContactDestroyFcn destroyFcn, b2ShapeType type1, b2ShapeType type2) """ return _Box2D2.b2Contact_AddType(*args) @@ -1977,7 +1977,7 @@ b2Contact_swigregister(b2Contact) def b2Contact_AddType(*args): """ - b2Contact_AddType(b2ContactCreateFcn createFcn, b2ContactDestroyFcn destroyFcn, + b2Contact_AddType(b2ContactCreateFcn createFcn, b2ContactDestroyFcn destroyFcn, b2ShapeType type1, b2ShapeType type2) """ return _Box2D2.b2Contact_AddType(*args) @@ -2003,7 +2003,7 @@ class b2NullContact(b2Contact): for _s in [b2Contact]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2NullContact, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2NullContact""" this = _Box2D2.new_b2NullContact(*args) try: self.this.append(this) @@ -2030,7 +2030,7 @@ class b2ContactManager(b2PairCallback): for _s in [b2PairCallback]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2ContactManager, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2ContactManager""" this = _Box2D2.new_b2ContactManager(*args) try: self.this.append(this) @@ -2081,7 +2081,7 @@ class b2TimeStep(_object): __swig_setmethods__["maxIterations"] = _Box2D2.b2TimeStep_maxIterations_set __swig_getmethods__["maxIterations"] = _Box2D2.b2TimeStep_maxIterations_get if _newclass:maxIterations = _swig_property(_Box2D2.b2TimeStep_maxIterations_get, _Box2D2.b2TimeStep_maxIterations_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2TimeStep""" this = _Box2D2.new_b2TimeStep(*args) try: self.this.append(this) @@ -2098,7 +2098,7 @@ class b2World(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2World, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2AABB worldAABB, b2Vec2 gravity, bool doSleep) -> b2World""" this = _Box2D2.new_b2World(*args) try: self.this.append(this) @@ -2299,7 +2299,7 @@ class b2Jacobian(_object): """Compute(self, b2Vec2 x1, float32 a1, b2Vec2 x2, float32 a2) -> float32""" return _Box2D2.b2Jacobian_Compute(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2Jacobian""" this = _Box2D2.new_b2Jacobian(*args) try: self.this.append(this) @@ -2328,7 +2328,7 @@ class b2JointEdge(_object): __swig_setmethods__["next"] = _Box2D2.b2JointEdge_next_set __swig_getmethods__["next"] = _Box2D2.b2JointEdge_next_get if _newclass:next = _swig_property(_Box2D2.b2JointEdge_next_get, _Box2D2.b2JointEdge_next_set) - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2JointEdge""" this = _Box2D2.new_b2JointEdge(*args) try: self.this.append(this) @@ -2345,7 +2345,7 @@ class b2JointDef(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2JointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2JointDef""" this = _Box2D2.new_b2JointDef(*args) try: self.this.append(this) @@ -2478,7 +2478,7 @@ class b2Joint(_object): return "b2Joint(body1: %s body2: %s)" % (self.body1, self.body2) def typeName(self): types = { e_unknownJoint : "Unknown", - e_mouseJoint : "Mouse", + e_mouseJoint : "Mouse", e_gearJoint : "Gear", e_distanceJoint : "Distance", e_prismaticJoint: "Prismatic", @@ -2531,7 +2531,7 @@ class b2BodyDef(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, b2BodyDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2BodyDef""" this = _Box2D2.new_b2BodyDef(*args) try: self.this.append(this) @@ -2731,7 +2731,7 @@ class b2Body(_object): e_staticType = _Box2D2.b2Body_e_staticType e_dynamicType = _Box2D2.b2Body_e_dynamicType e_maxTypes = _Box2D2.b2Body_e_maxTypes - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2BodyDef bd, uint16 type, b2World world) -> b2Body""" this = _Box2D2.new_b2Body(*args) try: self.this.append(this) @@ -2842,7 +2842,7 @@ class b2DistanceJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2DistanceJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2DistanceJointDef""" this = _Box2D2.new_b2DistanceJointDef(*args) try: self.this.append(this) @@ -2890,7 +2890,7 @@ class b2DistanceJoint(b2Joint): """GetReactionTorque(self) -> float32""" return _Box2D2.b2DistanceJoint_GetReactionTorque(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2DistanceJointDef data) -> b2DistanceJoint""" this = _Box2D2.new_b2DistanceJoint(*args) try: self.this.append(this) @@ -2939,7 +2939,7 @@ class b2MouseJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2MouseJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2MouseJointDef""" this = _Box2D2.new_b2MouseJointDef(*args) try: self.this.append(this) @@ -2993,7 +2993,7 @@ class b2MouseJoint(b2Joint): """SetTarget(self, b2Vec2 target)""" return _Box2D2.b2MouseJoint_SetTarget(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2MouseJointDef def) -> b2MouseJoint""" this = _Box2D2.new_b2MouseJoint(*args) try: self.this.append(this) @@ -3048,7 +3048,7 @@ class b2PrismaticJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2PrismaticJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2PrismaticJointDef""" this = _Box2D2.new_b2PrismaticJointDef(*args) try: self.this.append(this) @@ -3169,7 +3169,7 @@ class b2PrismaticJoint(b2Joint): """GetMotorForce(self) -> float32""" return _Box2D2.b2PrismaticJoint_GetMotorForce(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2PrismaticJointDef def) -> b2PrismaticJoint""" this = _Box2D2.new_b2PrismaticJoint(*args) try: self.this.append(this) @@ -3266,7 +3266,7 @@ class b2RevoluteJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2RevoluteJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2RevoluteJointDef""" this = _Box2D2.new_b2RevoluteJointDef(*args) try: self.this.append(this) @@ -3384,7 +3384,7 @@ class b2RevoluteJoint(b2Joint): """GetMotorTorque(self) -> float32""" return _Box2D2.b2RevoluteJoint_GetMotorTorque(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2RevoluteJointDef def) -> b2RevoluteJoint""" this = _Box2D2.new_b2RevoluteJoint(*args) try: self.this.append(this) @@ -3463,15 +3463,15 @@ class b2PulleyJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2PulleyJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2PulleyJointDef""" this = _Box2D2.new_b2PulleyJointDef(*args) try: self.this.append(this) except: self.this = this def Initialize(*args): """ - Initialize(self, b2Body body1, b2Body body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, - b2Vec2 anchor1, b2Vec2 anchor2, + Initialize(self, b2Body body1, b2Body body2, b2Vec2 groundAnchor1, b2Vec2 groundAnchor2, + b2Vec2 anchor1, b2Vec2 anchor2, float32 ratio) """ return _Box2D2.b2PulleyJointDef_Initialize(*args) @@ -3554,7 +3554,7 @@ class b2PulleyJoint(b2Joint): """GetRatio(self) -> float32""" return _Box2D2.b2PulleyJoint_GetRatio(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2PulleyJointDef data) -> b2PulleyJoint""" this = _Box2D2.new_b2PulleyJoint(*args) try: self.this.append(this) @@ -3654,7 +3654,7 @@ class b2GearJointDef(b2JointDef): for _s in [b2JointDef]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) __getattr__ = lambda self, name: _swig_getattr(self, b2GearJointDef, name) __repr__ = _swig_repr - def __init__(self, *args): + def __init__(self, *args): """__init__(self) -> b2GearJointDef""" this = _Box2D2.new_b2GearJointDef(*args) try: self.this.append(this) @@ -3702,7 +3702,7 @@ class b2GearJoint(b2Joint): """GetRatio(self) -> float32""" return _Box2D2.b2GearJoint_GetRatio(*args) - def __init__(self, *args): + def __init__(self, *args): """__init__(self, b2GearJointDef data) -> b2GearJoint""" this = _Box2D2.new_b2GearJoint(*args) try: self.this.append(this) diff --git a/library/pippy/physics/add_objects.py b/library/pippy/physics/add_objects.py index 66f3b8f..1c22c16 100644 --- a/library/pippy/physics/add_objects.py +++ b/library/pippy/physics/add_objects.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ from locals import * from elements import box2d @@ -90,8 +90,8 @@ class Add: x, y = pos bodyDef = box2d.b2BodyDef() bodyDef.position.Set(x, y) - bodyDef.sleepFlag = True -# bodyDef.allowSleep(True) + bodyDef.sleepFlag = True + # bodyDef.allowSleep(True) userData = { 'color' : self.parent.get_color() } bodyDef.userData = userData @@ -112,9 +112,9 @@ class Add: circleDef.friction = friction body.CreateShape(circleDef) - body.SetMassFromShapes(); + body.SetMassFromShapes(); - return body + return body def rect(self, pos, width, height, angle=0, dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=True): """ Add a dynamic rectangle with input unit according to self.input (INPUT_PIXELS or INPUT_METERS) @@ -147,22 +147,22 @@ class Add: def wall(self, pos1, pos2, width=5, density=1.0, restitution=0.16, friction=0.5, screenCoord=True): - """ Add a static rectangle between two arbitrary points with input unit according to self.input + """ Add a static rectangle between two arbitrary points with input unit according to self.input (INPUT_PIXELS or INPUT_METERS) Correcting the positions to meters and calling self._add_rect() Return: box2d.b2Body """ if width < 5: width = 5 - if (pos1[0] < pos2[0]): + if (pos1[0] < pos2[0]): x1, y1 = pos1 x2, y2 = pos2 else: x1, y1 = pos2 - x2, y2 = pos1 + x2, y2 = pos1 # Bring coordinates into the world coordinate system (flip, camera offset, ...) - if screenCoord: + if screenCoord: x1, y1 = self.parent.to_world((x1, y1)) x2, y2 = self.parent.to_world((x2, y2)) @@ -198,7 +198,7 @@ class Add: if not dynamic: density = 0 - bodyDef.sleepFlag = True + bodyDef.sleepFlag = True body = self.parent.world.CreateBody(bodyDef) @@ -227,14 +227,14 @@ class Add: other ... see [physics parameters] Return: box2d.b2Body - """ + """ # Bring coordinates into the world coordinate system (flip, camera offset, ...) if screenCoord: x, y = self.parent.to_world(pos) else: x, y = pos #pos, vertices, dynamic=True, density=1.0, restitution=0.16, friction=0. #5, screenCoord=True print "self.world.add.poly((", x,",", y, "), ", vertices, ", dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=True)" -#"x = " x "y = " y "vertices = " +#"x = " x "y = " y "vertices = " # If required, translate pixel -> meters if self.parent.input == INPUT_PIXELS: # translate pixel -> meters @@ -256,7 +256,7 @@ class Add: x, y = pos bodyDef = box2d.b2BodyDef() bodyDef.position.Set(x, y) - bodyDef.sleepFlag = True + bodyDef.sleepFlag = True userData = { 'color' : self.parent.get_color() } bodyDef.userData = userData @@ -274,7 +274,7 @@ class Add: polyDef.vertexCount = len(vertices) for i in range(len(vertices)): vx, vy = vertices[i] - polyDef.setVertex(i, box2d.b2Vec2(vx, vy)) + polyDef.setVertex(i, box2d.b2Vec2(vx, vy)) polyDef.density = density polyDef.restitution = restitution @@ -286,9 +286,9 @@ class Add: return body def concavePoly(self, vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=True): - # 1. Step: Reduce + # 1. Step: Reduce # Detect if the polygon is closed or open - if vertices[0] != vertices[-1]: + if vertices[0] != vertices[-1]: is_closed = False else: is_closed = True @@ -310,8 +310,8 @@ class Add: # Let's add the body bodyDef = box2d.b2BodyDef() bodyDef.position.Set(x, y) - bodyDef.sleepFlag = True - + bodyDef.sleepFlag = True + userData = { 'color' : self.parent.get_color() } bodyDef.userData = userData @@ -336,7 +336,7 @@ class Add: circleDef.restitution = restitution circleDef.friction = friction - # Set the scale factor + # Set the scale factor factor = 8.0 v2 = box2d.b2Vec2().fromTuple(vertices[0]) @@ -350,10 +350,10 @@ class Add: # we need a little size for the end part vn = box2d.b2Vec2(-vdir.y*factor, vdir.x*factor) - v = [ v1+vn, v1-vn, v2-vn, v2+vn ] + v = [ v1+vn, v1-vn, v2-vn, v2+vn ] - # Create a line (rect) for each part of the polygon, - # and attach it to the body + # Create a line (rect) for each part of the polygon, + # and attach it to the body for i in range(len(v)): polyDef.setVertex(i, v[i] / self.parent.ppm) @@ -370,10 +370,10 @@ class Add: break circleDef.localPosition = v2 / self.parent.ppm - body.CreateShape(circleDef) + body.CreateShape(circleDef) # Now, all shapes have been attached - body.SetMassFromShapes() + body.SetMassFromShapes() # Return hard and soft reduced vertices return body @@ -383,7 +383,7 @@ class Add: # 2. Step: See if start and end are close, if so then close the polygon # 3. Step: Detect if convex or concave # 4. Step: Start self.convexPoly or self.concavePoly - vertices, is_convex = tools_poly.reduce_poly_by_angle(vertices) + vertices, is_convex = tools_poly.reduce_poly_by_angle(vertices) #print "->", is_convex # If start and endpoints are close to each other, close polygon @@ -409,13 +409,13 @@ class Add: return self.convexPoly(vertices, dynamic, density, restitution, friction), vertices else: print "concave" - return self.concavePoly(vertices, dynamic, density, restitution, friction), vertices + return self.concavePoly(vertices, dynamic, density, restitution, friction), vertices def convexPoly(self, vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5): """ Add a complex polygon with vertices in absolute positions (meters or pixels, according - to INPUT_PIXELS or INPUT_METERS). This function does the reduction and convec hulling - of the poly, and calls add_poly(...) + to INPUT_PIXELS or INPUT_METERS). This function does the reduction and convec hulling + of the poly, and calls add_poly(...) Parameters: vertices .. absolute vertices positions @@ -429,7 +429,7 @@ class Add: tolerance = 10 #5 v_new = vertices while len(v_new) > box2d.b2_maxPolygonVertices: - tolerance += 1 + tolerance += 1 v_new = tools_poly.reduce_poly(vertices, tolerance) print "convexPoly: Polygon reduced from %i to %i vertices | tolerance: %i" % (len(vertices), len(v_new), tolerance) @@ -437,13 +437,13 @@ class Add: # So poly should be alright now # Continue reducing the vertecs - vertices_orig_reduced = vertices + vertices_orig_reduced = vertices vertices = tools_poly.poly_center_vertices(vertices) vertices = tools_poly.convex_hull(vertices) - if len(vertices) < 3: - return + if len(vertices) < 3: + return # Define the body x, y = c = tools_poly.calc_center(vertices_orig_reduced) @@ -455,24 +455,24 @@ class Add: ptx /= self.parent.ppm pty /= self.parent.ppm pt = box2d.b2Vec2(ptx, pty) - return pt + return pt # Alex Levenson's added joint methods: def distanceJoint(self,b1,b2,p1,p2): # Distance Joint - p1 = self.to_b2vec(p1) - p2 = self.to_b2vec(p2) + p1 = self.to_b2vec(p1) + p2 = self.to_b2vec(p2) jointDef = box2d.b2DistanceJointDef() jointDef.Initialize(b1, b2, p1, p2) - jointDef.collideConnected = True + jointDef.collideConnected = True self.parent.world.CreateJoint(jointDef) def fixedJoint(self, *args): - if len(args) == 2: + if len(args) == 2: # Fixed Joint to the Background, don't assume the center of the body b1 = self.parent.world.GetGroundBody() b2 = args[0] - p1 = self.to_b2vec(args[1]) + p1 = self.to_b2vec(args[1]) jointDef = box2d.b2RevoluteJointDef() jointDef.Initialize(b1, b2, p1) @@ -486,11 +486,11 @@ class Add: jointDef = box2d.b2RevoluteJointDef() jointDef.Initialize(b1, b2, p1) - self.parent.world.CreateJoint(jointDef) + self.parent.world.CreateJoint(jointDef) def revoluteJoint(self,b1,b2,p1): # revolute joint between to bodies - p1 = self.to_b2vec(p1) + p1 = self.to_b2vec(p1) jointDef = box2d.b2RevoluteJointDef() jointDef.Initialize(b1, b2, p1) @@ -521,10 +521,10 @@ class Add: self.parent.world.CreateJoint(jointDef) - def motor(self, body,pt,torque=900,speed=-10): + def motor(self, body,pt,torque=900,speed=-10): # Fixed Joint to the Background with a motor on it b1 = self.parent.world.GetGroundBody() - pt = self.to_b2vec(pt) + pt = self.to_b2vec(pt) jointDef = box2d.b2RevoluteJointDef() jointDef.Initialize(b1, body, pt) @@ -537,16 +537,16 @@ class Add: # jointDef = box2d.b2RevoluteJointDef() # jointDef.Initialize(b1, b2, p1) # jointDef. - # - def joint(self, *args): + # + def joint(self, *args): print "* Add Joint:", args if len(args) == 4: # Distance Joint b1, b2, p1, p2 = args - p1 = self.parent.to_world(p1) - p2 = self.parent.to_world(p2) + p1 = self.parent.to_world(p1) + p2 = self.parent.to_world(p2) p1x, p1y = p1 p2x, p2y = p2 @@ -563,7 +563,7 @@ class Add: jointDef.Initialize(b1, b2, p1, p2) jointDef.collideConnected = True - self.parent.world.CreateJoint(jointDef) + self.parent.world.CreateJoint(jointDef) elif len(args) == 3: # Revolute Joint diff --git a/library/pippy/physics/callbacks.py b/library/pippy/physics/callbacks.py index 5402869..e0b1091 100755 --- a/library/pippy/physics/callbacks.py +++ b/library/pippy/physics/callbacks.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,20 +22,20 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ from locals import * from elements import box2d class CallbackHandler: - # List of contact callbacks and shapes to start them - sorted by type for quicker access + # List of contact callbacks and shapes to start them - sorted by type for quicker access # Callbacks are saved as callbacks[callback_type][[function, parameters], ...] - callbacks = {} + callbacks = {} def __init__(self, parent): self.parent = parent - # init callback dict to avoid those slow try + # init callback dict to avoid those slow try # (especially for self.get, as it is called *often*) for i in xrange(10): self.callbacks[i] = [] @@ -79,7 +79,7 @@ class CallbackHandler: callback() class kContactListener(box2d.b2ContactListener): - def __init__(self, get_callbacks): + def __init__(self, get_callbacks): # Init the Box2D b2ContactListener box2d.b2ContactListener.__init__(self) @@ -94,7 +94,7 @@ class kContactListener(box2d.b2ContactListener): for c in contacts: callback, bodylist = c if len(bodylist) == 0: - # Without bodylist it's a universal callback (for all bodies) + # Without bodylist it's a universal callback (for all bodies) callback(point) else: @@ -104,7 +104,7 @@ class kContactListener(box2d.b2ContactListener): b2 = str(point.shape2.GetBody()) for s in bodylist: s = str(s) - if b1 == s or b2 == s: + if b1 == s or b2 == s: # Yes, that's the one :) callback(point) diff --git a/library/pippy/physics/camera.py b/library/pippy/physics/camera.py index c45b27d..553b582 100755 --- a/library/pippy/physics/camera.py +++ b/library/pippy/physics/camera.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ from locals import * @@ -59,7 +59,7 @@ class Camera: Typical call: world.camera.center(event.pos) Problem: Works ONLY WITH screenCoord now! - """ + """ x, y = pos x -= self.parent.display_width / 2 @@ -73,7 +73,7 @@ class Camera: self.inc_offset((x, y), screenCoord, stopTrack) def set_offset(self, offset, screenCoord=True, stopTrack=True): - """ Set an offset from the screen to the world cs + """ Set an offset from the screen to the world cs -- in screen (or world) coordinates and in pixel """ # Stop tracking of an object @@ -107,7 +107,7 @@ class Camera: """ Set the screen offset to the world coordinate system (using meters and the world coordinate system's orientation) """ - x, y = offset + x, y = offset self.parent.screen_offset = (x, y) self.parent.screen_offset_pixel = (x*self.parent.ppm, y*self.parent.ppm) diff --git a/library/pippy/physics/drawing.py b/library/pippy/physics/drawing.py index a537125..d70c9bc 100755 --- a/library/pippy/physics/drawing.py +++ b/library/pippy/physics/drawing.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ from math import pi from math import cos @@ -31,7 +31,7 @@ from math import sqrt import tools -# Functions of a rendering class +# Functions of a rendering class # mandatory: # __init__ # start_drawing @@ -47,7 +47,7 @@ import tools # for cairo: # draw_text # for opengl: -# +# # IMPORTANT # The drawing functions get the coordinates in their screen coordinate system @@ -65,11 +65,11 @@ class draw_pygame(object): Parameters: surface .... pygame surface (default: None) - lineWidth .. + lineWidth .. Return: Class draw_pygame() """ - print "* Pygame selected as renderer" + print "* Pygame selected as renderer" from pygame import draw from pygame import Rect @@ -103,7 +103,7 @@ class draw_pygame(object): Parameters: pt ........ (x, y) clr ....... color in rgb ((r), (g), (b)) - radius .... circle radius + radius .... circle radius angle ..... rotation in radians Return: - @@ -146,7 +146,7 @@ class draw_pygame(object): """ if width == None: lw = self.lineWidth - else: + else: lw = width self.draw.lines(self.surface, clr, closed, points, lw) @@ -173,12 +173,12 @@ class draw_cairo(object): #self.draw_box = self.draw_box_image def set_lineWidth(self, lw): # unused - self.lineWidth = lw + self.lineWidth = lw def set_drawing_area(self, da): """ Set the area for Cairo to draw to - da ...... drawing area (gtk.DrawingArea) + da ...... drawing area (Gtk.DrawingArea) Return: - """ @@ -267,7 +267,7 @@ class draw_cairo(object): points .... polygon points in normal (x,y) positions Return: - - """ + """ clr = tools.rgb2floats(clr) self.ctx.set_source_rgb(clr[0], clr[1], clr[2]) @@ -296,7 +296,7 @@ class draw_cairo(object): closed .... whether or not to close the lines (as a polygon) points .... polygon points in normal (x,y) positions Return: - - """ + """ clr = tools.rgb2floats(clr) self.ctx.set_source_rgb(clr[0], clr[1], clr[2]) @@ -320,7 +320,7 @@ class draw_opengl_pyglet(object): Parameters: surface .... not used with pyglet - lineWidth .. + lineWidth .. """ print "* OpenGL_Pyglet selected as renderer" @@ -332,23 +332,23 @@ class draw_opengl_pyglet(object): def draw_circle(self, clr, pt, radius, a=0): clr = tools.rgb2floats(clr) - self.gl.glColor3f(clr[0], clr[1], clr[2]) + self.gl.glColor3f(clr[0], clr[1], clr[2]) x, y = pt - segs = 15 - coef = 2.0*pi/segs; - - self.gl.glBegin(self.gl.GL_LINE_LOOP) - for n in range(segs): - rads = n*coef - self.gl.glVertex2f(radius*cos(rads + a) + x, radius*sin(rads + a) + y) - self.gl.glVertex2f(x,y) - self.gl.glEnd() + segs = 15 + coef = 2.0*pi/segs; + + self.gl.glBegin(self.gl.GL_LINE_LOOP) + for n in range(segs): + rads = n*coef + self.gl.glVertex2f(radius*cos(rads + a) + x, radius*sin(rads + a) + y) + self.gl.glVertex2f(x,y) + self.gl.glEnd() def draw_polygon(self, clr, points): clr = tools.rgb2floats(clr) - self.gl.glColor3f(clr[0], clr[1], clr[2]) - + self.gl.glColor3f(clr[0], clr[1], clr[2]) + self.gl.glBegin(self.gl.GL_LINES) p1 = points[0] diff --git a/library/pippy/physics/elements.py b/library/pippy/physics/elements.py index 1e821b3..81a7752 100644 --- a/library/pippy/physics/elements.py +++ b/library/pippy/physics/elements.py @@ -9,7 +9,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ __version__= '0.1' __contact__ = '<elements@linuxuser.at>' @@ -50,7 +50,7 @@ class Elements: """ # Settings run_physics = True # Can pause the simulation - element_count = 0 # Element Count + element_count = 0 # Element Count renderer = None # Drawing class (from drawing.py) input = INPUT_PIXELS # Default Input in Pixels! (can change to INPUT_METERS) line_width = 0 # Line Width in Pixels (0 for fill) @@ -99,7 +99,7 @@ class Elements: # Create the World self.world = box2d.b2World(self.worldAABB, self.gravity, self.doSleep) - # Init Colors + # Init Colors self.init_colors() # Set Pixels per Meter @@ -123,7 +123,7 @@ class Elements: top .... True or False -- y = 0 is at the top? Return: - - """ + """ self.inputAxis_x_left = not left self.inputAxis_y_down = top @@ -145,7 +145,7 @@ class Elements: def set_screenSize(self, size): """ Set the current screen size - Parameters: + Parameters: size ... (int(width), int(height)) in pixels Return: - @@ -155,7 +155,7 @@ class Elements: def init_colors(self): """ Init self.colors with a fix set of hex colors - Return: - + Return: - """ self.fixed_color = None self.cur_color = 0 @@ -166,9 +166,9 @@ class Elements: shuffle(self.colors) def set_color(self, clr): - """ Set a fixed color for all future Elements (until reset_color() is called) + """ Set a fixed color for all future Elements (until reset_color() is called) - Parameters: + Parameters: clr ... Hex '#123123' or RGB ((r), (g), (b)) Return: - @@ -178,19 +178,19 @@ class Elements: def reset_color(self): """ All Elements from now on will be drawn in random colors - Return: - + Return: - """ self.fixed_color = None def get_color(self): - """ Get a color - either the fixed one or the next from self.colors + """ Get a color - either the fixed one or the next from self.colors - Return: clr = ((R), (G), (B)) + Return: clr = ((R), (G), (B)) """ if self.fixed_color != None: return self.fixed_color - if self.cur_color == len(self.colors): + if self.cur_color == len(self.colors): self.cur_color = 0 shuffle(self.colors) @@ -215,7 +215,7 @@ class Elements: def translate_coord(self, point): """ Flips the coordinates in another coordinate system orientation, if necessary - (screen <> world coordinate system) + (screen <> world coordinate system) """ x, y = point @@ -228,10 +228,10 @@ class Elements: return (x, y) def translate_coords(self, pointlist): - """ Flips the coordinates in another coordinate system orientation, if necessary - (screen <> world coordinate system) - """ - p_out = [] + """ Flips the coordinates in another coordinate system orientation, if necessary + (screen <> world coordinate system) + """ + p_out = [] for p in pointlist: p_out.append(self.translate_coord(p)) return p_out @@ -247,7 +247,7 @@ class Elements: y = pos[1] / self.camera.scale_factor x, y = self.translate_coord((round(x), round(y))) - return (x+dx, y+dy) + return (x+dx, y+dy) def to_screen(self, pos): """ Transfers a coordinate from the world to the screen coordinate system (pixels) @@ -303,22 +303,22 @@ class Elements: """ self.callbacks.start(CALLBACK_DRAWING_START) - # No need to run through the loop if there's no way to draw - if not self.renderer: + # No need to run through the loop if there's no way to draw + if not self.renderer: return False if self.camera.track_body: # Get Body Center - p1 = self.camera.track_body.GetWorldCenter() + p1 = self.camera.track_body.GetWorldCenter() # Center the Camera There, False = Don't stop the tracking - self.camera.center(self.to_screen((p1.x*self.ppm, p1.y*self.ppm)), stopTrack=False) + self.camera.center(self.to_screen((p1.x*self.ppm, p1.y*self.ppm)), stopTrack=False) # Walk through all known elements body = self.world.GetBodyList() self.renderer.start_drawing() - while body: + while body: xform = body.GetXForm() shape = body.GetShapeList() angle = body.GetAngle() @@ -327,14 +327,14 @@ class Elements: userdata = body.GetUserData() clr = userdata['color'] - while shape: + while shape: type = shape.GetType() if type == box2d.e_circleShape: circle = shape.asCircle() position = box2d.b2Mul(xform, circle.GetLocalPosition()) - pos = self.to_screen((position.x*self.ppm, position.y*self.ppm)) + pos = self.to_screen((position.x*self.ppm, position.y*self.ppm)) self.renderer.draw_circle(clr, pos, self.meter_to_screen(circle.GetRadius()), angle) elif type == box2d.e_polygonShape: @@ -350,7 +350,7 @@ class Elements: else: print " unknown shape type:%d" % shape.GetType() - shape = shape.GetNext() + shape = shape.GetNext() body = body.GetNext() joint = self.world.GetJointList() diff --git a/library/pippy/physics/locals.py b/library/pippy/physics/locals.py index 85528f7..e69af24 100755 --- a/library/pippy/physics/locals.py +++ b/library/pippy/physics/locals.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ INPUT_METERS = 0 INPUT_PIXELS = 1 diff --git a/library/pippy/physics/menu.py b/library/pippy/physics/menu.py index 70d5b4b..4b6ab65 100644 --- a/library/pippy/physics/menu.py +++ b/library/pippy/physics/menu.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ import pygame from pygame.locals import * @@ -32,7 +32,7 @@ import tools COLOR_HEX_BLUE1 = "6491a4" COLOR_HEX_BLUE2 = "9ec9ff" -class MenuItem: +class MenuItem: # padding [px]: left, top, right, bottom padding = (5, 2, 5, 2) @@ -95,7 +95,7 @@ class MenuClass: focus = False # each item is stored as MenuItem - items = [] + items = [] # where to start drawing start_at = (0,0) @@ -127,7 +127,7 @@ class MenuClass: if parent: # Set the info that the item has a child to the parent item - self.items[parent-1].childs.append(len(self.items)-1) + self.items[parent-1].childs.append(len(self.items)-1) else: # New next drawing position @@ -135,7 +135,7 @@ class MenuClass: # Adjust the width of the menu bar if not self.setWidth: - self.width = x+w + self.width = x+w # Adjust the height of the menu bar if h > self.height: self.height = h + 2 @@ -161,7 +161,7 @@ class MenuClass: if len(item.childs) > 0: self.focus = i+1 - # Close any opened menu windows if clicked somewhere else + # Close any opened menu windows if clicked somewhere else if self.focus == focus_in: self.focus = False self.subwin_rect = (0,0,0,0) @@ -175,7 +175,7 @@ class MenuClass: if found: return True - else: + else: return False def draw(self, surface): @@ -188,7 +188,7 @@ class MenuClass: for i in xrange(len(self.items)): item = self.items[i] - if not item.parent: + if not item.parent: x,y,w,h = item.rect if self.focus == i+1: surface.blit(item.surface_active, (x,y)) @@ -212,7 +212,7 @@ class MenuClass: s = pygame.Surface((width, height)) s.fill(tools.hex2rgb(COLOR_HEX_BLUE1)) - # Parent Coordinates + # Parent Coordinates px, py, pw, ph = self.items[self.focus-1].rect # y Counter @@ -222,10 +222,10 @@ class MenuClass: item.visible = True s.blit(item.surface_inactive, (0, y)) - ix, iy, iw, ih = item.rect + ix, iy, iw, ih = item.rect if (ix, iy) == (0, 0): item.rect = item.rect.move((px, y+ph)) - ix, iy, iw, ih = item.rect + ix, iy, iw, ih = item.rect if iw < width: item.rect = (ix,iy,width,ih) diff --git a/library/pippy/physics/tools.py b/library/pippy/physics/tools.py index 9851ff8..9818638 100755 --- a/library/pippy/physics/tools.py +++ b/library/pippy/physics/tools.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,18 +22,18 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ # Some Hex Tools def hex2dec(hex): """ Convert and hex value in a decimal number - """ + """ return int(hex, 16) -def hex2rgb(hex): +def hex2rgb(hex): """ Convert a hex color (#123abc) in RGB ((r), (g), (b)) """ - if hex[0:1] == '#': hex = hex[1:]; + if hex[0:1] == '#': hex = hex[1:]; return (hex2dec(hex[:2]), hex2dec(hex[2:4]), hex2dec(hex[4:6])) def rgb2floats(rgb): diff --git a/library/pippy/physics/tools_poly.py b/library/pippy/physics/tools_poly.py index 97a0cea..4885169 100755 --- a/library/pippy/physics/tools_poly.py +++ b/library/pippy/physics/tools_poly.py @@ -8,7 +8,7 @@ Home: http://elements.linuxuser.at IRC: #elements on irc.freenode.org Code: http://www.assembla.com/wiki/show/elements - svn co http://svn2.assembla.com/svn/elements + svn co http://svn2.assembla.com/svn/elements License: GPLv3 | See LICENSE for the full text This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +along with this program. If not, see <http://www.gnu.org/licenses/>. """ from functools import partial @@ -55,7 +55,7 @@ def ComputeCentroid(pd): # Triangle vertices. p1 = pRef p2 = pd.getVertex(i) - if i + 1 < count: + if i + 1 < count: p3 = pd.getVertex(i+1) else: p3 = pd.getVertex(0) @@ -70,7 +70,7 @@ def ComputeCentroid(pd): # Area weighted centroid c += triangleArea * inv3 * (p1 + p2 + p3) - # Centroid + # Centroid # if area < FLT_EPSILON: #raise ValueError, "ComputeCentroid: area < FLT_EPSILON" @@ -95,7 +95,7 @@ def checkDef(pd): else: v1 = verts[i+1] edge=v1 - v0 # if edge.LengthSquared() < threshold: -# raise ValueError, "edge.LengthSquared < FLT_EPSILON**2" +# raise ValueError, "edge.LengthSquared < FLT_EPSILON**2" normals.append( box2d.b2Cross(edge, 1.0) ) normals[-1].Normalize() v0=v1 @@ -104,7 +104,7 @@ def checkDef(pd): d=box2d.b2Vec2() for i in range(pd.vertexCount): - i1 = i - 1 + i1 = i - 1 if i1 < 0: i1 = pd.vertexCount - 1 i2 = i n1 = normals[i1] @@ -114,17 +114,17 @@ def checkDef(pd): d.x = box2d.b2Dot(n1, v) - box2d.b2_toiSlop d.y = box2d.b2Dot(n2, v) - box2d.b2_toiSlop - # Shifting the edge inward by b2_toiSlop should - # not cause the plane to pass the centroid. + # Shifting the edge inward by b2_toiSlop should + # not cause the plane to pass the centroid. - # Your shape has a radius/extent less than b2_toiSlop. -# if d.x < 0.0 or d.y <= 0.0: + # Your shape has a radius/extent less than b2_toiSlop. +# if d.x < 0.0 or d.y <= 0.0: # raise ValueError, "Your shape has a radius/extent less than b2_toiSlop." A = box2d.b2Mat22() A.col1.x = n1.x; A.col2.x = n1.y A.col1.y = n2.x; A.col2.y = n2.y - #coreVertices[i] = A.Solve(d) + m_centroid + #coreVertices[i] = A.Solve(d) + m_centroid return True @@ -144,7 +144,7 @@ def poly_center_vertices(pointlist): """ Rearranges vectors around the center Return: pointlist ([(x, y), ...]) - """ + """ poly_points_center = [] center = cx, cy = calc_center(pointlist) @@ -165,7 +165,7 @@ def is_line(vertices, tolerance=25.0): Returns: True if line, False if no line """ - if len(vertices) <= 2: + if len(vertices) <= 2: return True # Step 1: Points -> Vectors @@ -178,7 +178,7 @@ def is_line(vertices, tolerance=25.0): x2, y2 = p p_old = p - # Create Vector + # Create Vector vx, vy = (x2-x1, y2-y1) # Check Length @@ -224,7 +224,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): p_new = [] p_new.append(vertices[0]) - dir = None + dir = None is_convex = True for i in xrange(len(vertices)-1): @@ -249,7 +249,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): b = sqrt((v1x*v1x) + (v1y*v1y)) c = sqrt((v2x*v2x) + (v2y*v2y)) - # No Division by 0 :) + # No Division by 0 :) if (b*c) == 0.0: continue # Get the current degrees @@ -263,7 +263,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): # Check if inside tolerance if fabs(angle) > tolerance: - p_new.append(vertices[i]) + p_new.append(vertices[i]) # print "x", 180-angle, is_left(vertices[i-1], vertices[i], vertices[i+1]) # Check if convex: @@ -279,7 +279,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): # Returns: (1) New Pointlist, (2) Soft reduced pointlist (reduce_poly()) return p_new, is_convex - """ OLD FUNCTION: """ + """ OLD FUNCTION: """ # Wipe all points too close to each other vxx = vertices = reduce_poly(vertices, minlen) @@ -310,7 +310,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): # Get Angle if fabs(vx) < 0.2: alpha = 90 - else: + else: alpha = degrees(atan(vy * 1.0) / (vx*1.0)) if alpha_old == None: @@ -318,7 +318,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): continue # Get difference to previous angle - alpha_diff = fabs(alpha - alpha_old) + alpha_diff = fabs(alpha - alpha_old) alpha_old = alpha # If the new vector differs from the old one, we add the old point @@ -334,7 +334,7 @@ def reduce_poly_by_angle(vertices, tolerance=10.0, minlen=20): return p_new, vxx -# The following functions is_left, reduce_poly and convex_hull are +# The following functions is_left, reduce_poly and convex_hull are # from the pymunk project (http://code.google.com/p/pymunk/) def is_left(p0, p1, p2): """Test if p2 is left, on or right of the (infinite) line (p0,p1). @@ -345,7 +345,7 @@ def is_left(p0, p1, p2): """ sorting = (p1[0] - p0[0])*(p2[1]-p0[1]) - (p2[0]-p0[0])*(p1[1]-p0[1]) if sorting > 0: return 1 - elif sorting < 0: return -1 + elif sorting < 0: return -1 else: return 0 def is_convex(points): @@ -362,7 +362,7 @@ def is_convex(points): xc, yc = 0, 0 is_same_winding = is_left(p0, p1, p2) for p2 in points[2:] + [p0] + [p1]: - if is_same_winding != is_left(p0, p1, p2): + if is_same_winding != is_left(p0, p1, p2): return False a = p1[0] - p0[0], p1[1] - p0[1] # p1-p0 b = p2[0] - p1[0], p2[1] - p1[1] # p2-p1 @@ -372,8 +372,8 @@ def is_convex(points): return xc <= 2 and yc <= 2 -def sign(x): - if x < 0: return -1 +def sign(x): + if x < 0: return -1 else: return 1 @@ -426,7 +426,7 @@ def convex_hull(points): pt1 = hull[-1] pt2 = hull[-2] - l = is_left(pt2, pt1, p) + l = is_left(pt2, pt1, p) if l > 0: hull.append(p) else: @@ -436,5 +436,5 @@ def convex_hull(points): pt2 = hull[-2] l = is_left(pt2, pt1, p) hull.append(p) - return hull + return hull diff --git a/library/pippy/query.py b/library/pippy/query.py index ff968e7..1260c98 100644 --- a/library/pippy/query.py +++ b/library/pippy/query.py @@ -19,7 +19,7 @@ import logging import dbus import gobject -from sugar.datastore import datastore +from sugar3.datastore import datastore DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore' DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore' @@ -232,7 +232,7 @@ class ResultSet(gobject.GObject): limit = min(self._offset, max_count) self._offset = max(0, self._offset - max_count) - logging.debug('prepending one more page, offset: %r limit: %r' % + logging.debug('prepending one more page, offset: %r limit: %r' % (self._offset, limit)) jobjects, self._total_count = datastore.find(self._query, sorting=self._sorting, diff --git a/library/pippy/sound.py b/library/pippy/sound.py index 08a5274..7124cfe 100755 --- a/library/pippy/sound.py +++ b/library/pippy/sound.py @@ -18,9 +18,9 @@ import errno import os import sys -import sugar.env +import sugar3.env from gettext import gettext as _ -from sugar.activity import activity +from sugar3.activity import activity path = activity.get_bundle_path() path = path.split("/")[0:-1] @@ -324,7 +324,7 @@ def audioOut(file=None): sound to hp. (file = [None]) """ global temp_path if temp_path is None: - from sugar import env + from sugar3 import env temp_path = env.get_profile_path() + '/pippy' if not os.path.isdir(temp_path): os.mkdir(temp_path) diff --git a/pippy_app.py b/pippy_app.py index f3f0540..4632df5 100644 --- a/pippy_app.py +++ b/pippy_app.py @@ -18,71 +18,66 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """Pippy Activity: A simple Python programming activity .""" -from __future__ import with_statement -import gtk + import logging -import pango -import vte import re import os -import gobject import time - -from port.style import font_zoom from signal import SIGTERM from gettext import gettext as _ -from sugar.activity import activity -from activity import ViewSourceActivity, TARGET_TYPE_TEXT -from sugar.activity.activity import ActivityToolbox, \ - EditToolbar, get_bundle_path, get_bundle_name -from sugar.graphics import style -from sugar.graphics.toolbutton import ToolButton - +import gi +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import Pango +from gi.repository import GObject +from gi.repository import Vte + +from sugar3.activity import activity + +from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton +from sugar3.activity.widgets import EditToolbar, StopButton +from sugar3.activity.activity import get_bundle_path +from sugar3.activity.activity import get_bundle_name +from sugar3.graphics import style +from sugar3.graphics.toolbutton import ToolButton +from port.style import font_zoom import groupthink.sugar_tools import groupthink.gtk_tools +from activity import ViewSourceActivity, TARGET_TYPE_TEXT # activity.py local + text_buffer = None # magic prefix to use utf-8 source encoding PYTHON_PREFIX = """#!/usr/bin/python # -*- coding: utf-8 -*- """ - -OLD_TOOLBAR = False -try: - from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton - from sugar.activity.widgets import StopButton -except ImportError: - OLD_TOOLBAR = True +#from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton +#from sugar3.activity.widgets import StopButton # get screen sizes -SIZE_X = gtk.gdk.screen_width() -SIZE_Y = gtk.gdk.screen_height() +SIZE_X = Gdk.Screen.width() +SIZE_Y = Gdk.Screen.height() groupthink_mimetype = 'pickle/groupthink-pippy' - class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): """Pippy Activity as specified in activity.info""" def early_setup(self): global text_buffer - import gtksourceview2 - text_buffer = gtksourceview2.Buffer() + from gi.repository import GtkSource + text_buffer = GtkSource.Buffer() def initialize_display(self): self._logger = logging.getLogger('pippy-activity') # Activity toolbar with title input, share button and export buttons: - - if OLD_TOOLBAR: - activity_toolbar = self.toolbox.get_activity_toolbar() - else: - activity_toolbar = self.activity_button.page + activity_toolbar = self.activity_button.page # Hide keep button for Sugar versions prior to 0.94: - activity_toolbar.keep.hide() + #activity_toolbar.keep.hide() - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.show() activity_toolbar.insert(separator, -1) @@ -104,19 +99,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): create_bundle_button.show() activity_toolbar.insert(create_bundle_button, -1) - self._edit_toolbar = activity.EditToolbar() + self._edit_toolbar = EditToolbar() - if OLD_TOOLBAR: - activity_toolbar = gtk.Toolbar() - self.toolbox.add_toolbar(_('Actions'), activity_toolbar) - self.toolbox.set_current_toolbar(1) - self.toolbox.add_toolbar(_('Edit'), self._edit_toolbar) - else: - edit_toolbar_button = ToolbarButton() - edit_toolbar_button.set_page(self._edit_toolbar) - edit_toolbar_button.props.icon_name = 'toolbar-edit' - edit_toolbar_button.props.label = _('Edit') - self.get_toolbar_box().toolbar.insert(edit_toolbar_button, -1) + edit_toolbar_button = ToolbarButton() + edit_toolbar_button.set_page(self._edit_toolbar) + edit_toolbar_button.props.icon_name = 'toolbar-edit' + edit_toolbar_button.props.label = _('Edit') + self.get_toolbar_box().toolbar.insert(edit_toolbar_button, -1) self._edit_toolbar.show() @@ -125,15 +114,12 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self._edit_toolbar.copy.connect('clicked', self.__copybutton_cb) self._edit_toolbar.paste.connect('clicked', self.__pastebutton_cb) - if OLD_TOOLBAR: - actions_toolbar = activity_toolbar - else: - actions_toolbar = self.get_toolbar_box().toolbar + actions_toolbar = self.get_toolbar_box().toolbar # The "go" button - goicon_bw = gtk.Image() + goicon_bw = Gtk.Image() goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd()) - goicon_color = gtk.Image() + goicon_color = Gtk.Image() goicon_color.set_from_file("%s/icons/run_color.svg" % os.getcwd()) gobutton = ToolButton(label=_("_Run!")) gobutton.props.accelerator = _('<alt>r') @@ -145,9 +131,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): actions_toolbar.insert(gobutton, -1) # The "stop" button - stopicon_bw = gtk.Image() + stopicon_bw = Gtk.Image() stopicon_bw.set_from_file("%s/icons/stopit_bw.svg" % os.getcwd()) - stopicon_color = gtk.Image() + stopicon_color = Gtk.Image() stopicon_color.set_from_file("%s/icons/stopit_color.svg" % os.getcwd()) stopbutton = ToolButton(label=_("_Stop")) stopbutton.props.accelerator = _('<alt>s') @@ -159,9 +145,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): actions_toolbar.insert(stopbutton, -1) # The "clear" button - clearicon_bw = gtk.Image() + clearicon_bw = Gtk.Image() clearicon_bw.set_from_file("%s/icons/eraser_bw.svg" % os.getcwd()) - clearicon_color = gtk.Image() + clearicon_color = Gtk.Image() clearicon_color.set_from_file("%s/icons/eraser_color.svg" % os.getcwd()) clearbutton = ToolButton(label=_("_Clear")) @@ -175,34 +161,33 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): activity_toolbar.show() - if not OLD_TOOLBAR: - separator = gtk.SeparatorToolItem() - separator.props.draw = False - separator.set_expand(True) - self.get_toolbar_box().toolbar.insert(separator, -1) - separator.show() + separator = Gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + self.get_toolbar_box().toolbar.insert(separator, -1) + separator.show() - stop = StopButton(self) - self.get_toolbar_box().toolbar.insert(stop, -1) + stop = StopButton(self) + self.get_toolbar_box().toolbar.insert(stop, -1) # Main layout. - self.hpane = gtk.HPaned() - self.vpane = gtk.VPaned() + self.hpane = Gtk.HPaned() + self.vpane = Gtk.VPaned() # The sidebar. - self.sidebar = gtk.VBox() - self.model = gtk.TreeStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING) - treeview = gtk.TreeView(self.model) - cellrenderer = gtk.CellRendererText() - treecolumn = gtk.TreeViewColumn(_("Examples"), cellrenderer, text=1) + self.sidebar = Gtk.VBox() + self.model = Gtk.TreeStore(GObject.TYPE_PYOBJECT, GObject.TYPE_STRING) + treeview = Gtk.TreeView(self.model) + cellrenderer = Gtk.CellRendererText() + treecolumn = Gtk.TreeViewColumn(_("Examples"), cellrenderer, text=1) treeview.get_selection().connect("changed", self.selection_cb) treeview.append_column(treecolumn) treeview.set_size_request(int(SIZE_X * 0.3), SIZE_Y) # Create scrollbars around the view. - scrolled = gtk.ScrolledWindow() + scrolled = Gtk.ScrolledWindow() scrolled.add(treeview) - self.sidebar.pack_start(scrolled) + self.sidebar.pack_start(scrolled, True, True, 0) self.hpane.add1(self.sidebar) root = os.path.join(get_bundle_path(), 'data') @@ -215,7 +200,6 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self.model.set_value(olditer, 0, direntry) self.model.set_value(olditer, 1, direntry["name"]) - for _file in sorted(os.listdir(os.path.join(root, d))): if _file.endswith('~'): continue # skip emacs backups @@ -224,13 +208,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): _iter = self.model.insert_before(olditer, None) self.model.set_value(_iter, 0, entry) self.model.set_value(_iter, 1, entry["name"]) - # Adding local examples + # Adding local examples root = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'data') - direntry_examples = { "name": _("My examples"), + direntry_examples = { "name": _("My examples"), "path": root + "/" } - self.example_iter = self.model.insert_before(None, None) - self.model.set_value(self.example_iter, 0, direntry_examples) - self.model.set_value(self.example_iter, 1, direntry_examples["name"]) + self.example_iter = self.model.insert_before(None, None) + self.model.set_value(self.example_iter, 0, direntry_examples) + self.model.set_value(self.example_iter, 1, direntry_examples["name"]) for _file in sorted(os.listdir(root)): file_name = os.path.join(root, _file) if os.path.isfile(file_name): @@ -242,9 +226,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): treeview.expand_all() # Source buffer - import gtksourceview2 + from gi.repository import GtkSource global text_buffer - lang_manager = gtksourceview2.language_manager_get_default() + lang_manager = GtkSource.LanguageManager.get_default() if hasattr(lang_manager, 'list_languages'): langs = lang_manager.list_languages() else: @@ -262,50 +246,53 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): text_buffer.set_highlight_syntax(True) # The GTK source view window - self.text_view = gtksourceview2.View(text_buffer) + self.text_view = GtkSource.View() + self.text_view.set_buffer(text_buffer) self.text_view.set_size_request(0, int(SIZE_Y * 0.5)) self.text_view.set_editable(True) self.text_view.set_cursor_visible(True) self.text_view.set_show_line_numbers(True) - self.text_view.set_wrap_mode(gtk.WRAP_CHAR) + self.text_view.set_wrap_mode(Gtk.WrapMode.CHAR) self.text_view.set_insert_spaces_instead_of_tabs(True) self.text_view.set_tab_width(2) self.text_view.set_auto_indent(True) - self.text_view.modify_font(pango.FontDescription("Monospace " + + self.text_view.modify_font(Pango.FontDescription("Monospace " + str(font_zoom(style.FONT_SIZE)))) # We could change the color theme here, if we want to. - #mgr = gtksourceview2.style_manager_get_default() + #mgr = GtkSource.style_manager_get_default() #style_scheme = mgr.get_scheme('kate') #self.text_buffer.set_style_scheme(style_scheme) - codesw = gtk.ScrolledWindow() - codesw.set_policy(gtk.POLICY_AUTOMATIC, - gtk.POLICY_AUTOMATIC) + codesw = Gtk.ScrolledWindow() + codesw.set_policy(Gtk.PolicyType.AUTOMATIC, + Gtk.PolicyType.AUTOMATIC) codesw.add(self.text_view) self.vpane.add1(codesw) # An hbox to hold the vte window and its scrollbar. - outbox = gtk.HBox() + outbox = Gtk.HBox() # The vte python window - self._vte = vte.Terminal() + + self._vte = Vte.Terminal() self._vte.set_encoding('utf-8') self._vte.set_size(30, 5) font = 'Monospace ' + str(font_zoom(style.FONT_SIZE)) - self._vte.set_font(pango.FontDescription(font)) - self._vte.set_colors(gtk.gdk.color_parse('#000000'), - gtk.gdk.color_parse('#E7E7E7'), + self._vte.set_font(Pango.FontDescription(font)) + self._vte.set_colors(Gdk.color_parse('#000000'), + Gdk.color_parse('#E7E7E7'), []) self._vte.connect('child_exited', self.child_exited_cb) self._child_exited_handler = None - self._vte.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [("text/plain", 0, TARGET_TYPE_TEXT)], - gtk.gdk.ACTION_COPY) + #self._vte.drag_dest_set(Gtk.DEST_DEFAULT_ALL, + # [("text/plain", 0, TARGET_TYPE_TEXT)], + # Gdk.DragAction.COPY) self._vte.connect('drag_data_received', self.vte_drop_cb) - outbox.pack_start(self._vte) + outbox.pack_start(self._vte, True, True, 0) - outsb = gtk.VScrollbar(self._vte.get_adjustment()) + #outsb = Gtk.VScrollbar(self._vte.get_adjustment()) + outsb = Gtk.VScrollbar() outsb.show() outbox.pack_start(outsb, False, False, 0) self.vpane.add2(outbox) @@ -349,7 +336,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def flash_cb(self, button, icons): button.set_icon_widget(icons['color']) button.show_all() - gobject.timeout_add(400, self.timer_cb, button, icons) + GObject.timeout_add(400, self.timer_cb, button, icons) def clearbutton_cb(self, button): self.save() @@ -389,11 +376,11 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def __copybutton_cb(self, button): global text_buffer - text_buffer.copy_clipboard(gtk.Clipboard()) + text_buffer.copy_clipboard(Gtk.Clipboard()) def __pastebutton_cb(self, button): global text_buffer - text_buffer.paste_clipboard(gtk.Clipboard(), None, True) + text_buffer.paste_clipboard(Gtk.Clipboard(), None, True) def gobutton_cb(self, button): from shutil import copy2 @@ -401,7 +388,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self._reset_vte() # FIXME: We're losing an odd race here - # gtk.main_iteration(block=False) + # Gtk.main_iteration(block=False) pippy_app_name = '%s/tmp/pippy_app.py' % self.get_activity_root() self._write_text_buffer(pippy_app_name) @@ -432,14 +419,14 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): # get the name of this pippy program. title = self.metadata['title'] if title == 'Pippy Activity': - from sugar.graphics.alert import Alert - from sugar.graphics.icon import Icon + from sugar3.graphics.alert import Alert + from sugar3.graphics.icon import Icon alert = Alert() alert.props.title = _('Save as Activity Error') alert.props.msg = _('Please give your activity a meaningful name ' 'before attempting to save it as an activity.') ok_icon = Icon(icon_name='dialog-ok') - alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) + alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) alert.connect('response', self.dismiss_alert_cb) self.add_alert(alert) return @@ -447,7 +434,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self._reset_vte() self._vte.feed(_("Creating activity bundle...")) self._vte.feed("\r\n") - TMPDIR = 'instance' + TMPDIR = 'instance' app_temp = mkdtemp('.activity', 'Pippy', os.path.join(self.get_activity_root(), TMPDIR)) sourcefile = os.path.join(app_temp, 'xyzzy.py') @@ -456,7 +443,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): # write out application code self._write_text_buffer(sourcefile) # hook up a callback for when the bundle builder is done. - # we can't use gobject.child_watch_add because vte will reap our + # we can't use GObject.child_watch_add because vte will reap our # children before we can. self._child_exited_handler = \ lambda: self.bundle_cb(title, app_temp) @@ -477,13 +464,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): # get the name of this pippy program. title = self.metadata['title'] if title == _('Pippy Activity'): - from sugar.graphics.alert import Alert - from sugar.graphics.icon import Icon + from sugar3.graphics.alert import Alert + from sugar3.graphics.icon import Icon alert = Alert() alert.props.title =_ ('Save as Example Error') alert.props.msg = _('Please give your activity a meaningful name before attempting to save it as an example.') ok_icon = Icon(icon_name='dialog-ok') - alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) + alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) alert.connect('response', self.dismiss_alert_cb) self.add_alert(alert) return @@ -494,7 +481,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): local_data = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'data') local_file = os.path.join(local_data,title) if os.path.exists(local_file): - from sugar.graphics.alert import ConfirmationAlert + from sugar3.graphics.alert import ConfirmationAlert alert = ConfirmationAlert() alert.props.title =_ ('Save as Example Warning') alert.props.msg = _('This example already exists. Do you want to overwrite it?') @@ -506,7 +493,6 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self._vte.feed(_("Saved as example.")) self._vte.feed("\r\n") self.add_to_example_list(local_file) - def child_exited_cb(self, *args): """Called whenever a child exits. If there's a handler, run it.""" @@ -516,9 +502,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def bundle_cb(self, title, app_temp): """Called when we're done building a bundle for a source file.""" - from sugar import profile + from sugar3 import profile from shutil import rmtree - from sugar.datastore import datastore + from sugar3.datastore import datastore try: # find the .xo file: were we successful? bundle_file = [f for f in os.listdir(app_temp) \ @@ -552,11 +538,10 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def dismiss_alert_cb(self, alert, response_id): self.remove_alert(alert) - def confirmation_alert_cb(self, alert, response_id, local_file): #callback for conf alert self.remove_alert(alert) - if response_id is gtk.RESPONSE_OK: + if response_id is Gtk.ResponseType.OK: self.write_file(local_file) self._reset_vte() self._vte.feed(_("Saved as example.")) @@ -564,16 +549,17 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): else: self._reset_vte() - def add_to_example_list(self,local_file): # def for add example + def add_to_example_list(self,local_file): # def for add example entry = { "name": _(os.path.basename(local_file)), "path": local_file } _iter = self.model.insert_before(self.example_iter, None) self.model.set_value(_iter, 0, entry) self.model.set_value(_iter, 1, entry["name"]) - def save_to_journal(self, file_path, cloudstring): _file = open(file_path, 'w') + self.metadata['mime_type'] = 'text/x-python' + ''' if not self._shared_activity: self.metadata['mime_type'] = 'text/x-python' global text_buffer @@ -582,7 +568,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): _file.write(text) else: self.metadata['mime_type'] = groupthink_mimetype - _file.write(cloudstring) + _file.write(cloudstring)''' def load_from_journal(self, file_path): if self.metadata['mime_type'] == 'text/x-python': @@ -611,12 +597,12 @@ show_launcher = yes PIPPY_ICON = \ """<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ - <!ENTITY stroke_color "#010101"> - <!ENTITY fill_color "#FFFFFF"> + <!ENTITY stroke_color "#010101"> + <!ENTITY fill_color "#FFFFFF"> ]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="activity-pippy"> - <path d="M28.497,48.507 c5.988,0,14.88-2.838,14.88-11.185c0-9.285-7.743-10.143-10.954-11.083c-3.549-0.799-5.913-1.914-6.055-3.455 c-0.243-2.642,1.158-3.671,3.946-3.671c0,0,6.632,3.664,12.266,0.74c1.588-0.823,4.432-4.668,4.432-7.32 c0-2.653-9.181-5.719-11.967-5.719c-2.788,0-5.159,3.847-5.159,3.847c-5.574,0-11.149,5.306-11.149,10.612 c0,5.305,5.333,9.455,11.707,10.612c2.963,0.469,5.441,2.22,4.878,5.438c-0.457,2.613-2.995,5.306-8.361,5.306 c-4.252,0-13.3-0.219-14.745-4.079c-0.929-2.486,0.168-5.205,1.562-5.205l-0.027-0.16c-1.42-0.158-5.548,0.16-5.548,5.465 C8.202,45.452,17.347,48.507,28.497,48.507z" fill="&fill_color;" stroke="&stroke_color;" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5"/> - <path d="M42.579,19.854c-2.623-0.287-6.611-2-7.467-5.022" fill="none" stroke="&stroke_color;" stroke-linecap="round" stroke-width="3"/> - <circle cx="35.805" cy="10.96" fill="&stroke_color;" r="1.676"/> + <path d="M28.497,48.507 c5.988,0,14.88-2.838,14.88-11.185c0-9.285-7.743-10.143-10.954-11.083c-3.549-0.799-5.913-1.914-6.055-3.455 c-0.243-2.642,1.158-3.671,3.946-3.671c0,0,6.632,3.664,12.266,0.74c1.588-0.823,4.432-4.668,4.432-7.32 c0-2.653-9.181-5.719-11.967-5.719c-2.788,0-5.159,3.847-5.159,3.847c-5.574,0-11.149,5.306-11.149,10.612 c0,5.305,5.333,9.455,11.707,10.612c2.963,0.469,5.441,2.22,4.878,5.438c-0.457,2.613-2.995,5.306-8.361,5.306 c-4.252,0-13.3-0.219-14.745-4.079c-0.929-2.486,0.168-5.205,1.562-5.205l-0.027-0.16c-1.42-0.158-5.548,0.16-5.548,5.465 C8.202,45.452,17.347,48.507,28.497,48.507z" fill="&fill_color;" stroke="&stroke_color;" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5"/> + <path d="M42.579,19.854c-2.623-0.287-6.611-2-7.467-5.022" fill="none" stroke="&stroke_color;" stroke-linecap="round" stroke-width="3"/> + <circle cx="35.805" cy="10.96" fill="&stroke_color;" r="1.676"/> </g></svg><!-- " --> """ @@ -658,12 +644,10 @@ PIPPY_DEFAULT_ICON = \ ############# ACTIVITY META-INFORMATION ############### # this is used by Pippy to generate a bundle for itself. - def pippy_activity_version(): """Returns the version number of the generated activity bundle.""" return 39 - def pippy_activity_extra_files(): """Returns a map of 'extra' files which should be included in the generated activity bundle.""" @@ -678,33 +662,27 @@ def pippy_activity_extra_files(): extra['activity/activity-default.svg'] = PIPPY_DEFAULT_ICON return extra - def pippy_activity_news(): """Return the NEWS file for this activity.""" # Cheat again. return open(os.path.join(get_bundle_path(), 'NEWS')).read() - def pippy_activity_icon(): """Return an SVG document specifying the icon for this activity.""" return PIPPY_ICON - def pippy_activity_class(): """Return the class which should be started to run this activity.""" return 'pippy_app.PippyActivity' - def pippy_activity_bundle_id(): """Return the bundle_id for the generated activity.""" return 'org.laptop.Pippy' - def pippy_activity_mime_types(): """Return the mime types handled by the generated activity, as a list.""" return ['text/x-python', groupthink_mimetype] - def pippy_activity_extra_info(): return """ license = GPLv2+ @@ -712,15 +690,14 @@ update_url = http://activities.sugarlabs.org """ ################# ACTIVITY BUNDLER ################ - def main(): """Create a bundle from a pippy-style source file""" from optparse import OptionParser from pyclbr import readmodule_ex from tempfile import mkdtemp from shutil import copytree, copy2, rmtree - from sugar import profile - from sugar.activity import bundlebuilder + from sugar3 import profile + from sugar3.activity import bundlebuilder import sys parser = OptionParser(usage='%prog [options] [title] [sourcefile]') parser.add_option('-d', '--dir', dest='dir', default='.', metavar='DIR', diff --git a/port/style.py b/port/style.py index 61915f2..a5f7c6c 100644 --- a/port/style.py +++ b/port/style.py @@ -13,7 +13,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ GUI look&feel related declarations """ -from sugar.graphics import style +from sugar3.graphics import style def font_zoom(size): @@ -16,6 +16,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from sugar.activity import bundlebuilder +from sugar3.activity import bundlebuilder bundlebuilder.start() |