コード例 #1
0
ファイル: main.py プロジェクト: BackupTheBerlios/grafity-svn
def main():
    app = QApplication(sys.argv)
    pm = QPixmap(":/images/splash01.jpg")
    splash = QSplashScreen(pm)
    splash.show()

    QCoreApplication.setOrganizationName("Grafity Labs")
    #    QCoreApplication.setOrganizationDomain("mysoft.com");
    QCoreApplication.setApplicationName("Grafity")

    from dispatch import dispatcher

    def messg(msg):
        splash.showMessage(msg, Qt.AlignLeft, Qt.white)
        app.processEvents()

    dispatcher.connect(messg, signal="splash-message")

    from grafity.ui.mdi import MainWindow

    dispatcher.send("splash-message", msg="Creating windows...")
    form = MainWindow()
    form.show()
    splash.finish(form)
    splash.close()
    app.exec_()
コード例 #2
0
 def present(self):
     # FIXME - assumes the model has a location i.e. is actually on the map
     dispatcher.send(signal=self,
                     sender='presenting',
                     property='location',
                     old=None,
                     value=self.location)
コード例 #3
0
ファイル: items.py プロジェクト: BackupTheBerlios/grafity-svn
 def _notify_set___folder(self, folder, old):
     if old is not None:
         old._update_contents()
         dispatcher.send('removed', old, self)
     if folder is not None:
         folder._update_contents()
         dispatcher.send('added', folder, self)
コード例 #4
0
ファイル: models.py プロジェクト: BackupTheBerlios/vellum-svn
 def present(self):
     # FIXME - assumes the model has a location i.e. is actually on the map
     dispatcher.send(signal=self, 
                     sender='presenting', 
                     property='location', 
                     old=None, 
                     value=self.location)
コード例 #5
0
    def do_set_expr(self, expr):
        # find dependencies and error-check expression
        #try:
        data = asarray(self.worksheet.evaluate(expr))
#        except Exception, ar:
       # x.    print >>sys.stderr, '*****************', ar
       #     raise UserWarning, False
        self.depdict = self.analyze_expression(expr)
        newdep = set(self.depdict.values())

        # set dependencies
        for column in newdep - self.dependencies:
            print >>sys.stderr, "add", column.name
            dispatcher.connect(self.calculate, signal='data-changed', sender=column)
            dispatcher.connect(self.on_dep_rename, signal='rename', sender=column)
        for column in self.dependencies - newdep:
            print >>sys.stderr, "rem", column.name
            dispatcher.disconnect(self.calculate, signal='data-changed', sender=column)
            dispatcher.disconnect(self.on_dep_rename, signal='rename', sender=column)
        newdepws = set(d.worksheet for d in newdep)
        depws = set(d.worksheet for d in self.dependencies)
        for worksheet in newdepws - depws:
            dispatcher.connect(self.on_dep_ws_rename, signal='fullname-changed', sender=worksheet)
            dispatcher.connect(self.on_dep_ws_rename, signal='rename', sender=worksheet)
        for worksheet in depws - newdepws:
            dispatcher.disconnect(self.on_dep_ws_rename, signal='fullname-changed', sender=worksheet)
            dispatcher.disconnect(self.on_dep_ws_rename, signal='rename', sender=worksheet)
        self.dependencies = newdep

        if expr != '':
            # set data without triggering an action
            self.data[:] = data
        dispatcher.send(sender=self, signal='data-changed')
        dispatcher.send(sender=self.worksheet, signal='data-changed')
        return True
コード例 #6
0
ファイル: view.py プロジェクト: BackupTheBerlios/vellum-svn
 def on_draggable_gdk_button_release(self, widget, event, model):
     if event.button == 1:
         model.selected = not model.selected
         model.grabbed = False
     elif event.button == 3:
         dispatcher.send(signal=Drop,
                         sender='gui',
                         model=model)
コード例 #7
0
 def receivePropertyChange(self, signal, sender, property, old, value):
     if signal in self.endpoints:
         locations = self.locations
         dispatcher.send(signal=self,
                         sender='connector',
                         property='locations',
                         old=None,
                         value=locations)
コード例 #8
0
ファイル: models.py プロジェクト: BackupTheBerlios/vellum-svn
 def receiveDropModel(self, sender, model):
     """If model is one of the endpoints, I should be destroyed too"""
     if sender == 'gui':
         print 'connector committing suicide. sender was', sender
         if model in self.endpoints:
             dispatcher.send(signal=Drop,
                             sender='connector',
                             model=self)
コード例 #9
0
 def on_draggable_gdk_motion_notify(self, widget, event, model):
     if model.grabbed:
         ix1, iy1, ix2, iy2 = model.widget.get_bounds()
         iw, ih = ix2 - ix1, iy2 - iy1
         x, y = event.x, event.y
         dispatcher.send(signal=model,
                         sender='gui',
                         property='location',
                         old=model.location,
                         value=(x - iw, y - ih))
コード例 #10
0
ファイル: view.py プロジェクト: BackupTheBerlios/vellum-svn
 def on_draggable_gdk_motion_notify(self, widget, event, model):
     if model.grabbed:
         ix1, iy1, ix2, iy2 = model.widget.get_bounds()
         iw, ih = ix2 - ix1, iy2 - iy1
         x, y = event.x, event.y
         dispatcher.send(signal=model, 
                         sender='gui', 
                         property='location',
                         old=model.location, 
                         value=(x - iw, y - ih))
コード例 #11
0
 def __setitem__(self, key, value):
     if isinstance(key, int):
         self.columns[key][:] = value
     elif isinstance(key, basestring):
         if key not in self.column_names:
             self.add_column(key)
         self.columns[self.column_names.index(key)][:] = value
     else:
         raise IndexError
     dispatcher.send('data-changed', sender=self)
コード例 #12
0
ファイル: TkTime.py プロジェクト: drewp/eventually
 def select(parse):
     if parse is None:
         self.text.tag_config(tag, background=self.parsed_color,
             borderwidth=1, relief='raised')
     else:
         self.text.tag_config(tag, background=self.selected_color,
             borderwidth=1, relief='raised')
     # remember our selection
     self.selections[str(segment)] = parse
     dispatcher.send("selection made", segment=segment, selection=parse,
         tag=tag, segmentnum=tagnum, sender=self)
コード例 #13
0
 def on_background_gdk_button_release(self, widget, ev, background):
     """on right click make a new character"""
     if ev.button == 3:
         # create a new Character, and move it to the position of click
         character = Character()
         dispatcher.send(signal=New, sender='gui', model=character)
         dispatcher.send(signal=character,
                         sender='gui',
                         property='location',
                         old=character.location,
                         value=(ev.x, ev.y))
コード例 #14
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
    def gotGame(self, data):
        for model_data, id in data:
            # create model objects from the yaml received
            model = loader.fromDict(model_data)
            self.remote_models[model] = id

            # and alert the gui and other listeners that models are 
            # alive and kicking.
            dispatcher.send(signal=New, sender='remote', model=model)

            # start telling the gui about the received object
            model.present()
コード例 #15
0
 def perspective_receivePropertyChange(self, sender, object_id, property,
                                       old, value):
     """Called by the client to notify that an object property 
     has changed.
     Notifies the dispatch mechanism.
     """
     model = self.models[object_id]
     dispatcher.send(signal=model,
                     sender=self.username,
                     property=property,
                     old=old,
                     value=value)
コード例 #16
0
    def gotGame(self, data):
        for model_data, id in data:
            # create model objects from the yaml received
            model = loader.fromDict(model_data)
            self.remote_models[model] = id

            # and alert the gui and other listeners that models are
            # alive and kicking.
            dispatcher.send(signal=New, sender='remote', model=model)

            # start telling the gui about the received object
            model.present()
コード例 #17
0
 def __delete__(self, client):
     """Override to send dispatcher messages on deletion"""
     value = super(Observable, self).__delete__(client)
     try:
         dispatcher.send(
             signal=self.DELETE_SIGNAL,
             sender=self,
             client=client,
         )
     except Exception, err:
         # you'd actually want to log here...
         pass
コード例 #18
0
 def remote_receivePropertyChange(self, sender, object_id, property, old,
                                  value):
     """Called by the avatar to notify that an object has moved, 
     changed colors, etc.
     Notifies the dispatch mechanism.
     """
     model = self.remote_models[object_id]
     dispatcher.send(signal=model,
                     sender='remote',
                     property=property,
                     old=old,
                     value=value)
