Beispiel #1
0
 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
Beispiel #2
0
 def __init__(self, conn, name='_EnvironmentEditor'):
     ListNoteBook.__init__(self, name=name)
     self.conn = conn
     self.main = StatementCursor(self.conn, name=name)
     self.append_page(RecordBox({}), 'Environment')
     self.menu = SimpleMenu()
     self.delimiters = DELIMITERS['out-arrows']
     self.dialogs = {}.fromkeys(['create', 'remove'])
Beispiel #3
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
Beispiel #4
0
 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')
Beispiel #5
0
class _EnvironmentEditor(ListNoteBook):
    def __init__(self, conn, name='_EnvironmentEditor'):
        ListNoteBook.__init__(self, name=name)
        self.conn = conn
        self.main = StatementCursor(self.conn, name=name)
        self.append_page(RecordBox({}), 'Environment')
        self.menu = SimpleMenu()
        self.delimiters = DELIMITERS['out-arrows']
        self.dialogs = {}.fromkeys(['create', 'remove'])

    def box_pressed(self, widget, event=None):
        if right_click_pressed(event):
            self.menu.popup(None, None, None, event.button, event.time)

    def populate_menu(self, widget, mainmenu, itementry, tmenu):
        self.current_entry = itementry
        self._current_entry_widget_ = widget
        populate_menu(mainmenu, '_define_', ['_create_', '_remove_'],
                      self.make_new_tag)
        for section, vars in self.sections.items():
            populate_menu(mainmenu, section, vars, self.make_tag)

    def make_new_tag(self, menuitem, name, pmenu):
        if name == '_create_':
            self.ask_new_entry()
        elif name == '_remove_':
            self.ask_remove_key()

    def ask_new_entry(self):
        if self.dialogs['create'] is None:
            data = dict(name='', value='')
            self.dialogs['create'] = dialogs.RecordEntry(
                'enter a new variable', data, 'create')
            self.dialogs['create'].set_cancel(self.destroy_dialog)
            self.dialogs['create'].set_ok(self.make_new_variable)

    def ask_remove_key(self):
        if self.dialogs['remove'] is None:
            self.dialogs['remove'] = dialogs.CList('remove which item',
                                                   name='remove')
            d = self.dialogs['remove']
            d.set_rows(self.record.keys(), ['name'])
            self.dialogs['remove'].set_cancel(self.destroy_dialog)
            self.dialogs['remove'].set_ok(self.remove_item)

    def make_tag(self, menuitem, name, parent):
        trait = parent.get_name()
        print trait, name
        self.pages['Environment']
        self._current_entry_widget_.set_text('$' + trait + '_' + name)
Beispiel #6
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.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
Beispiel #7
0
class _EnvironmentEditor(ListNoteBook):
    def __init__(self, conn, name='_EnvironmentEditor'):
        ListNoteBook.__init__(self, name=name)
        self.conn = conn
        self.main = StatementCursor(self.conn, name=name)
        self.append_page(RecordBox({}), 'Environment')
        self.menu = SimpleMenu()
        self.delimiters = DELIMITERS['out-arrows']
        self.dialogs = {}.fromkeys(['create', 'remove'])
        
    def box_pressed(self, widget, event=None):
        if right_click_pressed(event):
            self.menu.popup(None, None, None, event.button, event.time)
        
    def populate_menu(self, widget, mainmenu, itementry, tmenu):
        self.current_entry = itementry
        self._current_entry_widget_ = widget
        populate_menu(mainmenu, '_define_', ['_create_', '_remove_'], self.make_new_tag)
        for section, vars in self.sections.items():
            populate_menu(mainmenu, section, vars, self.make_tag)


    def make_new_tag(self, menuitem, name, pmenu):
        if name == '_create_':
            self.ask_new_entry()
        elif name == '_remove_':
            self.ask_remove_key()

    def ask_new_entry(self):
        if self.dialogs['create'] is None:
            data = dict(name='', value='')
            self.dialogs['create'] = dialogs.RecordEntry('enter a new variable',
                                                         data, 'create')
            self.dialogs['create'].set_cancel(self.destroy_dialog)
            self.dialogs['create'].set_ok(self.make_new_variable)

    def ask_remove_key(self):
        if self.dialogs['remove'] is None:
            self.dialogs['remove'] = dialogs.CList('remove which item', name='remove')
            d = self.dialogs['remove']
            d.set_rows(self.record.keys(), ['name'])
            self.dialogs['remove'].set_cancel(self.destroy_dialog)
            self.dialogs['remove'].set_ok(self.remove_item)

    def make_tag(self, menuitem, name, parent):
        trait = parent.get_name()
        print trait, name
        self.pages['Environment']
        self._current_entry_widget_.set_text('$' + trait + '_' + name)
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
Beispiel #9
0
 def __init__(self, conn):
     ScrolledWindow.__init__(self)
     self.conn = conn
     self.editor = TemplateEditor()
     self.menu = SimpleMenu()
     self.editor.connect('populate-popup', self.populate_menu, self.menu)
     self.add_with_viewport(self.editor)
     self.show()
Beispiel #10
0
 def __init__(self, conn, name='_EnvironmentEditor'):
     ListNoteBook.__init__(self, name=name)
     self.conn = conn
     self.main = StatementCursor(self.conn, name=name)
     self.append_page(RecordBox({}), 'Environment')
     self.menu = SimpleMenu()
     self.delimiters = DELIMITERS['out-arrows']
     self.dialogs = {}.fromkeys(['create', 'remove'])
Beispiel #11
0
 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')
Beispiel #12
0
 def __init__(self, conn, suite, trait):
     MyNotebook.__init__(self)
     self.conn = conn
     self.suite = suite
     self.trait = trait
     self.script = TraitScript(self.conn, self.suite)
     self.script.set_trait(trait)
     self.menu = SimpleMenu()
     for row in self.script.scripts():
         name = row.script
         sfile = self.script.scriptfile(name)
         self.append_script(name, sfile.read())
         sfile.close()
Beispiel #13
0
 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)