Beispiel #1
0
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_()
Beispiel #2
0
    def __init__(self, master):
        Tk.Frame.__init__(self, master)
        self.tktime = TkTime(self,
                             bg='black',
                             fg='white',
                             insertbackground='white',
                             parsed_color='blue',
                             special_symbols=[NotPresent])
        self.tktime.pack(side='top', fill='both', expand=1)

        contextframe = Tk.Frame(self)
        contexttext = Tk.Label(contextframe, text='Context')
        contexttext.pack(side='left', ipadx=0, ipady=0, padx=0, pady=0)
        self.context = TkTime(contextframe)
        dispatcher.connect(self.context_selector,
                           "selection made",
                           sender=self.context)
        dispatcher.connect(self.context_has_parses,
                           "new segment parses",
                           sender=self.context)
        self.context['height'] = 23  # errr...
        self.context.pack(side='left', fill='x', expand=0)
        self.contextlabel = Tk.Label(contextframe)
        self.contextlabel.pack(side='left',
                               ipadx=0,
                               ipady=0,
                               padx=0,
                               pady=0,
                               expand=1)
        contextframe.pack(side='top', fill='both', expand=0)

        self.context.text.bind("<KeyRelease>", self.typed_in_context, '+')
Beispiel #3
0
    def __init__(self):
        filename = 'foo.db'
        self.store = Store(filename)
        dispatcher.connect(self.on_action)

        self.store.begin('foobar')
        try:
            m = self.store.meta.create()
            m.name, m.value = 'foo', 'bar'
            f = self.store.folders.create()
            f.parent = m
        finally:
            self.store.commit()

        st2 = Store('foo.bar')
        st2.folders.create()
        st2.folders.create()
        st2.folders.create()
        print len(st2.folders)
        print len(self.store.folders)
        print m.name, m.value
        print >>sys.stderr, 'PA', f.parent
        self.store.undo()
        self.store.redo()
        self.store.close()
    def __init__(self, filename=None):
#        try:
#            os.remove('foo.db')
#        except:
#            pass
        self.store = Store(filename)
        self.modified = False
        dispatcher.connect(self.on_action)

        # top folder
        if len(self.store.folders) == 0:
            self.top = self.store.folders.create()
            self.top._project = self
            self.top.folder = self.top
            self.top.name = 'top'
        else:
            self.top = self.store.folders[0]
            self.top._project = self

        for c in self.store.containers():
            for item in c:
                item._project = self

        for f in self.store.folders:
            f._update_contents()
Beispiel #5
0
 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')
Beispiel #6
0
    def __init__(self):
        # these use strong references to avoid a warning when they are
        # garbage collected.
        dispatcher.connect(self.receiveNew, signal=New, weak=False)
        dispatcher.connect(self.receiveDrop, signal=Drop, weak=False)

        self.observers = []
        self.models = []
Beispiel #7
0
    def __init__(self):
        # these use strong references to avoid a warning when they are
        # garbage collected.
        dispatcher.connect(self.receiveNew, signal=New, weak=False)
        dispatcher.connect(self.receiveDrop, signal=Drop, weak=False)

        self.observers = []
        self.models = []
Beispiel #8
0
 def __init__(self):
     # FIXME? if receiver is a regular method, I get
     # TypeError: unsubscriptable object from pydispatcher when
     # the Modelable is gc'd.
     # when it's a lambda held in an instance variable, no error.
     self.receiver = (
         lambda sender, property, value: self.reify(property, value))
     dispatcher.connect(self.receiver, self)
Beispiel #9
0
 def __init__(self):
     # FIXME? if receiver is a regular method, I get 
     # TypeError: unsubscriptable object from pydispatcher when
     # the Modelable is gc'd.
     # when it's a lambda held in an instance variable, no error.
     self.receiver = (
             lambda sender,property,value: self.reify(property, value)
                      )
     dispatcher.connect(self.receiver, self)
    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
