def begin(self): pygame.init() screen = pygame.display.set_mode((740, 480)) black = (0, 0, 0) image = pygame.image.load("images/image4.jpg") myfont = pygame.font.SysFont("comicsansms", 20) quantity = myfont.render("quantity", 4, black) p_name = myfont.render("Product_name", 4, black) price = myfont.render("Price", 4, black) des = myfont.render("Description", 4, black) loop = True while loop: a = mysqltest.fetching_data() stocks = a.check() screen.blit(image, (0, 0)) screen.blit(p_name, (25, 15)) screen.blit(price, (230, 15)) screen.blit(des, (350, 15)) screen.blit(quantity, (560, 15)) pygame.draw.line(screen, 0, [210, 0], [210, 400], 2) #pygame.draw.line(screen,0,[100,0],[100,400],2) pygame.draw.line(screen, 0, [320, 0], [320, 400], 2) pygame.draw.line(screen, 0, [540, 0], [540, 400], 2) pygame.draw.line(screen, 0, [700, 0], [700, 400], 2) pygame.draw.line(screen, 0, [10, 400], [700, 400], 2) pygame.draw.line(screen, 0, [10, 0], [700, 0], 2) pygame.draw.line(screen, 0, [10, 50], [700, 50], 2) pygame.draw.line(screen, 0, [10, 100], [700, 100], 2) pygame.draw.line(screen, 0, [10, 150], [700, 150], 2) pygame.draw.line(screen, 0, [10, 200], [700, 200], 2) pygame.draw.line(screen, 0, [10, 250], [700, 250], 2) pygame.draw.line(screen, 0, [10, 300], [700, 300], 2) pygame.draw.line(screen, 0, [10, 350], [700, 350], 2) Group = pygame.sprite.Group() s = Probe() Group.add(s) x = 0 for stock in stocks: a1 = myfont.render(str(stock[0]), 3, black) screen.blit(a1, (30, 70 + x)) a2 = myfont.render(str(stock[1]), 3, black) screen.blit(a2, (230, 70 + x)) a3 = myfont.render(str(stock[2]), 3, black) screen.blit(a3, (350, 70 + x)) a4 = myfont.render(str(stock[3]), 3, black) screen.blit(a4, (580, 70 + x)) x += 50 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: if s.rect.collidepoint(pygame.mouse.get_pos()): pygame.quit() exit(0) Group.draw(screen) pygame.display.flip() pygame.quit()
def delete(entries): save = [] for entry in entries: field = entry[0] text = entry[1].get() save.append(text) entry[1].delete(0, END) print field, text d = mysqltest.fetching_data() x = d.delete2(save[0]) if x == "no": tkMessageBox.showinfo("WARNING", "No entry to Delete") else: tkMessageBox.showinfo("Delete", "successful delete")
def insert(entries): save = [] for entry in entries: field = entry[0] text = entry[1].get() if text == "": tkMessageBox.showinfo("Insert", "Incomplete details entered") for entry in entries: entry[1].delete(0, END) return save.append(text) entry[1].delete(0, END) print field, text d = mysqltest.fetching_data() d.insert2(save) tkMessageBox.showinfo("Insert", "Inserted sucessfully")
def update(entries): save = [] for entry in entries: field = entry[0] text = entry[1].get() if text == "": tkMessageBox.showinfo( "Update", "Incomplete records entered to update") for entry in entries: entry[1].delete(0, END) return save.append(text) entry[1].delete(0, END) print field, text d = mysqltest.fetching_data() x = d.update(save) if x == "no": tkMessageBox.showinfo("WARNING", "Update error") else: tkMessageBox.showinfo("Update", "Update successful")
def search(entries): save = [] for entry in entries: field = entry[0] text = entry[1].get() save.append(text) entry[1].delete(0, END) print field, text if save[1] == "": tkMessageBox.showinfo("WARNING", "Enter P_name to search") return print save[1] d = mysqltest.fetching_data() x = d.search(save[1]) if x == "no": tkMessageBox.showinfo("Search", "Search failed") else: i = 0 for entry in entries: entry[1].insert(0, x[i]) i += 1 tkMessageBox.showinfo("Search", "Details found")
def begin(self): pygame.init() screen = pygame.display.set_mode((740, 480)) image = pygame.image.load("images/image4.jpg") image2 = pygame.image.load("done.png") image3 = pygame.image.load("b.png") black = (0, 0, 0) myfont = pygame.font.SysFont("comicsansms", 20) id = myfont.render("ID", 4, black) p_name = myfont.render("Product name", 4, black) price = myfont.render("Price", 4, black) des = myfont.render("Description", 4, black) while True: c = mysqltest.fetching_data() id1, pname1, price1, descrip = c.connect() screen.blit(image, (0, 0)) screen.blit(id, (35, 15)) screen.blit(p_name, (120, 15)) screen.blit(price, (320, 15)) screen.blit(des, (420, 15)) pygame.draw.line(screen, 0, [10, 0], [10, 400], 2) pygame.draw.line(screen, 0, [100, 0], [100, 400], 2) pygame.draw.line(screen, 0, [300, 0], [300, 400], 2) pygame.draw.line(screen, 0, [400, 0], [400, 400], 2) pygame.draw.line(screen, 0, [600, 0], [600, 400], 2) pygame.draw.line(screen, 0, [10, 400], [600, 400], 2) pygame.draw.line(screen, 0, [10, 0], [600, 0], 2) pygame.draw.line(screen, 0, [10, 50], [600, 50], 2) pygame.draw.line(screen, 0, [10, 100], [600, 100], 2) pygame.draw.line(screen, 0, [10, 150], [600, 150], 2) pygame.draw.line(screen, 0, [10, 200], [600, 200], 2) pygame.draw.line(screen, 0, [10, 250], [600, 250], 2) pygame.draw.line(screen, 0, [10, 300], [600, 300], 2) pygame.draw.line(screen, 0, [10, 350], [600, 350], 2) Group = pygame.sprite.Group() s = Probe(530, 420, image2) q = Probe(30, 400, image3) Group.add(s, q) x = 0 for i in range(0, len(id1)): a1 = myfont.render(str(id1[i]), 3, black) screen.blit(a1, (30, 70 + x)) a2 = myfont.render(str(pname1[i]), 3, black) screen.blit(a2, (130, 70 + x)) a3 = myfont.render(str(price1[i]), 3, black) screen.blit(a3, (320, 70 + x)) a4 = myfont.render(str(descrip[i]), 3, black) screen.blit(a4, (420, 70 + x)) x += 50 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: if s.rect.collidepoint(pygame.mouse.get_pos()): d = mysqltest.fetching_data() amount = d.delete() f = billno.bill() f.display(amount) elif q.rect.collidepoint(pygame.mouse.get_pos()): pygame.quit() exit(0) Group.draw(screen) pygame.display.flip()
port = random.randrange(1111, 5555) address = (ip, port) server.bind(address) server.listen(1) print "started listening on", ip, ":", port client, addr = server.accept() print "got a connection from", addr[0], ":", addr[1] while True: data = client.recv(1024) print "recieved", data, "from the client" print "processing data" if data[0:4] == 'cart': x = [] x = data[5:].split(' ') print x a2 = mysqltest.fetching_data() a2.insert(x) print "got back from rasberry pi" else: a = mysqltest.fetching_data() b, c, d, e = a.query_with_fetchone(data) b = str(b) c = str(c) d = str(d) e = str(e) ans = b + " " + c + " " + d + " " + e if data == b: client.send(ans) print "processing done and reply sent" elif data == "disconnect": client.send("goodbye")