Hallo,
ich verzichte auf das Bash-Zeug.
Es ist mir weder mit den C system() Befehl noch mit "diversen" exec -Befehlen gelungen.
Und das Rumgewurstel mit Umgebungsvariablen ist mir dann doch zu blöd.
Mit den PureBasic internen Consolenbefehlen kann man schon eine ganze Menge machen, aber ich werde mal auf curses(ncurses) umswitchen.
Damit geht an bestimmten Stellen deutlich mehr.
Anbei:
Die "newt"-Bibliothek ist zwar sehr genial, aber ist mir dann doch viel zu komplex.
Außerdem benötigt diese Lib den slang - Interpreter.
Im Quelltext-Verzeichnis von "newt" befindet sich außerdem im übrigen der "Quältext" von "whiptail".
____
Aber eigentlich müsste es trotzdem gehen die Ausgabe von "whiptail" zu erlangen.
Mit Python geht es ja auch. (pip3 install whiptail | pip3 install whiptail-dialogs)
Mit PureBasic und der
internen Benutzung von Python geht es somit auch.
Also müsste es mit popen oder RunProgram eigentlich auch gehen.
Im Python-Script steht folgendes:
#Python3-Code:
Code: Alles auswählen
def run(
self,
control: str,
msg: str,
extra_args: Sequence[str] = (),
extra_values: Sequence[str] = (),
exit_on: Sequence[int] = (1, 255)
) -> Response:
"""
:param control: The name of the control to run. One of ``"yesno"``, ``"msgbox"``, ``"infobox"``,
``"inputbox"``, ``"passwordbox"``, ``"textbox"``, ``"menu"``, ``"checklist"``,
``"radiolist"`` or ``"gauge"``
:type control: str
:param msg: The message to display in the dialog box
:type msg: str
:param extra_args: A sequence of extra arguments to pass to the control
:param extra_values: A sequence of extra values to pass to the control
:param exit_on: A sequence of return codes that will cause program execution to stop if
:attr:`Whiptail.auto_exit` is :py:obj:`True`
:return: The response returned by whiptail
"""
width = self.width
height = self.height
if self.height is None or self.width is None:
w, h = get_terminal_size()
if self.width is None:
width = w - 10
width = width - (width % 10)
if self.height is None:
height = h - 2
height = height - (height % 5)
cmd = [
'whiptail',
'--title',
self.title,
'--backtitle',
self.backtitle,
*list(extra_args),
f'--{control}',
"--",
str(msg),
str(height),
str(width),
*list(extra_values),
]
p = Popen(cmd, stderr=PIPE)
out, err = p.communicate()
if self.auto_exit and p.returncode in exit_on:
print('User cancelled operation.')
sys.exit(p.returncode)
return Response(p.returncode, err)
Betriebssysteme: div. Windows, Linux, Unix - Systeme
no Keyboard, press any key
no mouse, you need a cat