Python and XForms: existing implementations?

C

Christian Wilcox

Does anyone know of any existing Python implementations of an XForms viewer?

Christian
 
J

John J. Lee

Christian Wilcox said:
Does anyone know of any existing Python implementations of an XForms
viewer?

What environment does it have to work in?

Does it have to be cross-platform? Does it have to be in pure Python,
or just useable from Python? Does it have to integrate with a
particular GUI framework, or with MS OLE? Does it have to be open
source? etc.

(BTW, you might want to disambiguate this: XForms is both an XML
standard and an old GUI toolkit -- I assume you mean the former)


John
 
S

Shane

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
 
L

Larry Bates

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 $
 
S

Shane

Thanks Larry, that was what I was hoping to hear. And thanks for the
book suggestion; I'll be sure to look it up!

Shane Brennan


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
 
T

Tim Roberts

Larry Bates said:
You can access all the Windows common dialogs (forms?)
Python by using Win32 extensions.

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.
 
S

Shane

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.

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

Shane Brennan
 
T

Tim Roberts

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

Interesting that this newsgroup is able to answer not only the question you
ASKED, but the question you MEANT to ask...
 
P

Peter Hansen

Tim said:
Interesting that this newsgroup is able to answer not only the question you
ASKED, but the question you MEANT to ask...

It's the time machine again. Marijan noticed in 2006 that Shane
had founded a very successful startup company based on using Python
to provide continuing support for legacy technologies that had been
abandoned by the original vendor. Their "Safe-T-Net for .NET" (tm)
product alone was generating millions in annual revenue.

Using the third-generation Google "I Feel Really Lucky" link,
Marijan discovered Shane's original question and gave him the
answer to the question he should have asked in the first place.
This will have had been going to have resulted in a huge increase
in the share price for Marijan's stock portfolio, allowing him
to retire in comfort to the Cayman's at the age of twenty-two...

-Peter
 
M

Miranda Evans

May I get some clarification regarding some terminology please?
Specifically, the sentences:

"You can access all the Windows common dialogs (forms?) Python by
using Win32 extensions. Specifically using pywin.mfc dialog and
win32ui modules."

My questions are:
1) is a combo box control something that is part of the set of stuff
that is referred to as 'all the Windows common dialogs'?
2) if so, is there any sample code available in which a combo box
control is 'hacked' (Mr. Bates' term, not mine) from pywin.mfc dialog
and win32ui modules? if so, where can I find this sample code?

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
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top