示例#1
0
class BaseDiffer(VBox):
    def __init__(self, conn, name='BaseDiffer'):
        VBox.__init__(self)
        self.set_name(name)
        self.conn = conn
        self.view = TwinScrollCList(name=name)
        self.cursor = StatementCursor(self.conn)
        suites = [
            r.suite for r in self.cursor.select(table='suites', order='suite')
        ]
        self.suite_bar = SuiteBar(suites, name=name)
        self.trait_bar = TraitBar(name=name)
        self.pack_end(self.suite_bar, 0, 0, 0)
        self.pack_end(self.trait_bar, 0, 0, 0)
        self.add(self.view)
        self.suite_bar.show()
        self.show()

    def update_lists(self, fields, suffix):
        self.lsuite = self.suite_bar.lcombo.get()
        self.rsuite = self.suite_bar.rcombo.get()
        self.cursor.set_fields(fields)
        clause = None
        ltrait = self.trait_bar.lcombo.get()
        if ltrait:
            clause = Eq('trait', ltrait)
        table = '%s_%s' % (self.lsuite, suffix)
        rows = self.cursor.select(table=table, clause=clause, order=fields)
        self.view.lbox.set_rows(rows)
        clause = None
        rtrait = self.trait_bar.rcombo.get()
        if rtrait:
            clause = Eq('trait', rtrait)
        table = '%s_%s' % (self.rsuite, suffix)
        rows = self.cursor.select(table=table, clause=clause, order=fields)
        self.view.rbox.set_rows(rows)
        fields = ['trait']
        self.cursor.set_fields(fields)
        rows = self.cursor.select(table='%s_traits' % self.lsuite,
                                  order=fields)
        ltraits = [r.trait for r in rows]
        rows = self.cursor.select(table='%s_traits' % self.rsuite,
                                  order=fields)
        rtraits = [r.trait for r in rows]
        self.trait_bar.lcombo.fill(ltraits)
        self.trait_bar.rcombo.fill(rtraits)
        if ltrait and ltrait in ltraits:
            self.trait_bar.lcombo.set(ltrait)
        else:
            self.trait_bar.lcombo.set('')
        if rtrait and rtrait in rtraits:
            self.trait_bar.rcombo.set(rtrait)
        else:
            self.trait_bar.rcombo.set('')
示例#2
0
class BaseDiffer(VBox):
    def __init__(self, conn, name='BaseDiffer'):
        VBox.__init__(self)
        self.set_name(name)
        self.conn = conn
        self.view = TwinScrollCList(name=name)
        self.cursor = StatementCursor(self.conn)
        suites = [r.suite for r in self.cursor.select(table='suites', order='suite')]
        self.suite_bar = SuiteBar(suites, name=name)
        self.trait_bar = TraitBar(name=name)
        self.pack_end(self.suite_bar, 0, 0, 0)
        self.pack_end(self.trait_bar, 0, 0, 0)
        self.add(self.view)
        self.suite_bar.show()
        self.show()

    def update_lists(self, fields, suffix):
        self.lsuite = self.suite_bar.lcombo.get()
        self.rsuite = self.suite_bar.rcombo.get()
        self.cursor.set_fields(fields)
        clause = None
        ltrait = self.trait_bar.lcombo.get()
        if ltrait:
            clause = Eq('trait', ltrait)
        table = '%s_%s' % (self.lsuite, suffix)
        rows = self.cursor.select(table=table, clause=clause, order=fields)
        self.view.lbox.set_rows(rows)
        clause = None
        rtrait = self.trait_bar.rcombo.get()
        if rtrait:
            clause = Eq('trait', rtrait)
        table = '%s_%s' % (self.rsuite, suffix)
        rows = self.cursor.select(table=table, clause=clause, order=fields)
        self.view.rbox.set_rows(rows)
        fields = ['trait']
        self.cursor.set_fields(fields)
        rows = self.cursor.select(table='%s_traits' % self.lsuite, order=fields)
        ltraits = [r.trait for r in rows]
        rows = self.cursor.select(table='%s_traits' % self.rsuite, order=fields)
        rtraits = [r.trait for r in rows]
        self.trait_bar.lcombo.fill(ltraits)
        self.trait_bar.rcombo.fill(rtraits)
        if ltrait and ltrait in ltraits:
            self.trait_bar.lcombo.set(ltrait)
        else:
            self.trait_bar.lcombo.set('')
        if rtrait and rtrait in rtraits:
            self.trait_bar.rcombo.set(rtrait)
        else:
            self.trait_bar.rcombo.set('')