def __init__(self): self.db = DBAccess() self.botonera = self.db.table_botonera() self.pages_botonera = self.db.table_pages_botonera() self.sort_pages_botonera = self.db.ordenar(self.pages_botonera, 'id_page') self.articulos = self.db.table_articles() self.widget = gtk.glade.XML('pytpv.glade', 'winBotonera') self.winbotonera = self.widget.get_widget('winBotonera') self.winbotonera.set_title('Configurar Botonera') self.winbotonera.set_icon_from_file('images' + os.sep + 'yinyang.png') vbox = self.widget.get_widget('vbox13') self.winbotonera.show() self.widget.signal_autoconnect(self) self.notebook = gtk.Notebook() data_botonera = [] for item in self.botonera: data_botonera.append(item) data_articulos = [] for item in self.articulos: data_articulos.append(item) vbox.pack_start(self.notebook) a = 0 c = 0 r = 0 aopt = gtk.FILL|gtk.SHRINK for page in self.sort_pages_botonera: label = gtk.Label(page[1]) label.set_padding(15, 15) self.table = gtk.Table(6, 6) self.notebook.append_page(self.table, label) for x in range(36): button = MakeButton(data_botonera[a][5]) print "button %s" % a # button.set_data("id", (a+1)) button.set_data("id", data_botonera[a][0]) button.connect("clicked", self.clicked, button.get_data("id")) button.set_size_request(100, 100) # if button.get_label() is None: # button.set_sensitive(False) self.notebook.get_nth_page(page[2]).attach(button, c, \ c+1, r, \ r+1, aopt, aopt, 0, 0) a += 1 c += 1 if c == 6: c = 0 r += 1 if r == 6: r = 0 self.winbotonera.show_all()
def on_btnAddPageNotebook_clicked(self, widget, args=[]): self.widget = gtk.glade.XML('pytpv.glade', 'dlgAddPage') self.dlgaddpage = self.widget.get_widget('dlgAddPage') self.dlgaddpage.set_title('Nueva Pestaña') self.dlgaddpage.set_icon_from_file('images'+ os.sep +'yinyang.png') self.entrys = ['entNamePageNotebook'] resultado = self.dlgaddpage.run() self.dlgaddpage.hide() if resultado == -3: table = MakeTable(6, 6) table.show_all() c = 0 r = 0 for entry in self.entrys: label = gtk.Label(self.widget.get_widget(entry).get_text()) label.set_padding(0, 15) self.notebook.append_page(table, label) aopt = gtk.FILL|gtk.SHRINK for x in range(36): label2 = "r=%s,c=%d" % (r, c) button = MakeButton(label2) button.connect("clicked", self.clicked) button.set_data("row", (r)) button.set_data("col", (c)) button.set_size_request(100, 100) button.show() self.notebook.get_nth_page(0).attach(button, c, c+1, r, \ r+1, aopt, aopt, 0, 0) c += 1 if c == 6: c = 0 r += 1 if r == 6: r = 0 linea = self.pages_botonera.max_value('id_page', 'pages_botonera') linea += 1 self.db.insert(self.botonera, None, linea, r, c, None, None) pages = self.notebook.get_n_pages() - 1 print pages self.db.insert(self.pages_botonera, None, \ self.widget.get_widget(entry).get_text(), linea) self.winbotonera.show_all()
def __init__(self): # We create the notebook for store buttons called botonera self.notebook = gtk.Notebook() self.db = DBAccess() self.botonera = self.db.table_botonera() self.pages_botonera = self.db.table_pages_botonera() self.sort_pages_botonera = self.db.ordenar(self.pages_botonera, 'id_page') self.ticketlinea = self.db.table_ticketlinea() self.articulos = self.db.table_articles() data_botonera = [] for item in self.botonera: data_botonera.append(item) data_articulos = [] for item in self.articulos: data_articulos.append(item) a = 0 c = 0 r = 0 aopt = gtk.FILL|gtk.SHRINK # Add the pages and buttons to notebook for page in self.sort_pages_botonera: label = gtk.Label(page[1]) label.set_padding(15, 15) self.table = gtk.Table(6, 6) self.notebook.append_page(self.table, label) for x in range(36): button = MakeButton(data_botonera[a][5]) print "button %s" % a #button.set_data("id", (a+1)) button.set_data("id", data_botonera[a][0]) button.connect("clicked", self.clicked, button.get_data("id")) button.set_focus_on_click(False) button.set_size_request(100, 100) if button.get_label() is None: button.set_sensitive(False) self.notebook.get_nth_page(page[2]).attach(button, c, \ c+1, r, \ r+1, aopt, aopt, 0, 0) a += 1 c += 1 if c == 6: c = 0 r += 1 if r == 6: r = 0 self.widget = gtk.glade.XML('pytpv.glade') window = self.widget.get_widget('mainwindow') window.set_title(app + " " + version) window.set_icon_from_file('images'+ os.sep +'yinyang.png') self.clientesview = ClientesView(self) self.ticketview = TicketView(self) self.ticketview.set_size_request(500, 309) self.ticketview.connect('cursor-changed', self.on_TicketView_Cursor_Changed) self.ticketlineaview = TicketLineaView(self) self.ticketlineaview.set_size_request(300, -1) self.articlesview = ArticulosView(self) self.creditoview = CreditoView(self) self.historicoview = HistoricoView(self) self.scrolledticket = self.widget.get_widget('scrolledTicket') self.scrolledticketlinea = self.widget.get_widget('scrolledTicketLinea') self.scrolledarticles = self.widget.get_widget('scrolledArticles') self.scrolledclients = self.widget.get_widget('scrolledClients') self.scrolledhistory = self.widget.get_widget('scrolledHistory') self.scrolledcredit = self.widget.get_widget('scrolledCredit') self.scrolledticket.add(self.ticketview) self.scrolledticketlinea.add(self.ticketlineaview) self.scrolledarticles.add(self.articlesview) self.scrolledclients.add(self.clientesview) self.scrolledhistory.add(self.historicoview) self.scrolledcredit.add(self.creditoview) hbox = self.widget.get_widget('hbox1') self.buttonbox = self.notebook #self.buttonbox = Buttons() hbox.pack_start(self.buttonbox, False, False) window.show_all() self.db = DBAccess() self.clients = DBAccess().table_clients() self.dbclients = DBAccess().select(self.clients) #print self.dbclients if self.dbclients: for row in self.dbclients: self.clientesview.add(row) self.articles = DBAccess().table_articles() self.dbarticles = DBAccess().select(self.articles) self.family = self.db.table_family() if self.dbarticles: for row in self.dbarticles: print "%-5s %-5s %-5s" % (row[:-4]) familyname = self.family.busqueda('familia', 'id=%s' % (row[1])) #print familyname[1] datos = row[0], familyname[1], row[2], ("%0.2f" %row[3]), \ ("%0.2f" %row[4]), ("%0.2f" %row[5]), row[6] self.articlesview.add(datos) self.currentdate = self.db.date(self.clients) self.ticket = DBAccess().table_tickets() self.tickets = self.ticket.search('ticket', "fecha=\"%s\"" % self.currentdate) if self.tickets: for row in self.tickets: client = self.clients.busqueda('clientes', 'id=%s' % (row[1])) if row[6]: credito = gtk.STOCK_ADD else: credito = None if row[7]: servicio = gtk.STOCK_DIALOG_WARNING else: servicio = None if row[8]: comanda = gtk.STOCK_APPLY else: comanda = None structured_row = [row[0], credito, servicio, comanda, client[1], \ client[2], None, row[3]] print structured_row self.ticketview.add(structured_row) self.widget.signal_autoconnect(self)