469,927 Members | 1,800 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

help on pywin CreateWindow Vs. DoModal

Hi all,

Python:2.5
OS: Windows XP

I have posted couple questions regarding the wxPython. Since I am still a newbie to Python, wxPython makes more sense to me than pyWin for gui programming. But 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). When the "DoModal" is called, the gui will stay in loop. It is different when the "CreateWindow" is called. And we run the program from command prompt, the gui won't stay in loop (or basically just blink for a moment and disappear). Can someone explain this for us? And what should we do to make the gui stay in loop if we used "CreateWindow". We really appreciate for any help. Thanks in advance.
Mar 21 '07 #1
3 3681
bartonc
6,596 Expert 4TB
Hi all,

Python:2.5
OS: Windows XP

I have posted couple questions regarding the wxPython. Since I am still a newbie to Python, wxPython makes more sense to me than pyWin for gui programming. But 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). When the "DoModal" is called, the gui will stay in loop. It is different when the "CreateWindow" is called. And we run the program from command prompt, the gui won't stay in loop (or basically just blink for a moment and disappear). Can someone explain this for us? And what should we do to make the gui stay in loop if we used "CreateWindow". We really appreciate for any help. Thanks in advance.
Sounds like a MainLoop() issue. Typically, (in other GTKs) "create" would be like Show() and return control to MainLoop() for event processing.
Sorry, I still don't know anyone who uses PythonWin, for the very reason that you need to know MFC.
Mar 21 '07 #2
Update:

We just did a quick test running our simple program on the "PythonWin" program instead of the command program, and the gui is staying in the loop. We really appreciate if someone can help us out with all the confusion that we have. Thanks.

By the way, here is the simple code that we try on:
Note: Codes credits to Mark Hammond.

Expand|Select|Wrap|Line Numbers
  1. import win32ui
  2. import win32con
  3. from pywin.mfc.dialog import Dialog
  4.  
  5. d = Dialog (win32ui.IDD_SIMPLE_INPUT)
  6.  
  7. print d
  8. print d._obj_
  9.  
  10. d.CreateWindow ()
  11. #d.ShowWindow (win32con.SW_SHOWNORMAL)
  12. button = d.GetDlgItem (win32ui.IDC_PROMPT1)
  13. print "button: ", button
  14. button.SetWindowText ("Hello from Python")
  15. d.SetWindowText ("Python is awesome")
  16.  
Mar 21 '07 #3
bartonc
6,596 Expert 4TB
Update:

We just did a quick test running our simple program on the "PythonWin" program instead of the command program, and the gui is staying in the loop. We really appreciate if someone can help us out with all the confusion that we have. Thanks.

By the way, here is the simple code that we try on:
Note: Codes credits to Mark Hammond.

Expand|Select|Wrap|Line Numbers
  1. import win32ui
  2. import win32con
  3. from pywin.mfc.dialog import Dialog
  4.  
  5. d = Dialog (win32ui.IDD_SIMPLE_INPUT)
  6.  
  7. print d
  8. print d._obj_
  9.  
  10. d.CreateWindow ()
  11. #d.ShowWindow (win32con.SW_SHOWNORMAL)
  12. button = d.GetDlgItem (win32ui.IDC_PROMPT1)
  13. print "button: ", button
  14. button.SetWindowText ("Hello from Python")
  15. d.SetWindowText ("Python is awesome")
  16.  
I do know tha Mr. Hammond put some special work into the PythonWin IDE to handle GUI application degugging. That's probably what's keeping the window open. Mr. Hammond's book is very expensive, but I have seen it used on amazon.
Mar 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Clive Moore | last post: by
2 posts views Thread by Jeff Adams | last post: by
6 posts views Thread by Charles Krug | last post: by
7 posts views Thread by Mr. Roboto | last post: by
1 post views Thread by Richard Gordon | last post: by
2 posts views Thread by Richard Gordon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.