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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #coding=utf-8
from tkinter import *
from tkinter.filedialog import *
from tkinter import ttk
window = Tk()
window.title("Alert app v1")
window.geometry("720x550")
window.minsize(480, 360)
window.config(background='#41B77F')
# initialization des composants
frame = Frame(window, bg='#41B77F')
# creation des composants
liste_product = []
def select_collection():
global choix_collection
choix_collection = liste_combo_collection.get()
print(choix_collection)
if choix_collection == 'truc':
print("ok")
liste_product = ["toto","is","here"]
def collection():
label_collection = Label(window, text="Collection",bg='#41B77F',
fg='white')
label_collection.pack(pady=10)
liste_collection = ["truc", "machin", "chose", "bidule"]
global liste_combo_collection
liste_combo_collection = ttk.Combobox(window, values=liste_collection,state="readonly")
liste_combo_collection.bind('<<ComboboxSelected>>', lambda e : select_collection())
liste_combo_collection.pack()
def select_product():
global choix_product
choix_product = liste_combo_product.get()
def product_type(liste_product):
label_product = Label(window, text="Product",bg='#41B77F',
fg='white')
label_product.pack(pady=10)
global liste_combo_product
liste_combo_product = ttk.Combobox(window, values=liste_product,state="readonly")
liste_combo_product.bind('<<ComboboxSelected>>', lambda e: select_product())
liste_combo_product.pack()
def create_widgets():
collection()
product_type(liste_product)
create_widgets()
# empaquetage
frame.pack(expand=YES)
# afficher
window.mainloop() |
Partager