Compiling Arduino code from custom made GUI using PlatformIO CLI

I am trying to build a custom GUI of my own using Qt designer and PyQt5 script. I have properly placed and coded all the buttons and text edits in my GUI. I want to compile and upload arduino sketch from my GUI using the platformIO CLI or the platformIO IDE integration. As of now I have no clue how to achieve it. Can anyone help me with it.
This is a picture of my GUI

I think you should use QProcess module to communicate with PlatformIO CLI. Here is an example.

How will I run the Widget file which is given in the example on windows?

Widget file is just the example how to use QProcess to communicate between applications, everything else you should write by yourself.

Any idea how to install platformIO for python 3.4?

PlatformIO supports only Python 2.7. In theory, it could be run with any Python versions but it depends on SCons tool which supports only Python 2.7.

The workflow from the PlatformIO side should be next:

  1. Each PlatformIO command should be run with the next required options: platformio -f -c myqtapp, where -f tells PlatformIO to force any prompts and avoid blocking operation; -c myqtapp is unique identifier of your application (you can choose any other ID).
  2. When user presses “Compile/Upload” button you need to initialize PlatformIO project. See platformio init command docs. For example, platformio -f -c myqtapp init -d /path/to/tmp/dir --board uno. This command initializes new PlatformIO project for Arduino Uno board in /path/to/tmp/dir directory.
  3. Place source code(maybe from your GUI code editor) to /path/to/tmp/dir/src direcotry as sketch.ino.
  4. Build project via platformio -f -c myqtapp run -d /path/to/tmp/dir
  5. Upload firmware via platformio -f -c myqtapp run -d /path/to/tmp/dir -t upload.

P.S: You can omit -d /path/to/tmp/dir with running this command from CWD where is project located.

Can you elaborate on how to ID the “myqtapp” so that it refers to my GUI. And all those commands that you have suggested are to be executed in CMD and the output to be shown in my GUI, right?

This ID is used inside PlatformIO CLI for better handling of own subprocess. I propose you to set it to the name of your application. For example, for IDEs it equal as -c eclipse for Eclipse IDE, -c vim for VIM text editor and etc. The one rule here is [a-z-0-9] chars.

Right. Take a look on Sublime Text Project Template for PlatformIO.