Click here to Skip to main content
14,239,615 members
Rate this:
Please Sign up or sign in to vote.
See more:
I wanted to make two processes. One for the main program (class mainclass) and the second one for checking variable values for debugging.
Please help.
<pre>from tkinter import *
import time
#import multiprocessing
from multiprocessing import Process 
root = Tk()
root2 = Toplevel()
root2.title("root2")
class Mainclass:
	def __init__(self):
		root.title("root")
		frame= Frame(root)
		b = Button(root,text="button")
		b.grid()
		self.x = 55

mainclass = Mainclass()

labellist = []
class something:
	def __init__(self):
		global mainclass,labellist
		
		

		for x in mainclass.__dict__: #list of instance variables
				try:
					l = Label(root2,text=str(x))
					l.grid(column=0)
					i = Label(root2,text=x)
					i.grid(column=1)
					labellist.append(i)
					print("labellist",labellist)
				except:
					print("exception")
				
		self.otherfunction()
	def otherfunction(self):

                        
		while True:
			time.sleep(2)
			lenprocess2dict = len(mainclass.__dict__)
			print(lenprocess2dict)
			if len(mainclass.__dict__) > lenprocess2dict:
				for x in range(lenprocess2dict,len(mainclass.__dict__)):
					l = Label(root2,text=str(mainclass.__dict__[x].keys()))
					l.grid(column=0)
					i = Label(root2,text=mainclass.__dict__[x]).grid(column=1)
					labellist.append(i)
					lenprocess2dict += 1
			else:
				for x in labellist:
					index = 0
					d = list(mainclass.__dict__.keys())
					x.config(text=mainclass.__dict__[d[index]])
					index += 1 
if __name__ == '__main__': 				
	
	
	process1 = Process(target=something)
	process1.start()
	process1.join()
	#process1.join()
	print(process1)
	#prev worked when e = something() here

root.mainloop()


What I have tried:

I have a bigger program, this a basic prpgram to check that this behaviour persists. I tried running it a couple of times through Sublime Text 3 and IDLE. There aren't any error meassages, it's just that nothing appears.
Posted
Updated 27-Apr-19 21:33pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100