Hi,

I am working on a GUI (more correctly, trying to), but I just don't really get it to work the way I want.

The idea is to have a first list, where the user chooses one of the choices. Then depending on that choice, a new window pops out and the user enters the values that will be used further on in the code.
Ideally, when the user clicks enter, a graph and a image pop out (we coded the euler function that draws the graph). The euler function depends on the choice the user made.

I hope I was clear.

Thanks so much for any help,

Doule

from tkinter import *

class GUI:

    def __init__(self):
        self.root= Tk()
        self.labelVariable = StringVar()
        self.root.title('Projet informatique')
        self.initialize()
        self.root.mainloop()

    def initialize(self):
        self.main = Frame(self.root)
        self.main.pack() 

        label = Label(self.main, textvariable=self.labelVariable, font=('courier',10,'bold'), anchor="w", fg="red", bg="white")
        label.grid(column=0,row=1,columnspan=2,sticky='EW')
        self.labelVariable.set(u"Modélisation de populations atteintes d'un virus")

        v=tkinter.Listbox(self.main)
        v.insert("end","Modèle SIR")
        v.insert("end", "Modèle de Witowski")
        v.insert("end", "Modèle de Munz")
        v.insert("end", "Modèle avec infection latente")
        v.insert("end", "Modèle avec traitement")
        v.bind("<Double-Button-1>", self.Double)
        v.grid(row=2,column=0)

        self.grid_columnconfigure(0,weight=1)

    def Double(self, event):
        widget = event.widget
        selection=widget.curselection()
        value = widget.get(selection[0])
        self.newWindow(value)

if __name__ == "__main__":
    app = simpleapp_tk(None)
    app.title('Projet informatique')
    #on boucle sans fin en attente d'évenements
    app.mainloop()

Here is a modified version which works (with python3) up to the point where the newWindow() method is called. You must add the code for the popup window and subsequent behavior

#-*-coding: utf8-*-
from tkinter import *
import tkinter

class GUI:

    def __init__(self):
        self.root= Tk()
        self.labelVariable = StringVar()
        self.root.title('Projet informatique')
        self.initialize()
        self.root.mainloop()

    def initialize(self):
        self.main = Frame(self.root)
        self.main.pack() 

        label = Label(self.main, textvariable=self.labelVariable, font=('courier',10,'bold'), anchor="w", fg="red", bg="white")
        label.grid(column=0,row=1,columnspan=2,sticky='EW')
        self.labelVariable.set(u"Modélisation de populations atteintes d'un virus")

        v=tkinter.Listbox(self.main)
        v.insert("end","Modèle SIR")
        v.insert("end", "Modèle de Witowski")
        v.insert("end", "Modèle de Munz")
        v.insert("end", "Modèle avec infection latente")
        v.insert("end", "Modèle avec traitement")
        v.bind("<Double-Button-1>", self.Double)
        v.grid(row=2,column=0)

        self.root.grid_columnconfigure(0,weight=1)

    def Double(self, event):
        widget = event.widget
        selection=widget.curselection()
        value = widget.get(selection[0])
        self.newWindow(value)

if __name__ == "__main__":
    app = GUI()
    app.title('Projet informatique')
    #on boucle sans fin en attente d'évenements
    app.mainloop()
This question has already been answered. Start a new discussion instead.