473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 3819
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

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

Similar topics

0
by: The Jetman | last post by:
I'm trying to port PyWin into a limited version of Windows XP, called BartPE. Essentially, it's a matter of taking the installed elements of most WinApps (ie. registry settings and files) and...
3
by: Clive Moore | last post by:
Is it possible to load a CDialog from my application and display it without stopping the excution of a program. I have tried calling doModal from the initinstance function but this stops the rest...
2
by: Jeff Adams | last post by:
I am using MSVC .NET to create a C program. I am having trouble creating a window. The createwindow returns NULL however no error is caught. The GetLastError() returns "operation completed...
6
by: Charles Krug | last post by:
Here's the deal: I've a dead-simple command-line program I'm using to test things that I can't (for various reasons) test in the IDE. Here's a do-nothing subset that shows the idea: #...
7
by: Mr. Roboto | last post by:
Folks: I want to embark on a project to add Python (actually, wxPython or PythonWin) to a new Windows app I want to start writing soon. Essentially, I want to take VB6 (or pos Delphi) and...
2
by: shakthi | last post by:
hi, Am trying to create a dialog box in MFC that has two buttons and an edit control.When i click button1,a dialog box that displays all the files in the system is displayed.when i select a...
1
by: Richard Gordon | last post by:
I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module. The test program is import pyTTS tts = pyTTS.Create() tts.Speak('Hello...
2
by: Richard Gordon | last post by:
Sorry if this is sent twice, but I didn't see it get posted the first time. I've got a fatal bug using Parente's pyTTS with Python 2.3 on Windoze 32 using MS SAPI 5.1 and Hammond's win32 module....
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.