471,355 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

WXPYTHON push button call a frame

Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?

......
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, "")
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()

class MTRRHH(wx.Frame):
........
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, "")
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()

Jul 5 '07 #1
4 1764
Marcpp wrote:
Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?
Well, one *really* good idea would be to copy the error message and
paste it into your message. The readers of this list have amazing
psychic powers, but you can always help improve the answer quality by
providing relevant information.
.....
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, "")
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()

class MTRRHH(wx.Frame):
.......
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, "")
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()
Unfortunately your code extracts don't tell us what's going wrong, only
how the program is constructed. While that *is* useful information, by
itself it only paints half the picture.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 5 '07 #2
On 5 jul, 14:51, Steve Holden <s...@holdenweb.comwrote:
Marcpp wrote:
Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?

Well, one *really* good idea would be to copy the error message and
paste it into your message. The readers of this list have amazing
psychic powers, but you can always help improve the answer quality by
providing relevant information.
.....
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, "")
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()
class MTRRHH(wx.Frame):
.......
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, "")
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()

Unfortunately your code extracts don't tell us what's going wrong, only
how the program is constructed. While that *is* useful information, by
itself it only paints half the picture.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Hi, the problem is No Error message, but the program continues running
after I closed it (by the X).

Jul 5 '07 #3
On Jul 5, 9:04 am, Marcpp <mar...@gmail.comwrote:
On 5 jul, 14:51, Steve Holden <s...@holdenweb.comwrote:
Marcpp wrote:
Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?
Well, one *really* good idea would be to copy the error message and
paste it into your message. The readers of this list have amazing
psychic powers, but you can always help improve the answer quality by
providing relevant information.
.....
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, "")
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()
class MTRRHH(wx.Frame):
.......
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, "")
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()
Unfortunately your code extracts don't tell us what's going wrong, only
how the program is constructed. While that *is* useful information, by
itself it only paints half the picture.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Hi, the problem is No Error message, but the program continues running
after I closed it (by the X).
When I open a custom frame from one of my applications, I do something
like this:
<main app code>

def BtnEventHandler(self, event):
frame = myFrame()
frame.Show()

</main app code>
<myframe code>

class myFrame(wx.Frame):
def __init__(self, filename=None):
wx.Frame.__init__(self, None, -1, 'Whatever', size=(570,295))
# you can set the OnTop style here
# lots of other code...

def OnClose(self, event):
# Close the frame
self.Close()

</myframe code>

If you have additional problems, try mailing the wxPython group, which
you can find here: www.wxpython.org

Mike

Jul 5 '07 #4
Marcpp schreef:
Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?

.....
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, "")
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()

class MTRRHH(wx.Frame):
.......
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, "")
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()
In DialogRRHH() you create a new application object with a new event
loop, while you already have one running. wxPython should have only one
application object though; otherwise there conflicts between the
different event loops. Also you don't need to call
wx.InitAllImageHandlers() again.

It seems to me that in DialogRRHH() you want to create a dialog and wait
until the user closes it. In that case, it should look more or less like
this (beware, I'm not a wxPython expert myself):

def DialogRRHH(self, event):
DialogRRHH = MTRRHH(None, -1, "")
DialogRRHH.ShowModal()

Also, in that case MTRRHH should be a wxDialog, not a wxFrame.

In case you want to show MTRRHH without waiting for the user to close
it, use DialogRRHH.Show() instead of .ShowModal(). I think MTRRHH can be
either a wxDialog or a wxForm in that case.

--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
Jul 5 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Grant Edwards | last post: by
15 posts views Thread by Grant Edwards | last post: by
1 post views Thread by mdk.R | last post: by
reply views Thread by plumpy321 | last post: by
3 posts views Thread by John Salerno | last post: by
4 posts views Thread by Jimmy | last post: by

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.