Я хочу создать приложение, которое использует команды Bash, но каждый раз это приводит к исключению в обратном вызове Tkinter.
Я уже пытался использовать подпроцесс popen, но там он даже хотел запускать команды.
from tkinter import *
import os
# The following commands gets executed, if the user is pressing the action button
def button_action():
update_button.config(os.system('sudo -S pacman -Syu'), text="Aktualisiert!")
# create a window
fenster = Tk()
# set the title of the window
fenster.title("Befehlsammlung")
# create button and labels
update_label = Label(fenster, text="Drücke auf Aktualisieren, um alle Pakete zu updaten.",)
update_button = Button(fenster, text="Aktualisieren", command=button_action)
exit_button = Button(fenster, text="Schließen", command=fenster.quit)
# Add your components in your favourite
update_label.pack()
update_button.pack()
exit_button.pack()
# wait for input
fenster.mainloop()
I, за исключением кнопки, меняется на "Aktualisiert", а не на фактическую ошибку исключения.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.7/tkinter/__init__.py", line 106, in _cnfmerge
cnf.update(c)
TypeError: 'int' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
return self.func(*args)
File "/home/flozge/PycharmProjects/untitled1/GUI.py", line 7, in button_action
update_button.config(os.system('sudo -S pacman -Syu'), text="Aktualisiert!")
File "/usr/lib/python3.7/tkinter/__init__.py", line 1485, in configure
return self._configure('configure', cnf, kw)
File "/usr/lib/python3.7/tkinter/__init__.py", line 1469, in _configure
cnf = _cnfmerge((cnf, kw))
File "/usr/lib/python3.7/tkinter/__init__.py", line 109, in _cnfmerge
for k, v in c.items():
AttributeError: 'int' object has no attribute 'items'
Process finished with exit code 0