Esempio n. 1
0
        private void runButton_Click(object sender, EventArgs e)
        {
            var scriptscope = NewScope(pythonengine);

            me = this;

            var script = scriptEditor.Text;

            scriptOutput.Text = "";
            linenum = -1;

            EnableButtons(false);

            linenumTimer.Enabled = true;
            linenumTimer.Start();

            Thread th = Helpers.NewThread(new ThreadStart(() =>
            {
                pythonengine.SetTrace(PythonTrace);

                // ignore output, the trace handler above will print output
                string output = Execute(pythonengine, scriptscope, script);

                linenumTimer.Stop();
                pythonengine.SetTrace(null);

                this.BeginInvoke(new Action(() =>
                {
                    scriptOutput.Text += output;

                    SetLineNumber(linenum);

                    EnableButtons(true);
                }));
            }));

            th.Start();
        }
Esempio n. 2
0
        private void runButton_Click(object sender, EventArgs e)
        {
            var scriptscope = NewScope(pythonengine);

            me = this;

            var script = scriptEditor.Text;

            scriptOutput.Text = "";
            linenum = -1;

            EnableButtons(false);

            linenumTimer.Enabled = true;
            linenumTimer.Start();

            pythonThread = Helpers.NewThread(new ThreadStart(() =>
            {
                pythonengine.SetTrace(PythonTrace);

                string output = "";
                // ignore output, the trace handler above will print output
                try
                {
                    output = Execute(pythonengine, scriptscope, script);
                }
                catch (ThreadAbortException)
                {
                    // python was interrupted
                    Thread.ResetAbort();
                }

                linenumTimer.Stop();
                pythonengine.SetTrace(null);

                this.BeginInvoke(new Action(() =>
                {
                    pythonThread = null;

                    scriptOutput.Text += output;
                    scriptOutput.SelectionStart = scriptOutput.TextLength;
                    scriptOutput.ScrollToCaret();

                    SetLineNumber(linenum);

                    EnableButtons(true);
                }));
            }));

            pythonThread.Start();
        }