def list_connection(self, limit = setup_options.getLimit(), page = 1):
     print "======= Listing conectors ======="
     print "===========In case you want to delete a project press d plus the number =========================="
     quantity_connectors = self.conector_db.retrieveAllCount(self.element_id)
     number = 1
     while number != 0:
         conectores = self.conector_db.selectAll(self.element_id, limit, page)
         for conector in conectores:
             print "{0}: {1}".format(conector.id, conector)
         
         if page > 1:
             print "To go to the previous page press < "
         
         if (page * limit) < quantity_connectors:
             print "To go to the next page press > "
             
         option = raw_input("Select the number to edit or 0 to come back\n")
         try:
             if option == "<":
                 self.list_connection(limit, page - 1)
                 number = 0
             elif option == ">":
                 self.list_connection(limit, page + 1)
                 number = 0
             else:
                 number = int(option)
                 if number != 0:
                     self.edit_conector(number)
                     
         except ValueError:
             print "It has to be a number"
     return True
 def list_proyectos(self, limit = setup_options.getLimit(), page = 1):
     print "======= Listing al projects ======="
     print "===========In case you want to delete a project press d plus the number =========================="
     quantity_proyectos = self.proyectos_db.retrieveAllCount()
     number = 1
     while number != 0:
         proyectos = self.proyectos_db.selectAll(limit, page)
         for proyecto in proyectos:
             print "{0}: {1}".format(proyecto.id, proyecto.nombre)
         
         if page > 1:
             print "To go to the previous page press < "
         
         if (page * limit) < quantity_proyectos:
             print "To go to the next page press > "
             
         option = raw_input("Select the number to edit or 0 to come back\n")
         try:
             if option == "<":
                 self.list_proyectos(limit, page - 1)
                 number = 0
             elif option == ">":
                 self.list_proyectos(limit, page + 1)
                 number = 0
             else:
                 number = int(option)
                 if number != 0:
                     self.proyecto_options(number)
                     
         except ValueError:
             print "It has to be a number"
 def list_tables(self, limit = setup_options.getLimit(), page = 1):
     print "============= Listing tables =================="
     quantity_tables = self.tablas_db.retrieveAllCount(self.element_id)
     number = 1
     while number != 0:
         tablas = self.tablas_db.selectAll(self.element_id, limit, page)
         for tabla in tablas:
             print "{0}: {1}".format(tabla.id, tabla)
         
         if page > 1:
             print "To go to the previous page press < "
         
         if (page * limit) < quantity_tables:
             print "To go to the next page press > "
             
         option = raw_input("Select the number to edit or 0 to come back\n")
         try:
             if option == "<":
                 self.list_tables(limit, page - 1)
                 number = 0
             elif option == ">":
                 self.list_tables(limit, page + 1)
                 number = 0
             else:
                 number = int(option)
                 if number != 0:
                     self.edit_table(number)
                     
         except ValueError:
             print "It has to be a number"        
     
     return True
    def list_tables(self, limit=setup_options.getLimit(), page=1):
        print "============= Listing tables =================="
        quantity_tables = self.tablas_db.retrieveAllCount(self.element_id)
        number = 1
        while number != 0:
            tablas = self.tablas_db.selectAll(self.element_id, limit, page)
            for tabla in tablas:
                print "{0}: {1}".format(tabla.id, tabla)

            if page > 1:
                print "To go to the previous page press < "

            if (page * limit) < quantity_tables:
                print "To go to the next page press > "

            option = raw_input("Select the number to edit or 0 to come back\n")
            try:
                if option == "<":
                    self.list_tables(limit, page - 1)
                    number = 0
                elif option == ">":
                    self.list_tables(limit, page + 1)
                    number = 0
                else:
                    number = int(option)
                    if number != 0:
                        self.edit_table(number)

            except ValueError:
                print "It has to be a number"

        return True
    def list_connection(self, limit=setup_options.getLimit(), page=1):
        print "======= Listing conectors ======="
        print "===========In case you want to delete a project press d plus the number =========================="
        quantity_connectors = self.conector_db.retrieveAllCount(
            self.element_id)
        number = 1
        while number != 0:
            conectores = self.conector_db.selectAll(self.element_id, limit,
                                                    page)
            for conector in conectores:
                print "{0}: {1}".format(conector.id, conector)

            if page > 1:
                print "To go to the previous page press < "

            if (page * limit) < quantity_connectors:
                print "To go to the next page press > "

            option = raw_input("Select the number to edit or 0 to come back\n")
            try:
                if option == "<":
                    self.list_connection(limit, page - 1)
                    number = 0
                elif option == ">":
                    self.list_connection(limit, page + 1)
                    number = 0
                else:
                    number = int(option)
                    if number != 0:
                        self.edit_conector(number)

            except ValueError:
                print "It has to be a number"
        return True
    def list_proyectos(self, limit=setup_options.getLimit(), page=1):
        print "======= Listing al projects ======="
        print "===========In case you want to delete a project press d plus the number =========================="
        quantity_proyectos = self.proyectos_db.retrieveAllCount()
        number = 1
        while number != 0:
            proyectos = self.proyectos_db.selectAll(limit, page)
            for proyecto in proyectos:
                print "{0}: {1}".format(proyecto.id, proyecto.nombre)

            if page > 1:
                print "To go to the previous page press < "

            if (page * limit) < quantity_proyectos:
                print "To go to the next page press > "

            option = raw_input("Select the number to edit or 0 to come back\n")
            try:
                if option == "<":
                    self.list_proyectos(limit, page - 1)
                    number = 0
                elif option == ">":
                    self.list_proyectos(limit, page + 1)
                    number = 0
                else:
                    number = int(option)
                    if number != 0:
                        self.proyecto_options(number)

            except ValueError:
                print "It has to be a number"
    def init_agenda(self):
        main_menu_text = {1 : 'Create new', 2: 'List', 3 : 'Exit'}
        main_menu_options = {1 : self.create_contact, 2: self.list_contacts, 3 : self.close_program}

        options = { 'main' : { 'text' : main_menu_text, 'options' : main_menu_options}}
        start_point = 'main'

        selected = start_point
        print "========== Welcome to contact 1.0.1 ================"

        while True:
            print "========== Main menu ================"
            displayed = options[selected]['text']
            sel_options = options[selected]['options']
        
            for k, v in displayed.iteritems():
                print " {0} - {1}".format(k, v)
            
            selection = raw_input("[Selection] >") 
            selection_int = 0
            try:
                #print selection
                selection_int = int(selection)
                function = sel_options[selection_int]
                if selection == 2 or selection == "2":
                    function(setup_options.getLimit() , 1)
                else:
                    function()
            except ValueError:
                print "It has to be a number"
