Python Forum
Help Using combobox in a select statement variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Using combobox in a select statement variable
#1
I'm creating a small App that will list values from a mysql database to a combobox. The user will select one of those values then click a button. This button will need to get the value selected from the combobox. It will then perform another select statement using the value in the combobox as a variable in the select statement and then execute a windows shell command.

I've got a sql select statement listing values in a tkinter combobox.

I'm having trouble with the combobox. Do I bind or get the value?
Reply
#2
Are you having trouble returning the combobox value?
Reply
#3
Essentially yes.

I'm not sure if I can assign the get to a variable and then have a button event to execute the command.

example: variable = "SELECT DB.ID from DB WHERE DB.NAME = "comboboxvalue"

install_command = subprocess.Popen("cmd.exe /c setup.exe variable")

button event button1 = Button(root, text="Install", command=install_command)

I hope that helps to see where I'm wanting to go with it. I still have a lot to work out syntax and logic wise I just wanted to get some help getting started.

from tkinter import *
from tkinter.ttk import *
import mysql.connector


root = Tk()
root.title('Software Installation')
root.geometry("400x400")

conn = mysql.connector.connect(host="x.x.x.x",
                               user="UN",
                               passwd="1234",
                               database="myDb")

c = conn.cursor()

query = "Select DB.NAME from DB Where DB.ENABLED = True"


c.execute(query)
rows=c.fetchall()
# Create Combobox
combo = Combobox(root,values=rows)
combo.pack()



button1 = Button(root, text="Install")
button1.pack()

root.mainloop()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] How can I sync Combobox index to other combobox index? nickzsche 2 2,333 Jan-03-2022, 12:29 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020