Creating a GUI with a script

Hi, I’m on a research team with Taylor university and I am creating a script that can be used to gather any data we would need from the copters through a GUI that will allow a user to enter the parameter name they wish to record and a few other miscellaneous items. I’m running into a problem with creating and showing the GUI though, as I am getting the error “Error running script The calling thread must be STA, because many UI components require this.”

I’ve looked it up and cannot find anything that fixes the issue. My only thought to fix it is to create a new thread and run it off of there, but I cannot get that to work either (I’m assuming I am just importing Thread incorrectly)

Here is the code if it will help you help me (Will include the XAML if needed):

[code]import clr
clr.AddReference(‘IronPython.Wpf’)
import wpf

from System.Windows import Application, Window, Visibility
from System.Windows.Media import Brushes

class WpfSampleWindow(Window):
def init(self):
wpf.LoadComponent(self, ‘Window1.xaml’)

def startBtn_Click(self, sender, e):
    self.doStuff(10,"alt")

def Window_Loaded(self, sender, e):
    print("Loaded")

def doStuff(self,iterations,param):
    count = 0
    while count < iterations:
        count += 1
        m = globals()['cs']()
        func = getattr(m, param)
        self.startBtn.Content = func

def run(self):
    t = Thread(ThreadStart(start))
    t.IsBackground = True
    t.ApartmentState = ApartmentState.STA

WpfSampleWindow().Show()[/code]

Some additional data: Threading just causes mission planner to crash, unless I did it terribly wrong.

threading fails because there is already a STA, being mission planner itself.
have a look at invoking what you require