コード例 #19
0
ファイル: models.py プロジェクト: BackupTheBerlios/vellum-svn
 def receivePropertyChange(self, 
                           signal, 
                           sender, 
                           property, 
                           old, 
                           value):
     if signal in self.endpoints:
         locations = self.locations
         dispatcher.send(signal=self,
                         sender='connector',
                         property='locations',
                         old=None,
                         value=locations)
コード例 #20
0
 def __set__(self, client, value):
     """Override to send dispatcher messages on setting"""
     value = super(Observable, self).__set__(client, value)
     try:
         dispatcher.send(
             signal=self.SET_SIGNAL,
             sender=self,
             value=value,
             client=client,
         )
     except Exception, err:
         # you'd actually want to log here...
         pass
コード例 #21
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def remote_receiveDropModel(self,
                             sender,
                             object_id,):
     """Called by the avatar to notify that an object 
     on the map needs to go away.
     Notifies the dispatch mechanism.
     """
     print 'received propagated drop of model', object_id
     model = self.remote_models[object_id]
     dispatcher.send(signal=Drop,
                     sender='remote',
                     model=model)
     del self.remote_models[object_id]
コード例 #22
0
 def perspective_receiveDropModel(
     self,
     sender,
     object_id,
 ):
     """Called by the client to notify that an object needs 
     to go away.
     Notifies the dispatch mechanism.
     """
     print 'got proclamation of model removal', object_id
     model = self.models[object_id]
     dispatcher.send(signal=Drop, sender=self.username, model=model)
     del self.models[object_id]
コード例 #23
0
 def remote_receiveDropModel(
     self,
     sender,
     object_id,
 ):
     """Called by the avatar to notify that an object 
     on the map needs to go away.
     Notifies the dispatch mechanism.
     """
     print 'received propagated drop of model', object_id
     model = self.remote_models[object_id]
     dispatcher.send(signal=Drop, sender='remote', model=model)
     del self.remote_models[object_id]
コード例 #24
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def perspective_receiveDropModel(self, 
                                  sender, 
                                  object_id,):
     """Called by the client to notify that an object needs 
     to go away.
     Notifies the dispatch mechanism.
     """
     print 'got proclamation of model removal', object_id
     model = self.models[object_id]
     dispatcher.send(signal=Drop,
                     sender=self.username,
                     model=model)
     del self.models[object_id]
コード例 #25
0
 def perspective_receiveNewModel(
     self,
     sender,
     type,
     object_id,
 ):
     """Called by the client to notify that a new object has 
     appeared.
     Notifies the dispatch mechanism.
     """
     print 'received and adding model', object_id
     model = loader.typeByName(type)()
     self.models[model] = object_id
     dispatcher.send(signal=New, sender=self.username, model=model)
コード例 #26
0
 def loadSavedGame(self):
     loaded = yaml.loadFile(fs.saved).next()
     for id, data in loaded.items():
         model = loader.fromDict(data)
         self.models[model] = id
         dispatcher.send(signal=New, sender='realm', model=model)
         for prop, value in data.items():
             if prop == 'TYPE':
                 continue
             dispatcher.send(signal=model,
                             sender='realm',
                             property=prop,
                             old=None,
                             value=value)
コード例 #27
0
 def _operation(self, opcode, *args):
     if opcode == 'add':
         itemtype, root = args
         oid = itemtype+'/'+self._create_id()
         if root is None:
             view = self.db.getas('%s[%s]'%(itemtype, itemtypes[itemtype]._attributes()))
         else:
             view = getattr(self[root]._row, itemtype)
             oid = root+':'+oid
         view.append(oid=oid)
         inv = ('del', oid)
         dispatcher.send('add-object', self, oid)
     elif opcode == 'del':
         oid, = args
         obj = self[oid]
         obj._row.deleted = True
         del self.items[oid]
         inv = ('und', obj._row.oid)
         dispatcher.send('delete-object', self, oid)
     elif opcode == 'und':
         oid, = args
         obj = self[oid]
         obj._row.deleted = False
         inv = ('del', obj._row.oid)
         dispatcher.send('add-object', self, oid)
     elif opcode == 'set':
         oid, name, value = args 
         inv = ('set', oid, name, getattr(self[oid]._row, name))
         setattr(self[oid]._row, name, value)
         dispatcher.send('set-attr', self[oid], name)
     self.oplist.append(inv)
