Rellenar ComboBox desde MYSQL.
Publicado por Jamyz (11 intervenciones) el 01/05/2019 10:52:09
Hola buenas,
Queria tener un ejemplo de como rellenar un combobox desde mysql.
Intente lo siguiente pero no me sale correctamente el resultado.
Gracias
Queria tener un ejemplo de como rellenar un combobox desde mysql.
Intente lo siguiente pero no me sale correctamente el resultado.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from tkinter import *from tkinter import ttk
import sqlite3
import tkinter as tk
from tkinter import messagebox
import os
import configparser
import tkinter
from PIL import Image, ImageTkfrom tkinter import filedialog
from PIL import ImageTk, Imageimport tkinter
import mysql.connectorfrom mysql.connector import ErrorProduct = Tk()
Product.title ('App - Add Product')
Product.iconbitmap(r'./local/pics/App.ico')
Product.geometry("1000x800")
def combo_input():
db = mysql.connector.connect(host='localhost',
database='test',
user='test',
password='test')
cursor = db.execute('select nombre from test')
result = []
for row in cursor.fetchall():
result.append(row[0])
return result
combo_list = ttk.Combobox(Product)
combo_list['value'] = combo_input()
combo_list.pack()
Gracias
Valora esta pregunta


0
