Bonjour,
je cherche a faire une petite application avec GUI pour choisir les traitements grâce aux boutons mais en passant par le Shell pour répondre aux questions demandées par le traitement.Le problème c'est que souvent le cadre Shell reste a l’arrière plan.Comment remédier a cela ?
Je sais bien quelle est l'instance de ma fenêtre tk (self.Parent dans mon exemple), mais je n'ai aucune idée de mon instance Shell python (pour interagir avec je dois bien connaitre son nom ?). Je laisse mon bout de code en exemple.
import tkinter as tk import os #---------------------------------------- class monapp: """doc""" def __init__(self, parent): """doc""" self.Parent = parent self.Parent.configure(width = 10, height = 45) # ------------- def Add2Chiffres(): self.Parent.wm_withdraw() print("\nAdditionne deux nombres") Entree1 = (input("\nEntrez un nombre : ")).lower() Entree2 = (input("\nEntrez un nombre : ")).lower() print("\nla somme des deux nombres est : " + str(int(Entree1) + int(Entree2))) self.Parent.wm_deiconify() # ------------- def Concat2Chaines(): self.Parent.wm_withdraw() print("\nConcatene deux chaines") Entree1 = (input("\n1ere Chaine ? : ")).lower() Entree2 = (input("\n2eme Chaine ? : ")).lower() print("\nle resultat de la concatenation est : " + Entree1 + Entree2) self.Parent.wm_deiconify() # ----------------------------------------------------------------------------- self.Parent.wm_geometry("%dx%d+%d+%d" % (514, 445, 5, 5)) self.Parent.focus_force() # ----------------------------------------------------------------------------- FrameInitiale1 = tk.Frame(self.Parent, width = 150, height = 440, bd = 3, bg = "DeepSkyBlue1", relief = tk.SUNKEN) FrameInitiale1.grid(column = 0, row = 0, columnspan = 2, sticky = tk.W + tk.N) # ----------------------------------------------------------------------------- PetitBouton1 = tk.Button(FrameInitiale1, text="monBn1\nAdditionne", width=10 , height=2, bg = 'yellow', bd = 6, relief = tk.RAISED,command = Add2Chiffres, cursor='hand2',font='courier') PetitBouton1.pack(fill = 'both', expand = 1, side = 'left') # ------------- PetitBouton2 = tk.Button(FrameInitiale1, text="monBn2\nConcatene", width=10 , height=2, bg = 'pink', bd = 6, relief = tk.RAISED,command = Concat2Chaines, cursor='hand2',font='courier') PetitBouton2.pack(fill = 'both', expand = 1, side = 'left') # ---------------------- if __name__=='__main__': root = tk.Tk() app = monapp(root) root.mainloop() root.quit() # ----------------------
Afficher la suite