コード例 #28
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def loadSavedGame(self):
     loaded = yaml.loadFile(fs.saved).next()
     for id, data in loaded.items():
         model = loader.fromDict(data)
         self.models[model] = id
         dispatcher.send(signal=New, sender='realm', model=model)
         for prop, value in data.items():
             if prop == 'TYPE':
                 continue
             dispatcher.send(signal=model, 
                             sender='realm', 
                             property=prop,
                             old=None, 
                             value=value)
コード例 #29
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def perspective_receiveNewModel(self,
                                 sender,
                                 type,
                                 object_id,):
     """Called by the client to notify that a new object has 
     appeared.
     Notifies the dispatch mechanism.
     """
     print 'received and adding model', object_id
     model = loader.typeByName(type)()
     self.models[model] = object_id
     dispatcher.send(signal=New,
                     sender=self.username,
                     model=model)
コード例 #30
0
ファイル: view.py プロジェクト: BackupTheBerlios/vellum-svn
 def on_background_gdk_button_release(self, widget, ev, background):
     """on right click make a new character"""
     if ev.button == 3:
         # create a new Character, and move it to the position of click
         character = Character()
         dispatcher.send(signal=New, 
                         sender='gui', 
                         model=character)
         dispatcher.send(signal=character, 
                         sender='gui', 
                         property='location', 
                         old=character.location,
                         value=(ev.x, ev.y)
                         )
コード例 #31
0
 def remote_receiveNewModel(
     self,
     sender,
     type,
     object_id,
 ):
     """Called by the avatar to notify that a new object 
     has appeared on the map.
     Notifies the dispatch mechanism.
     """
     print 'received propagated model', object_id
     model = loader.typeByName(type)()
     self.remote_models[model] = object_id
     dispatcher.send(signal=New, sender='remote', model=model)
     model.present()
コード例 #32
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def remote_receiveNewModel(self,
                            sender,
                            type,
                            object_id,):
     """Called by the avatar to notify that a new object 
     has appeared on the map.
     Notifies the dispatch mechanism.
     """
     print 'received propagated model', object_id
     model = loader.typeByName(type)()
     self.remote_models[model] = object_id
     dispatcher.send(signal=New,
                     sender='remote',
                     model=model)
     model.present()
コード例 #33
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def remote_receivePropertyChange(self, 
                                  sender, 
                                  object_id, 
                                  property, 
                                  old, 
                                  value):
     """Called by the avatar to notify that an object has moved, 
     changed colors, etc.
     Notifies the dispatch mechanism.
     """
     model = self.remote_models[object_id]
     dispatcher.send(signal=model, 
                     sender='remote', 
                     property=property, 
                     old=old, 
                     value=value)
コード例 #34
0
ファイル: net.py プロジェクト: BackupTheBerlios/vellum-svn
 def perspective_receivePropertyChange(self, 
                                       sender, 
                                       object_id, 
                                       property,
                                       old, 
                                       value):
     """Called by the client to notify that an object property 
     has changed.
     Notifies the dispatch mechanism.
     """
     model = self.models[object_id]
     dispatcher.send(signal=model, 
                     sender=self.username,
                     property=property,
                     old=old, 
                     value=value)
コード例 #35
0
ファイル: TkTime.py プロジェクト: drewp/eventually
 def select(parse):
     if parse is None:
         self.text.tag_config(tag,
                              background=self.parsed_color,
                              borderwidth=1,
                              relief='raised')
     else:
         self.text.tag_config(tag,
                              background=self.selected_color,
                              borderwidth=1,
                              relief='raised')
     # remember our selection
     self.selections[str(segment)] = parse
     dispatcher.send("selection made",
                     segment=segment,
                     selection=parse,
                     tag=tag,
                     segmentnum=tagnum,
                     sender=self)
