Hi,

I am new to wxpython and trying to develop a small GUI interface (shown below). User selects a python script from "Browse run script" and when he/she hits the button "Execute RunScript", the script should execute via aardvark i2c interface. But I am not sure why it's not getting executed. I cannot even see any error messages after hitting the button.

Any help is really appreciated!!

import wx
import wx.grid
import wx.html
import wx.aui
from aardvark_py import *
from time import *
import cStringIO
import os
import subprocess

    self.runScript = wx.TextCtrl(self.panel,-1, "", wx.Point(100, 352), wx.Size(350, 20),
                           wx.NO_BORDER)

    self.rsButton = wx.Button(self.panel, 4, 'Browse Run Script', (475,350))
    self.Bind(wx.EVT_BUTTON, self.OnSelectRS, self.rsButton)

    self.exeButton = wx.Button(self.panel, 5, 'Execute RunScript', (250,400))
    self.Bind(wx.EVT_BUTTON, self.OnexeRS, self.exeButton)

    def OnSelectRS(self, event):
        with wx.FileDialog(self, "Choose a file to open", "",
                           "", "*.*", wx.OPEN) as dlg:
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                print("RunScript location: ", path)
                self.runScript.SetValue(path)

    def OnexeRS(self, event):
        scriptPath = self.runScript.GetValue()
        subprocess.call(scriptPath, shell=True) 

Try to use this command class instead of subprocess.call()

com = Command(scriptPath).run()
print(com.output)
print(com.error)

Thanks Gribouillis! I was able to at least see the error code now. It kind of worked.. Thanks for you help!!!

You're welcome.
Why not click on the Mark Question Solved button ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.