C
Christian Wilcox
Does anyone know of any existing Python implementations of an XForms viewer?
Christian
Christian
Christian Wilcox said:Does anyone know of any existing Python implementations of an XForms
viewer?
Larry said:Shane,
You can access all the Windows common dialogs (forms?)
Python by using Win32 extensions. Specifically using
pywin.mfc dialog and win32ui modules. Here is an example
that I "hacked" from Demos directory. If this is
something you want to study more see Mark Hammond's
excellent Python Programming on Win32 book.
HTH,
Larry Bates
Syscon, Inc.
#
# Progress bar control example
#
# PyCProgressCtrl encapsulates the MFC CProgressCtrl class. To use it,
# you:
#
# - Create the control with win32ui.CreateProgressCtrl()
# - Create the control window with PyCProgressCtrl.CreateWindow()
# - Initialize the range if you want it to be other than (0, 100) using
# PyCProgressCtrl.SetRange()
# - Either:
# - Set the step size with PyCProgressCtrl.SetStep(), and
# - Increment using PyCProgressCtrl.StepIt()
# or:
# - Set the amount completed using PyCProgressCtrl.SetPos()
#
# Example and progress bar code courtesy of KDL Technologies, Ltd., Hong
Kong SAR, China.
#
from pywin.mfc import dialog
import win32ui
import win32con
import time
def MakeDlgTemplate():
style = (win32con.DS_MODALFRAME |
win32con.WS_POPUP |
win32con.WS_VISIBLE |
win32con.WS_CAPTION |
win32con.WS_SYSMENU |
win32con.DS_SETFONT)
cs = (win32con.WS_CHILD |
win32con.WS_VISIBLE)
w = 215
h = 36
dlg = [["Progress bar",
(0, 0, w, h),
style,
None,
(8, "MS Sans Serif")],
]
return dlg
class TestDialog(dialog.Dialog):
def OnInitDialog(self):
rc = dialog.Dialog.OnInitDialog(self)
self.pbar = win32ui.CreateProgressCtrl()
self.pbar.CreateWindow (win32con.WS_CHILD |
win32con.WS_VISIBLE,
(10, 10, 310, 24),
self, 1001)
return rc
def demo():
d = TestDialog (MakeDlgTemplate())
d.CreateWindow ()
for i in xrange(100):
d.pbar.SetPos(i)
time.sleep(0.1)
d.OnCancel()
if __name__=='__main__':
demo()
# $Header: /home/cvsroot/PyWin32/Pythonwin/pywin/Demos/progressbar.py,v 1.1
1999/09/01 23:33:35 mhammond Exp $
Hey folks,
I'm new to Python and programming in general and I'm having a blast. I
was curious if it was possible to use Windows.Forms; I'm interesting in
porting a C++ program a friend wrote for me to Python and would like to
use a similar GUI (its fairly simple). I've noticed ActiveState has a
.NET plugin for Python...
http://www.activestate.com/Products/Visual_Python/?_x=1
...but I'm not sure that is what I am looking for and I'm stuck with
Borland C# Builder Personal Edition anyway for financial reasons.
One thing that threw me for a loop was that when I used ActivePython
(ActiveStates Python IDE, I like it so far) to run a script I wrote, it
gives me a Windows.Forms input box when I call raw_input as opposed to
the regular console input message you get in the basic interactive
window that comes with a standalone Pythin installation. What's going on
there? Can I harness that a little more?
Shane Brennan
Larry Bates said:You can access all the Windows common dialogs (forms?)
Python by using Win32 extensions.
Tim said:His specific question was about Windows.Forms, which is a .NET class in the
Common Language Runtime. Hooking that is not as easy as popping into the
common dialogs.
Shane said:Sorry Tim, I first learned programming with C# so when I said
Windows.Forms I meant any generic Windows form, and especially common
dialogs. My mistake! I'm glad I made though since Marijan Tadin pointed
out that python .NET link that I wasn't aware of (see his reply). Thanks
again...
Tim said:Interesting that this newsgroup is able to answer not only the question you
ASKED, but the question you MEANT to ask...
Larry Bates said:Shane,
You can access all the Windows common dialogs (forms?)
Python by using Win32 extensions. Specifically using
pywin.mfc dialog and win32ui modules. Here is an example
that I "hacked" from Demos directory. If this is
something you want to study more see Mark Hammond's
excellent Python Programming on Win32 book.
HTH,
Larry Bates
Syscon, Inc.
#
# Progress bar control example
#
# PyCProgressCtrl encapsulates the MFC CProgressCtrl class. To use it,
# you:
#
# - Create the control with win32ui.CreateProgressCtrl()
# - Create the control window with PyCProgressCtrl.CreateWindow()
# - Initialize the range if you want it to be other than (0, 100) using
# PyCProgressCtrl.SetRange()
# - Either:
# - Set the step size with PyCProgressCtrl.SetStep(), and
# - Increment using PyCProgressCtrl.StepIt()
# or:
# - Set the amount completed using PyCProgressCtrl.SetPos()
#
# Example and progress bar code courtesy of KDL Technologies, Ltd., Hong
Kong SAR, China.
#
from pywin.mfc import dialog
import win32ui
import win32con
import time
def MakeDlgTemplate():
style = (win32con.DS_MODALFRAME |
win32con.WS_POPUP |
win32con.WS_VISIBLE |
win32con.WS_CAPTION |
win32con.WS_SYSMENU |
win32con.DS_SETFONT)
cs = (win32con.WS_CHILD |
win32con.WS_VISIBLE)
w = 215
h = 36
dlg = [["Progress bar",
(0, 0, w, h),
style,
None,
(8, "MS Sans Serif")],
]
return dlg
class TestDialog(dialog.Dialog):
def OnInitDialog(self):
rc = dialog.Dialog.OnInitDialog(self)
self.pbar = win32ui.CreateProgressCtrl()
self.pbar.CreateWindow (win32con.WS_CHILD |
win32con.WS_VISIBLE,
(10, 10, 310, 24),
self, 1001)
return rc
def demo():
d = TestDialog (MakeDlgTemplate())
d.CreateWindow ()
for i in xrange(100):
d.pbar.SetPos(i)
time.sleep(0.1)
d.OnCancel()
if __name__=='__main__':
demo()
# $Header: /home/cvsroot/PyWin32/Pythonwin/pywin/Demos/progressbar.py,v 1.1
1999/09/01 23:33:35 mhammond Exp $
Shane said:Hey folks,
I'm new to Python and programming in general and I'm having a blast. I
was curious if it was possible to use Windows.Forms; I'm interesting in
porting a C++ program a friend wrote for me to Python and would like to
use a similar GUI (its fairly simple). I've noticed ActiveState has a
.NET plugin for Python...
http://www.activestate.com/Products/Visual_Python/?_x=1
...but I'm not sure that is what I am looking for and I'm stuck with
Borland C# Builder Personal Edition anyway for financial reasons.
One thing that threw me for a loop was that when I used ActivePython
(ActiveStates Python IDE, I like it so far) to run a script I wrote, it
gives me a Windows.Forms input box when I call raw_input as opposed to
the regular console input message you get in the basic interactive
window that comes with a standalone Pythin installation. What's going on
there? Can I harness that a little more?
Shane Brennan
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.