コード例 #36
0
ファイル: TkTime.py プロジェクト: drewp/eventually
    def display_parses(self, text, force_update=False):
        sig = getsignature(text)
        if sig == self.last_sig and not force_update:
            return
        else:
            self.last_sig = sig

        # reset our tags and popup menus
        for tag in self.tags:
            self.text.tag_delete(tag)
        self.popups = []

        self.tags = []
        parse = NLTime.Parse(text, context=self.time_context)
        segments = parse.segments
        dispatcher.send("new parses", segments=segments, sender=self)
        for segmentnum, segment in enumerate(segments):
            valid_parses = segment.valid_parses()
            start, end = segment.extent()
            start = ("%d.%d" % start)
            end = ("%d.%d" % end)
            tag = 'seg%d' % segmentnum
            if valid_parses:
                if self.selections.get(str(segment)):
                    color = self.selected_color
                else:
                    color = self.parsed_color
                self.text.tag_config(tag,
                                     background=color,
                                     borderwidth=1,
                                     relief='raised')
                self.popups.append(self.make_menu(tag, segment, valid_parses))
            else:
                self.text.tag_config(tag, background=self.unparsed_color)
            self.add_tag(tag, start, end)
            dispatcher.send("new segment parses",
                            segmentnum=segmentnum,
                            segment=segment,
                            parses=valid_parses,
                            sender=self)
        if not segments:
            dispatcher.send("no parses", sender=self)
コード例 #37
0
ファイル: TkTime.py プロジェクト: drewp/eventually
    def display_parses(self, text, force_update=False):
        sig = getsignature(text)
        if sig == self.last_sig and not force_update:
            return
        else:
            self.last_sig = sig

        # reset our tags and popup menus
        for tag in self.tags:
            self.text.tag_delete(tag)
        self.popups = []

        self.tags = []
        parse = NLTime.Parse(text, context=self.time_context)
        segments = parse.segments
        dispatcher.send("new parses", segments=segments, sender=self)
        for segmentnum, segment in enumerate(segments):
            valid_parses = segment.valid_parses()
            start, end = segment.extent()
            start = ("%d.%d" % start)
            end = ("%d.%d" % end)
            tag = 'seg%d' % segmentnum
            if valid_parses:
                if self.selections.get(str(segment)):
                    color = self.selected_color
                else:
                    color = self.parsed_color
                self.text.tag_config(tag, background=color, borderwidth=1,
                    relief='raised')
                self.popups.append(self.make_menu(tag, segment, valid_parses))
            else:
                self.text.tag_config(tag, background=self.unparsed_color)
            self.add_tag(tag, start, end)
            dispatcher.send("new segment parses", segmentnum=segmentnum,
                segment=segment, parses=valid_parses, sender=self)
        if not segments:
            dispatcher.send("no parses", sender=self)
コード例 #38
0
 def _notify_set__data(self, value, old):
     dispatcher.send('modified', sender=self.worksheet)
コード例 #39
0
 def _notify_set__name(self, name, old):
     dispatcher.send('modified', sender=self.worksheet)
コード例 #40
0
 def receiveDropModel(self, sender, model):
     """If model is one of the endpoints, I should be destroyed too"""
     if sender == 'gui':
         print 'connector committing suicide. sender was', sender
         if model in self.endpoints:
             dispatcher.send(signal=Drop, sender='connector', model=self)
コード例 #41
0
ファイル: mdi.py プロジェクト: BackupTheBerlios/grafity-svn
import sys

from PyQt4.Qt import *
from dispatch import dispatcher

dispatcher.send('splash-message', msg='Loading modules...')

from pkg_resources import resource_stream
from grafity.base.items import Folder
from grafity.base.graph import Graph
from grafity.base.worksheet import Worksheet
from grafity.base.project import Project
from grafity.ui.console import Console
from grafity.ui.properties import Properties
from grafity.ui.forms import qtresources


class TreeModel(QAbstractItemModel):
    def __init__(self, project, parent=None):
        QAbstractItemModel.__init__(self, parent)
        self.project = project
        self.ids = {}
        
        dispatcher.connect(self.update, signal='added')
        dispatcher.connect(self.update, signal='removed')

    def update(self, folder=None):
        print >>sys.stderr, 'update', type(folder)
        self.emit(SIGNAL("layoutChanged()"))

    def headerData(self, section, orientation, role):
コード例 #42
0
 def on_draggable_gdk_button_release(self, widget, event, model):
     if event.button == 1:
         model.selected = not model.selected
         model.grabbed = False
     elif event.button == 3:
         dispatcher.send(signal=Drop, sender='gui', model=model)