Q:

If I want to create a GUI which displays exactly the same data as TOP command does in LINUX, where do I get the data from?

I found out that I can get the PID(first column) from the /proc/[pid]/stat file, first column. I am not sure where can I find the rest of the attributes. And my guess is we need to calculate the %CPU and %MEM from some other attributes. Can someone please help me with this? 
My GUI should look exactly like top. I am using Python3 and ttk for the GUI. 

A:

If you type:
strace -o outfile top

it will run top as usual, while tracing all the system calls it makes and placing the result in outfile. The files it opens are visible as calls to the open(2) system call. After running this, you should quit top quickly, since it will keep appending lots of data and just a few seconds worth are enough to tell you what it reads.
Running this quickly on my own system, it appears most of the data are from /proc/<pid>/stat, /proc/<pid>/status and /proc/<pid>/statm. Some searching and experimentation should allow you to determine the formats of these.

