'The simple condition starts only inside a function called from a button. It doesn't work without function and button, how do I fix it?
If I try to execute the condition automatically when you click on the combobox item X, the condition does not start and does not print anything. Whereas if you insert the condition into a function and invoke it with a button, then it starts correctly.
I would like to start the condition directly, automatically, by simply clicking on the item X of the combobox.
I DON'T WANT TO USE FUNCTIONS OR BUTTONS OR ('<<ComboboxSelected>>', func). Because it does not work? How can I solve? Thank you
from tkinter import ttk
import tkinter as tk
from tkinter import *
from tkinter import ttk
import tkinter as tk
root = tk.Tk()
root.geometry('350x250')
root.config(bg="white")
root.state("normal")
combobox1=ttk.Combobox(root, width = 21)
combobox1.place(x=10, y=10)
combobox1.set("Click")
combobox1['value'] = ["X", "Y"]
if combobox1.get() == "X":
print("test")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