Esempio n. 8
0
    def init_agenda(self):
        main_menu_text = {1: 'Create new', 2: 'List', 3: 'Exit'}
        main_menu_options = {
            1: self.create_contact,
            2: self.list_contacts,
            3: self.close_program
        }

        options = {
            'main': {
                'text': main_menu_text,
                'options': main_menu_options
            }
        }
        start_point = 'main'

        selected = start_point
        print "========== Welcome to contact 1.0.1 ================"

        while True:
            print "========== Main menu ================"
            displayed = options[selected]['text']
            sel_options = options[selected]['options']

            for k, v in displayed.iteritems():
                print " {0} - {1}".format(k, v)

            selection = raw_input("[Selection] >")
            selection_int = 0
            try:
                #print selection
                selection_int = int(selection)
                function = sel_options[selection_int]
                if selection == 2 or selection == "2":
                    function(setup_options.getLimit(), 1)
                else:
                    function()
            except ValueError:
                print "It has to be a number"
 def __init__(self):
     super(AgendaWindow, self).__init__()
     
     self.set_title("Agenda")
     self.set_size_request(500, 400)
     self.set_position(gtk.WIN_POS_CENTER)
     
     self.connect("destroy", gtk.main_quit)
     
     # Database parameters
     self.page_limit = setup_options.getLimit()
     self.current_page = 1
     self.items_quantity = 0
     self.db = BasicDb()
     
     #Contact id
     self.contact_id = 0
     
     # Menu bar
     mb = gtk.MenuBar()
     
     filemenu = gtk.Menu()
     filem = gtk.MenuItem("_File")
     filem.set_submenu(filemenu)
     
     agr = gtk.AccelGroup()
     self.add_accel_group(agr)
     
     newi = gtk.ImageMenuItem(gtk.STOCK_NEW, agr)
     key, mod = gtk.accelerator_parse("<Control>N")
     newi.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
     filemenu.append(newi)
     
     sep = gtk.SeparatorMenuItem()
     filemenu.append(sep)
     
     exit = gtk.ImageMenuItem(gtk.STOCK_QUIT, agr)
     key, mod = gtk.accelerator_parse("<Control>Q")
     exit.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
     
     exit.connect("activate", gtk.main_quit)
     newi.connect("activate", self.add_contact)
     
     filemenu.append(exit)
     
     mb.append(filem)
     
     
     sw = gtk.ScrolledWindow()
     sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
     sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     
     toolbar = gtk.Toolbar()
     
     toolbar.set_style(gtk.TOOLBAR_ICONS)
     
     newtb = gtk.ToolButton(gtk.STOCK_NEW)
     self.back = gtk.ToolButton(gtk.STOCK_GO_BACK)
     self.back.set_sensitive(False)
     self.next = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
     self.next.set_sensitive(False)
     
     sep = gtk.SeparatorToolItem()
     quittb = gtk.ToolButton(gtk.STOCK_QUIT)
     
     toolbar.insert(newtb, 0)
     toolbar.insert(self.back, 1)
     toolbar.insert(self.next, 2)
     toolbar.insert(sep, 3)
     toolbar.insert(quittb, 4)
     
     newtb.connect("clicked", self.add_contact)
     quittb.connect("clicked", gtk.main_quit)
     self.back.connect("clicked", self.previous_page)
     self.next.connect("clicked", self.next_page)
     
     vbox = gtk.VBox(False, 3)
     
     vbox.pack_start(mb, False, False, 0)
     vbox.pack_start(toolbar, False, False, 0)
     vbox.pack_start(sw, True, True, 0)
     
     self.store = self.create_model()
     
     
     
     self.treeView = gtk.TreeView(self.store)
     self.treeView.connect("row-activated", self.on_activated)
     self.treeView.set_rules_hint(True)
     
     self.populate_model()
     
     self.selected = self.treeView.get_selection()
     self.selected.connect("changed", self.on_changed)
     
     sw.add(self.treeView)
     
     self.create_columns(self.treeView)
     
     
     self.enable_next_previous()
     
     hbox = gtk.HBox(True, 3)
     self.edit = gtk.Button("Edit")
     self.edit.set_size_request(70,30)
     self.edit.set_sensitive(False)
     self.edit.connect("clicked", self.edit_contact)
     self.label = gtk.Label(" - ")
     
     self.delete = gtk.Button("Delete")
     self.delete.set_size_request(70,30)
     self.delete.set_sensitive(False)
     self.delete.connect("clicked", self.delete_contact)
     
     hbox.add(self.label)
     hbox.add(self.edit)
     hbox.add(self.delete)
     
     halign = gtk.Alignment(1, 0, 0, 0)
     halign.add(hbox)
     vbox.pack_start(halign, False, False, 3)
     
     self.add(vbox)
     
     self.show_all()
    def __init__(self):
        super(AgendaWindow, self).__init__()

        self.set_title("Agenda")
        self.set_size_request(500, 400)
        self.set_position(gtk.WIN_POS_CENTER)

        self.connect("destroy", gtk.main_quit)

        # Database parameters
        self.page_limit = setup_options.getLimit()
        self.current_page = 1
        self.items_quantity = 0
        self.db = BasicDb()

        #Contact id
        self.contact_id = 0

        # Menu bar
        mb = gtk.MenuBar()

        filemenu = gtk.Menu()
        filem = gtk.MenuItem("_File")
        filem.set_submenu(filemenu)

        agr = gtk.AccelGroup()
        self.add_accel_group(agr)

        newi = gtk.ImageMenuItem(gtk.STOCK_NEW, agr)
        key, mod = gtk.accelerator_parse("<Control>N")
        newi.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
        filemenu.append(newi)

        sep = gtk.SeparatorMenuItem()
        filemenu.append(sep)

        exit = gtk.ImageMenuItem(gtk.STOCK_QUIT, agr)
        key, mod = gtk.accelerator_parse("<Control>Q")
        exit.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)

        exit.connect("activate", gtk.main_quit)
        newi.connect("activate", self.add_contact)

        filemenu.append(exit)

        mb.append(filem)

        sw = gtk.ScrolledWindow()
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        toolbar = gtk.Toolbar()

        toolbar.set_style(gtk.TOOLBAR_ICONS)

        newtb = gtk.ToolButton(gtk.STOCK_NEW)
        self.back = gtk.ToolButton(gtk.STOCK_GO_BACK)
        self.back.set_sensitive(False)
        self.next = gtk.ToolButton(gtk.STOCK_GO_FORWARD)
        self.next.set_sensitive(False)

        sep = gtk.SeparatorToolItem()
        quittb = gtk.ToolButton(gtk.STOCK_QUIT)

        toolbar.insert(newtb, 0)
        toolbar.insert(self.back, 1)
        toolbar.insert(self.next, 2)
        toolbar.insert(sep, 3)
        toolbar.insert(quittb, 4)

        newtb.connect("clicked", self.add_contact)
        quittb.connect("clicked", gtk.main_quit)
        self.back.connect("clicked", self.previous_page)
        self.next.connect("clicked", self.next_page)

        vbox = gtk.VBox(False, 3)

        vbox.pack_start(mb, False, False, 0)
        vbox.pack_start(toolbar, False, False, 0)
        vbox.pack_start(sw, True, True, 0)

        self.store = self.create_model()

        self.treeView = gtk.TreeView(self.store)
        self.treeView.connect("row-activated", self.on_activated)
        self.treeView.set_rules_hint(True)

        self.populate_model()

        self.selected = self.treeView.get_selection()
        self.selected.connect("changed", self.on_changed)

        sw.add(self.treeView)

        self.create_columns(self.treeView)

        self.enable_next_previous()

        hbox = gtk.HBox(True, 3)
        self.edit = gtk.Button("Edit")
        self.edit.set_size_request(70, 30)
        self.edit.set_sensitive(False)
        self.edit.connect("clicked", self.edit_contact)
        self.label = gtk.Label(" - ")

        self.delete = gtk.Button("Delete")
        self.delete.set_size_request(70, 30)
        self.delete.set_sensitive(False)
        self.delete.connect("clicked", self.delete_contact)

        hbox.add(self.label)
        hbox.add(self.edit)
        hbox.add(self.delete)

        halign = gtk.Alignment(1, 0, 0, 0)
        halign.add(hbox)
        vbox.pack_start(halign, False, False, 3)

        self.add(vbox)

        self.show_all()