Python Forum
Running two consecutive scripts in VSCode
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running two consecutive scripts in VSCode
#4
The problem is controlling output in 2 VSCode sessions. The Python code is running fine. It is possible that there is a Python solution to the problem, i.e. multiprocessing/threading would solve the problem, but we have no code to work with.

A simple program that sends data to a Tkinter Listbox instead of the shell. Don't know if this will help or not, and you may have to use multiprocessing/threading for each separate program instance, but the listbox code would remain similar to this
## program name = test_1.py
def update_listbox(listbox, ctr, time_to_sleep):
    listbox.insert("end", "%s" % (ctr))
    listbox.after(time_to_sleep, update_listbox, listbox, ctr+1, time_to_sleep)

## different program
import tkinter as tk
import multiprocessing
import test_1

class CalculateNumbers():
    def __init__(self, root):
        self.root=root
        tk.Button(self.root, text="Quit", bg="orange",
               command=self.root.quit, width=7).grid()

        self.lb_1 = self.create_listbox("lightblue")
        test_1.update_listbox(self.lb_1, 1, 500)
        self.lb_2 = self.create_listbox("lightyellow")
        test_1.update_listbox(self.lb_2, 11, 750)

    def create_listbox(self, bg_color):
        top=tk.Toplevel(root)
        lb = tk.Listbox(top, height=30, width=20, bg=bg_color,
                        font=('Fixed', 14))
        lb.grid(row=0, column=0)

        return lb

if __name__ == "__main__":
    root=tk.Tk()
    CN=CalculateNumbers(root)
    root.mainloop()
Reply


Messages In This Thread
RE: Running two consecutive scripts in VSCode - by woooee - Mar-10-2019, 09:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  running py3 scripts as root Skaperen 4 3,138 Dec-18-2019, 12:31 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020