multithreading - Opening and running a python script in spyder from tkinter -
i hoping there way open '.py' file in spyder , run in correlating ipython console tkinter window. have been able scripts run using threading , os.system, run spyder in ipython
here code wrote, run1 works, not open spyder run it. know if exists run2. (i know run_in_spyder not function). perhaps there cmd commands spyder not know of.
to_run example script.
here backbone of code.
import tkinter tk import ttk import tkfiledialog pil import imagetk, image collections import ordereddict import os, sys shutil import copy threading import thread to_run import make_df root_dir = os.getcwd()+os.sep class lippy_ui: def __init__(self, master): self.master = master self.master.geometry('450x300+200+200') self.frame = ttk.frame(self.master) self.style = ttk.style() self.style.theme_use('vista') self.title = master.title('title') self.labeltext = tk.stringvar() self.labeltext.set('welcome. \n here can kinds of stuff , things!') self.introtext = tk.label(self.master, textvariable=self.labeltext, height =4) self.introtext.pack() self.button1 = ttk.button(self.frame, text = 'run', width = 25, command = self.run) self.button1.pack(padx=15,pady=10) self.menubar = tk.menu(self.master) self.filemenu = tk.menu(self.menubar, tearoff = 0) self.filemenu.add_command(label = 'quit', command = self.close_window) self.menubar.add_cascade(label = 'file',menu = self.filemenu) self.master.config(menu=self.menubar) self.frame.pack() def run1(self): thread1 = thread(target = make_df) thread1.start() def run2(self): file_to_run = tkfiledialog.askopenfilename() desired_working_dir = 'd:\my_scripts' run_in_spyder(runfile(file_to_run, wdir=desired_working_dir)) def close_window(self): self.master.destroy() if '__main__' == __name__: root = tk.tk() lippy_ui(root) root.mainloop()
Comments
Post a Comment