hi guys!
why this code doesn't work as I want ?
I've tried several ways but it does the same,
it shows the scrolled bar widget at the end of the procedure
why this code doesn't work as I want ?
I've tried several ways but it does the same,
it shows the scrolled bar widget at the end of the procedure
from tkinter import * import tkinter as tk from tkinter import scrolledtext import os import keyboard import serial import time def on_closing(): pass def Ready(): keyboard.wait('y'or 'Y') ser4.open() ser4.write(b'\x00') ser4.write(b'\x00') ser4.close() def PS1_5(): ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +5.0 Vdc. \n")) ser9.write("VOLT00050\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_1=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_1)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to PS1 entering the console.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x03') ser4.write(b'\x03') ser4.close() test_area.yview(END) def PS1_15(): ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +15.0 Vdc. \n")) ser9.write("VOLT00150\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_2=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_2)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to PS1 entering the console.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x03') ser4.write(b'\x03') ser4.close() test_area.yview(END) def PS1_25(): ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +28.0 Vdc. \n")) ser9.write("VOLT00280\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_3=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_3)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to PS1 entering the console.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x03') ser4.write(b'\x03') ser4.close() test_area.yview(END) def PS1_OUT(): ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +28.0 Vdc. \n")) ser9.write("VOLT00100\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_3=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_3)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to ADAPTER.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x0B') ser4.write(b'\x0B') ser4.close() test_area.yview(END) def update_blue(): mylabel.configure(fg = "blue", text = "This is some blue text") mylabel.pack(pady = 5) def update_red(): mylabel.configure(fg = "red", text = "This is some red text") mylabel.pack(pady = 5) def leaving(): ser9.open() ser9.write("VOLT00000\r".encode()) ser9.write("SOUT000\r".encode()) ser9.write("SOUT001\r".encode()) ser9.close() #ser10.open() #ser10.write("VOLT00000\r".encode()) #ser10.write("SOUT000\r".encode()) #ser10.write("SOUT001\r".encode()) #ser10.close() ser4.open() ser4.write(b'\x00') ser4.close() root.destroy() #Instruments.devices() root = Tk() root.geometry('1000x950+450+70') root.title("AC/DC Power Supplies Verification Procedure") root.resizable(False, False) root.attributes('-topmost', 1) #always on top root.protocol("WM_DELETE_WINDOW", on_closing) root.focus_set() #Initializing and opening serial ports ser4=serial.Serial(port='COM4', baudrate=9600, timeout=1) ser9=serial.Serial(port='COM9', baudrate=9600, timeout=1) ser9.close() ser4.close() # Title Label tk.Label(root, text = "ScrolledText Widget Example", font = ("Arial", 15), background = 'lightgray', foreground = "white").grid(column = 0, row = 0) test_area = scrolledtext.ScrolledText(root, wrap = tk.WORD, width = 100, height = 20, font = ("Arial", 12)) test_area.grid(column = 0, pady = 10, padx = 10) Button(root, text='Close',font = ('Arial', 12, "bold"), command = leaving).grid(pady = 10, padx = 10) test_area.insert(tk.END,("======================================================================\n")) test_area.insert(tk.END,("P.N: BK Precision 1697 \n")) test_area.insert(tk.END,("AC/DC Power Supplies Verification Procedure \n")) test_area.insert(tk.END,("Verification Procedure Ver 1.0\n")) test_area.insert(tk.END,("======================================================================\n")) test_area.insert(tk.END,("DC Power Supply No.1 \n")) test_area.insert(tk.END,("COM9 will be open to get access to PS.1 and set voltages... \n")) test_area.insert(tk.END,("COM4 will be used to connect DMM to read voltages.\n")) mylabel = Label(root, text = "This is some black text") #test_area.after(0, PS1_5) #test_area.after(2000, Ready) #test_area.after(4000, PS1_15) #test_area.after(6000, Ready) #test_area.after(8000, PS1_25) #test_area.after(10000, Ready) #test_area.after(12000, PS1_OUT) #test_area.after(14000, Ready) #PS1_5 ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +5.0 Vdc. \n")) ser9.write("VOLT00050\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_1=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_1)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to PS1 entering the console.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x03') ser4.write(b'\x03') ser4.close() test_area.yview(END) #ready keyboard.wait('y'or 'Y') ser4.open() ser4.write(b'\x00') ser4.write(b'\x00') ser4.close() ser9.open() test_area.insert(tk.END,str("-- Going to Remote Mode. \n")) ser9.write("SESS01\r".encode()) ser9.write("SESS01\r".encode()) test_area.insert(tk.END,str("-- Setting up the voltage to +10.0 Vdc external. \n")) ser9.write("VOLT00100\r".encode()) test_area.insert(tk.END,str("-- Closing output switch. \n")) ser9.write("SOUT000\r".encode()) ser9.write("SOUT000\r".encode()) MEAS_3=ser9.write("GETD\r".encode()) # 500 ms delay for instrument read time.sleep(.5) test_area.insert(tk.END,str("-- PS1 reporting: ")) test_area.insert(tk.END,(MEAS_3)) test_area.insert(tk.END,str(" volts\n")) test_area.insert(tk.END,str("-- Connecting DMM to ADAPTER.\n")) test_area.insert(tk.END,str("-- Everything ok? Please prees Y or N...\n")) ser9.close() ser4.open() ser4.write(b'\x0B') ser4.write(b'\x0B') ser4.close() test_area.yview(END) #ready keyboard.wait('y'or 'Y') ser4.open() ser4.write(b'\x00') ser4.write(b'\x00') ser4.close() root.mainloop()
buran write Mar-24-2023, 09:02 AM:
Moved from Code Review section of the forum.
Moved from Code Review section of the forum.
Larz60+ write Mar-23-2023, 11:49 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.