Recently my friend ask me for help on pywin32 gui programming.
There is one thing that throw us off (Note. Both of us don't have any
mfc background and we are newbie in python). When the "DoModal" is called, the gui will stay in
loop. It is different when the "CreateWindow" is called. If we run the
program from command prompt, the gui won't stay in loop (or basically
just blink for a moment and disappear). It is different if we run the program from "PythonWin" program. Can someone explain this for
us? It cause a lot of confusion. And what should we do to make the gui stay in loop if we used
"CreateWindow" and called it from command prompt. We really appreciate for any help. Thanks in advance.<br><br>Below is the snippet code that we used for testing:<br>
Note: Codes credits to Mark Hammond.<br><pre class="alt2 smallcode" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: scroll; width: 500px;">import win32ui<br>import win32con<br>from pywin.mfc.dialog import Dialog
<br><br>d = Dialog (win32ui.IDD_SIMPLE_INPUT)<br><br>print d<br>print d._obj_<br><br>d.CreateWindow ()<br>#d.ShowWindow (win32con.SW_SHOWNORMAL)<br>button = d.GetDlgItem (win32ui.IDC_PROMPT1)<br>print "button: ", button
<br>button.SetWindowText ("Hello from Python")<br>d.SetWindowText ("Python is awesome")</pre><br>