Beispiel #11
0
    def __init__(self, master):
        Tk.Frame.__init__(self, master)
        self.tktime = TkTime(self, bg='black', fg='white',
            insertbackground='white', parsed_color='blue',
            special_symbols=[NotPresent])
        self.tktime.pack(side='top', fill='both', expand=1)

        contextframe = Tk.Frame(self)
        contexttext = Tk.Label(contextframe, text='Context')
        contexttext.pack(side='left', ipadx=0, ipady=0, padx=0, pady=0)
        self.context = TkTime(contextframe)
        dispatcher.connect(self.context_selector, "selection made",
            sender=self.context)
        dispatcher.connect(self.context_has_parses, "new segment parses",
            sender=self.context)
        self.context['height'] = 23 # errr...
        self.context.pack(side='left', fill='x', expand=0)
        self.contextlabel = Tk.Label(contextframe)
        self.contextlabel.pack(side='left', ipadx=0, ipady=0, padx=0, pady=0,
            expand=1)
        contextframe.pack(side='top', fill='both', expand=0)

        self.context.text.bind("<KeyRelease>", self.typed_in_context, '+')
Beispiel #12
0
    def __init__(self, master):
        TkTimeWithContext.__init__(self, master)
        dispatcher.connect(self.reset_bins, "new parses", sender=self.tktime)
        dispatcher.connect(self.new_segment_parses, "new segment parses",
            sender=self.tktime)
        dispatcher.connect(self.draw_bins, "no parses", sender=self.tktime)

        self.bins = {} # name : Bin object
        self.bins_sorted = []
        for name in bin_names:
            b = Bin(self, name=name, contents=[])
            self.bins[name] = b
            self.bins_sorted.append(b)
Beispiel #13
0
    def __init__(self, master):
        TkTimeWithContext.__init__(self, master)
        dispatcher.connect(self.reset_bins, "new parses", sender=self.tktime)
        dispatcher.connect(self.new_segment_parses,
                           "new segment parses",
                           sender=self.tktime)
        dispatcher.connect(self.draw_bins, "no parses", sender=self.tktime)

        self.bins = {}  # name : Bin object
        self.bins_sorted = []
        for name in bin_names:
            b = Bin(self, name=name, contents=[])
            self.bins[name] = b
            self.bins_sorted.append(b)
        )
        values = IntegersProperty(
            "values",
            """Set of observable integers""",
        )

    def onDel(sender, client):
        """Process a change to a Model Object"""
        print 'DEL', sender.name, client

    def onSet(sender, client, value):
        """Process value from *any* property"""
        print 'SET', sender.name, client, value

    dispatcher.connect(
        onSet,
        # we assume the default SET_SIGNAL here
        signal=Observable.SET_SIGNAL,
    )
    dispatcher.connect(
        onDel,
        # we assume the default DELETE_SIGNAL here
        signal=Observable.DELETE_SIGNAL,
    )
    m = Model()
    m.name = 'Peters'
    m.age  # note we send a message, as the default is __set__ on retrieval
    m.age = 18
    m.values = [2, 3, 4, '8']
    del m.values
Beispiel #15
0
 def registerObserver(self, observer):
     for model in self.models:
         dispatcher.connect(observer.receivePropertyChange, signal=model)
     dispatcher.connect(observer.receiveNewModel, signal=New)
     dispatcher.connect(observer.receiveDropModel, signal=Drop)
     self.observers.append(observer)
Beispiel #16
0
 def receiveNew(self, sender, signal, model):
     if sender is self:
         return
     self.models.append(model)
     for observer in self.observers:
         dispatcher.connect(observer.receivePropertyChange, signal=model)
Beispiel #17
0
 def registerObserver(self, observer):
     for model in self.models:
         dispatcher.connect(observer.receivePropertyChange, signal=model)
     dispatcher.connect(observer.receiveNewModel, signal=New)
     dispatcher.connect(observer.receiveDropModel, signal=Drop)
     self.observers.append(observer)
Beispiel #18
0
 def receiveNew(self, sender, signal, model):
     if sender is self:
         return
     self.models.append(model)
     for observer in self.observers:
         dispatcher.connect(observer.receivePropertyChange, signal=model)
 def __init__(self, worksheet):
     QAbstractTableModel.__init__(self)
     self.worksheet = worksheet
     dispatcher.connect(self.update, sender=self.worksheet, signal='modified')