SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

GUI not appearing using Run but does from command line -- How to solve

Last post 07-18-2017 7:13 PM by sbridewell. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-17-2017 12:54 PM

    GUI not appearing using Run but does from command line -- How to solve

    Hello all.

    I have a app (I'm just trying to learn Python) and when I run: ipy at the command line in the directory for the solution (where is located the GUI appears fine.

    When I click the created .exe file after a Build (with no errors) it does not appear (tho' does appear to be doing something behind the scenes<G>).

    When I create a very simple test (like in IronPython in Action book) then I get the GUI as expected.

    When I first started testing/learning this worked (running the .exe or from the "Run" button) but at times failed---I fixed this in the past by commenting out code I just entered and when it ran was able to isolate where some errors were hiding. This doesn't work now. I've commented out the entire code except the controls initialization portion and still not GUI form appears.

    Can anyone suggest some things for me to try?  I've added IronPython to my path. I've added the BackEndBindings Python subdir to my path (from Sharpdevelop).

    Thank you in advance for your time and help




  • 07-17-2017 8:37 PM In reply to

    Re: GUI not appearing using Run but does from command line -- How to solve

    I've just done a bit of reading about Python, and I'm actually more confused now than I was an hour ago.

    According to it's an interpreted language, yet when I create a Python project in SharpDevelop and build it, it appears to compile the project to a .dll and a .exe file, implying that it's a compiled language. Or at least those binary files appear to contain the code from my source files (I opened them in ILDasm to look for references to things I'd added to the project).

    And when I look at the project properties, specifically the Debug tab, I see that debugging the project (run button), rather than just starting the project, as would normally be the case for a C# Windows or console application, it actually runs a program called ipy.exe and passes it two command line arguments: "-X:Debug" and the name of my source file. The fact it passes the name of a source code file makes me think that debbuging the project actually means interpreting the source code at run time and running the interpreted code, rather than running the .exe built from the source code, but that's just an uneducated guess on my part.

    Anyway, I seem to be able to run my application from the run button, by double-clicking the .exe file in windows explorer, by running the .exe file from a command prompt, and also by passing the name of the file to ipy,exe in a command prompt. They all seem to work for me.

    Are you able to edit your MainForm in the forms designer (switch from "code" tab to "design" tab)? The designer will normally display an exception message if you've commented out anything which will break the form.

    And does your MainForm still contain a def __init__(self): and a def InitializeComponent(self): (the first looks like the method signature for a constructor, which in turn calls InitializeComponent, and the second looks like the method signature for the InitializeComponent method so you'll need them both)?


  • 07-17-2017 9:16 PM In reply to

    Re: GUI not appearing using Run but does from command line -- How to solve

    Well if you are confused then I don't feel so bad<G>.

    I can switch back and forth between coding and designing on the MainForm without any problem. The still contains both the def__init(self) and def InitializeComponent(self).

    Like I said---during my initial experimentation I was able to double-click the .exe file and was able to bring up my Windows application. Now the only way is to use: ipy (in the subdir of the solution directory where lives).

    This bothers me since if I want to distribute I don't want to have to install IronPython on the user's machine---I thought I would be able to just distribute the .exe and all the required .dlls.

    My understanding is the Run without debugger run's the appication's executable but in my case, as I mentioned, now does not work.

    If there were an error causing this in my program then I would think it would not work when I ran from the command line with ipy

    Could it be a path problem? More of a configuration issue than a "programming issue".

    Again thanks very much for taking the time to respond.



  • 07-17-2017 10:05 PM In reply to

    Re: GUI not appearing using Run but does from command line -- How to solve

    Seeing as I don't really understand in each scenario whether your code is being interpreted at runtime or being run via the .exe and .dll files created by SharpDevelop, I'm reluctant to comment further.

    My "hello world" Python application worked straight away, I just added a project to my solution, dragged a button onto the MainForm, double-clicked the button to create an event handler for it, and added a MessageBox.Show("hello world") to the event handler. I didn't need to do anything with paths to make it work, so neither should you need to.

    I suspect (but can't prove, because I don't know Python), that the issue is probably somewhere within your code. It was all working until you wrote some more code and then it stopped working, so the more code is probably the cause. I think you would be better off asking for help in a forum dedicated to Python (or IronPython) rather than one dedicated to SharpDevelop. Or, failing that, try (I find loads of answers there, to questions I haven't needed to ask because someone else has already asked them).

    Sorry, I think I've reached my limit of usefulness on this subject :-(

    But please let us know how you get on, so that anyone else learning Python who hits similar issues can find this thread and learn from you :-)


  • 07-18-2017 12:19 PM In reply to

    Re: GUI not appearing using Run but does from command line -- How to solve

    I tried a simple app like you suggested and it worked! So I agree it must not be the paths---at least not with the references used and paths to program files.

    I am trying to use a third-party .Net control which I've used extensively in VS (Flexcell) which is a grid control. It may be the offending reference.

    You gave me an idea. As soon as I get a chance I'll copy the MainForm code to NotePad. Then I'll use that minimal test app that works. I will keep copying and pasting code (maybe by subroutines) from NotePad to the MainForm file and when it fails I'll go line by line to find the cause.

    I would like to know WHY it is failing in this manner---not only to have the IDE work as I think it was written to work but maybe understanding the cause of failure will help me understand more about IronPython or Python. I've found that understanding why I get an error in VS has led me to avoid future mistakes (tho' not always).

    Anyway...I do appreciate your time. If I get this test app working I would like to post the code here--not only for constructive criticism but to put in one place what I've had to search all over the web for. Maybe it will help someone else looking for a demo?


  • 07-18-2017 7:13 PM In reply to

    Re: GUI not appearing using Run but does from command line -- How to solve

    That sounds like a good approach, starting with a working "hello world" app and gradually adding bits of your real application to it until it stops working. And don't forget to wrap any bits which could possibly throw an exception in the Python equivalent of a try {...} catch {...} (even if only as a temporary measure to help you find the problem).

    And yes, if you do get to the bottom of what's wrong and how to fix it, please do share that information here, for the benefit of anyone who hits the same problem in future and finds this thread using their favourite search engine.

    Good luck :-)


Page 1 of 1 (6 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this ( email address.