예제 #1
0
class FamilyWin(CommandBoxWindow, HasDialogs):
    def __init__(self, conn, name='FamilyWin'):
        if name is None:
            name = '.'.join([suite, 'traits'])
        CommandBoxWindow.__init__(self, name=name)
        self.conn = conn
        self.set_title(name)
        self.browser = FamilyBrowser(self.conn)
        self.__make_menus__()
        self.vbox.pack_start(self.menu_bar, 0, 0, 0)
        self.vbox.add(self.browser)
        self.dialogs = {}.fromkeys(['create'])

    def __make_menus__(self):
        self.menu_bar = SimpleMenuBar()
        self.main_menu = SimpleMenu()
        self.tbar.add_button('create', 'create family', self.ask_dialog)
        self.tbar.add_button('variables', 'show all variables',
                             self.create_list_dialog)
        self.tbar.add_button('families', 'show all families',
                             self.create_list_dialog)
        #self.main_menu.add('create', self.ask_dialog)
        #self.main_menu.add('packages', self.create_package_list)
        #self.main_menu.add('traits', self.create_package_list)
        #self.menu_bar.append(self.main_menu, 'main')

    def ask_dialog(self, button, data):
        if not self.dialogs[data]:
            if data == 'create':
                self.dialogs[data] = dialogs.Entry('create family',
                                                   name='create')
                self.dialogs[data].set_ok(self.create_family)
            self.dialogs[data].set_cancel(self.destroy_dialog)

    def create_family(self, button):
        name = button.get_name()
        if name == 'create':
            family = self.dialogs[name].get()
            try:
                self.browser.family.create_family(family)
            except ExistsError:
                dialogs.Message('family %s already exists' % family)
            self.destroy_dialog(self.dialogs['create'])
            self.browser.reset_rows()

    def create_list_dialog(self, button, data):
        if data == 'variables':
            self.browser.make_variables_window()
        elif data == 'families':
            self.browser.make_families_window()

    def make_suite_menu(self):
        self.suite_menu = SimpleMenu()
        suites = self.cmd.as_dict('suites', 'suite')
        for suite in suites:
            self.suite_menu.add(suite, self.browser.change_suite)
        self.menu_bar.append(self.suite_menu, 'suite')
        self.suite = suite
예제 #2
0
class FamilyWin(CommandBoxWindow, HasDialogs):
    def __init__(self, conn, name='FamilyWin'):
        if name is None:
            name = '.'.join([suite, 'traits'])
        CommandBoxWindow.__init__(self, name=name)
        self.conn = conn
        self.set_title(name)
        self.browser = FamilyBrowser(self.conn)
        self.__make_menus__()
        self.vbox.pack_start(self.menu_bar, 0, 0, 0)
        self.vbox.add(self.browser)
        self.dialogs = {}.fromkeys(['create'])


    def __make_menus__(self):
        self.menu_bar = SimpleMenuBar()
        self.main_menu = SimpleMenu()
        self.tbar.add_button('create', 'create family', self.ask_dialog)
        self.tbar.add_button('variables', 'show all variables', self.create_list_dialog)
        self.tbar.add_button('families', 'show all families', self.create_list_dialog)
        #self.main_menu.add('create', self.ask_dialog)
        #self.main_menu.add('packages', self.create_package_list)
        #self.main_menu.add('traits', self.create_package_list)
        #self.menu_bar.append(self.main_menu, 'main')
        
    def ask_dialog(self, button, data):
        if not self.dialogs[data]:
            if data == 'create':
                self.dialogs[data] = dialogs.Entry('create family', name='create')
                self.dialogs[data].set_ok(self.create_family)
            self.dialogs[data].set_cancel(self.destroy_dialog)

    def create_family(self, button):
        name = button.get_name()
        if name == 'create':
            family = self.dialogs[name].get()
            try:
                self.browser.family.create_family(family)
            except ExistsError:
                dialogs.Message('family %s already exists' % family)
            self.destroy_dialog(self.dialogs['create'])
            self.browser.reset_rows()

    def create_list_dialog(self, button, data):
        if data == 'variables':
            self.browser.make_variables_window()
        elif data == 'families':
            self.browser.make_families_window()

    def make_suite_menu(self):
        self.suite_menu = SimpleMenu()
        suites = self.cmd.as_dict('suites', 'suite')
        for suite in suites:
            self.suite_menu.add(suite, self.browser.change_suite)
        self.menu_bar.append(self.suite_menu, 'suite')
        self.suite = suite
예제 #3
0
class TraitGenWin(CommandBoxWindow, HasDialogs):
    def __init__(self, conn, suite, name=None):
        if name is None:
            name = '.'.join([suite, 'traits'])
        CommandBoxWindow.__init__(self, name=name)
        self.conn = conn
        self.suite = suite
        self.set_title(name)
        self.browser = TraitBrowser(self.conn, self.suite)
        self.__make_menus__()
        self.vbox.pack_start(self.menu_bar, 0, 0, 0)
        self.vbox.add(self.browser)
        self.dialogs = {}.fromkeys(['create'])


    def __make_menus__(self):
        self.menu_bar = SimpleMenuBar()
        self.main_menu = SimpleMenu()
        self.tbar.add_button('create', 'create trait', self.ask_dialog)
        self.tbar.add_button('packages', 'show all packages', self.create_package_list)
        self.tbar.add_button('traits', 'show all traits', self.create_package_list)
        self.main_menu.add('create', self.ask_dialog)
        self.main_menu.add('packages', self.create_package_list)
        self.main_menu.add('traits', self.create_package_list)
        self.menu_bar.append(self.main_menu, 'main')
        
    def ask_dialog(self, button, data):
        if not self.dialogs[data]:
            if data == 'create':
                self.dialogs[data] = dialogs.Entry('create trait', name='create')
                self.dialogs[data].set_ok(self.create_trait)
            self.dialogs[data].set_cancel(self.destroy_dialog)

    def create_trait(self, button):
        name = button.get_name()
        debug(name)
        if name == 'create':
            trait = self.dialogs[name].get()
            try:
                self.browser.trait.create_trait(trait)
            except ExistsError:
                dialogs.Message('trait %s already exists' % trait)
                self.browser.traits.insert(data=insert_data)
            self.destroy_dialog(self.dialogs['create'])
            self.browser.reset_rows()

    def create_package_list(self, button, data):
        if data == 'packages':
            PackagesWindow(self.conn, self.browser.suite)
        elif data == 'traits':
            TraitsWindow(self.conn, self.browser.suite)

    def make_suite_menu(self):
        self.suite_menu = SimpleMenu()
        suites = self.cmd.as_dict('suites', 'suite')
        for suite in suites:
            self.suite_menu.add(suite, self.browser.change_suite)
        self.menu_bar.append(self.suite_menu, 'suite')
        self.suite = suite