Chris,
On second thought, the example that Paul Kunysch sent me may be all that you
need. Here it is again in case you missed it. Just put the main part of your
script under the "if __name__ == '__main__':" section and open dialogs as
you need to.
I did it a lot differently. Basically, I saved a reference to the wxApp
object and just passed it as I needed it, but Paul's example seems a lot
simpler.
Dan
···
--------------------------------------------------------------
from wxPython import wx
from sys import exit
class MyDialog(wx.wxDialog):
def __init__(self, parent):
wx.wxDialog.__init__(self, parent, -1, 'wxDialog')
clb = wx.wxCheckListBox(
self, -1, choices=['check', 'list', 'box'])
ok = wx.wxButton(self, wx.wxID_OK, 'Ok')
sizer = wx.wxBoxSizer(wx.wxVERTICAL)
sizer.Add(clb, 1, wx.wxEXPAND|wx.wxALL, 5)
sizer.Add(ok, 0, wx.wxALIGN_RIGHT|wx.wxALL^wx.wxTOP, 5)
self.SetSizer(sizer)
sizer.Fit(self)
self.Layout()
if __name__ == '__main__':
# You could put some code here
app = wx.wxPySimpleApp()
frame = wx.wxFrame(None, -1, 'Focus test')
frame.Show(1)
# And here, etc.
fd = wx.wxFileDialog(frame)
if fd.ShowModal() != wx.wxID_OK:
exit(1)
md = wx.wxMessageDialog(frame, 'Continue?')
if md.ShowModal() != wx.wxID_OK:
exit(1)
scd = wx.wxSingleChoiceDialog(frame, 'msg', 'cap', ['single', 'choice'])
if scd.ShowModal() != wx.wxID_OK:
exit(1)
myd = MyDialog(frame)
if myd.ShowModal() != wx.wxID_OK:
exit(1)
-----Original Message-----
From: Rolander, Dan
Sent: Monday, January 22, 2001 2:36 PM
To: 'Chris Barker'; wxpython-users@lists.sourceforge.net
Subject: RE: Procedural wxPython Program
Yes, Chris, I saw your posts in the wxPython archives and I was hoping to
find that you received some suitable advice, but apparently you didn't. I
almost sent you email directly asking you about that.
I think I am doing exactly what you were trying to do. My app started as a
console app and I just replaced the input and print commands with GUI
dialogs. Give me a chance to simplify it a bit into a generic demo and then
I'll send it to you. I'll try to do that tonight.
Dan
-----Original Message-----
From: Chris Barker [mailto:cbarker@jps.net]
Sent: Monday, January 22, 2001 2:33 PM
To: wxpython-users@lists.sourceforge.net; Rolander, Dan
Subject: Procedural wxPython Program
"Rolander, Dan" wrote:
Yes, you may be right. My program is 'procedural' and does not use
MainLoop,
so it worked out well that the code Paul sent me didn't use MainLoop
either.
I thought that might have something to do with it and I played with idle
time events but nothing seemed to work. I realize most gui apps should
operate within the space of an event driven loop, but for my application
it
didn't make sense.
I've tried to dothis a number of times in the past, and always failed. I
couldn't get dialogs to display at all without a mainloop. I'd love to
see a sample of what you have done, It dould be very useful.
Just to make sure we are talking about the samething, what I have in mid
is the following: And application that starts up, runs through a
process, while perhaps asking the user a couple of questions via a set
of dialog boxes. Often what I am doing is writing a small script that
does some kind of text file conversion. I might need to ask the user for
a filename or two, and maybe a couple of parameters. I don't want to
have to write a whole event driven GUI around it!
Thanks for any sample code you can send me.
-Chris
--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users