#https://codeloop.org/how-to-create-textbox-in-python-tkinter/ import tkinter as tk from tkinter import ttk import sys import os import sys if sys.platform == 'win32': print("pipe-test.py, running on windows") TONAME = '\\\\.\\pipe\\ToSrvPipe' FROMNAME = '\\\\.\\pipe\\FromSrvPipe' EOL = '\r\n\0' else: print("pipe-test.py, running on linux or mac") TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid()) FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid()) EOL = '\n' print("Write to \"" + TONAME +"\"") if not os.path.exists(TONAME): print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.") sys.exit() print("Read from \"" + FROMNAME +"\"") if not os.path.exists(FROMNAME): print(" ..does not exist. Ensure Audacity is running with mod-script-pipe.") sys.exit() print("-- Both pipes exist. This is a good thing.") TOFILE = open(TONAME, 'w') print("-- File to which to write has been opened") FROMFILE = open(FROMNAME, 'rt') print("-- File from which to read has now been opened also\r\n") def send_command(command): """Send a single command.""" print("Send: >>> \n"+command) TOFILE.write(command + EOL) TOFILE.flush() def get_response(): """Return the command response.""" result = '' line = '' while line != '\n': result += line line = FROMFILE.readline() #print(" I read line:["+line+"]") return result # ======================================================================= def AudacityController(): import tkinter as tk from tkinter import ttk import sys window = tk.Tk() global T T = 0 label = ttk.Label(window, text = "Enter the new code") label.grid(column = 2, row = 2, padx = 15, pady = 15) def StartRecord(): label.configure(text= 'Start Record') send_command("Record1stChoice") def AddLabel(): global T LabelInfo = "Test" print(" T = <" + str(T) + ">") send_command("AddLabel:") send_command("SetLabel:Label=%s Text='%s'"%(T,LabelInfo)) T += 1 button = ttk.Button(window, text = "Start Record", command = StartRecord) button.grid(column= 1, row = 10, pady = 5, padx = 5) button = ttk.Button(window, text = "Add Label", command = AddLabel) button.grid(column= 2, row = 10, pady = 5, padx = 5) window.mainloop() AudacityController()