python - Tkinter RPy2 GUI Issues -



python - Tkinter RPy2 GUI Issues -

i have tcltk gui coded in r wish implement via python using r's "source" command. in past, has been simple implementation; phone call source command using rpy2 python , tcltk gui load.

however, seems not case. realize tkinter not multithreaded , reason my gui freezes.

to combat this, have attempted create thread in python (containing "source" command) acts thread , uses queue function. now, tcltk gui r source command runs , not frozen (since has ability update or refresh, if will); however, source command called in infinite loop resulting in multiple instances of r gui beingness started.

is there way can phone call source command once, have gui maintain ability take input?

here code far adapted illustration found:

import tkinter import time import threading import random import queue import rpy2.robjects robjects time import sleep class guipart: def __init__(self, master, queue): self.queue = queue def processincoming(self): while self.queue.qsize(): try: msg = self.queue.get(0) print msg except queue.empty: pass class threadedclient: def __init__(self, master): self.master = master self.queue = queue.queue() self.gui = guipart(master, self.queue) self.running = 1 self.thread1 = threading.thread(target=self.workerthread1) self.thread1.start() self.periodiccall() def periodiccall(self): self.gui.processincoming() if not self.running: import sys sys.exit(1) self.master.after(100, self.periodiccall) def workerthread1(self): while self.running == 1 : rsource = robjects.r.source rsource("biolab_gui_1.r") root = tkinter.tk() client = threadedclient(root) root.mainloop()

python r user-interface tkinter rpy2

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -