>>> from tkinter import *
>>> import os
>>>
>>>
>>> def stop():
... os.execl("gksudo,apachectl,stop")
...
>>>
...
>>> # Création de la fenêtre principale (main window)
... Mafenetre = Tk()
>>>
>>> Mafenetre.title('apache')
''
>>> Mafenetre.geometry('300x100+400+400')
''
>>>
>>> # Création d'un widget Button (bouton stop)
... Boutonstop = Button(Mafenetre, text ='Lancer', command = stop)
>>> # Positionnement du widget avec la méthode pack()
... Boutonstop.pack(side = LEFT, padx = 5, pady = 5)
>>>
>>> # Création d'un widget Button (bouton Quitter)
... BoutonQuitter = Button(Mafenetre, text ='Quitter', command = Mafenetre.destroy)
>>> BoutonQuitter.pack(side = LEFT, padx = 5, pady = 5)
>>>
>>> Texte = StringVar()
>>> top()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'top' is not defined
>>>
>>>
>>> LabelResultat = Label(Mafenetre, textvariable = Texte, fg ='red', bg ='white')
>>> LabelResultat.pack(side = LEFT, padx = 5, pady = 5)
>>>
>>> Mafenetre.mainloop()Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 1490, in __call__
return self.func(*args)
File "<stdin>", line 2, in stop
File "/usr/lib/python3.4/os.py", line 489, in execl
execv(file, args)
ValueError: execv() arg 2 must not be empty
Partager