472,972 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

wxpython frame question

Hi I am using wxpython to develop my GUI. I have 3 frame. On the first frame I have ok button and when I click that it will open 2nd frame. And when I click ok button on 2nd frame, it will open 3rd frame. But I want my 2nd frame to be closed when I open the 3rd frame. I tried self.Close() it closes 2nd and 3rd frame.
I am attaching my code. Please help

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import os, sys
  3. import string
  4. import re
  5. import cfgparse
  6. import cmd
  7. import  wx.lib.dialogs
  8. import pyExcelerator as xl
  10. class Frame1(wx.Frame):
  11.         def __init__(self, parent, id, title):
  12.             wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
  13.             self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
  14.             self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
  16.             Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
  17.             self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
  19.         def OnOk(self,event):
  20.                 self.dlg1 = Frame2(self,-1)
  21.                 self.dlg1.Show(True)
  24. class Frame2(wx.Frame):
  25.     def __init__(self, parent, id, title = "Frame2"):
  26.             wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
  27.             self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
  28.             self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
  30.             Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
  31.             self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
  33.     def OnOk(self,event):
  34.         self.dlg2 = Frame3(self,-1)
  35.         self.dlg2.Show(True)
  37. class Frame3(wx.Frame):
  38.     def __init__(self, parent, id, title = "Frame3"):
  39.             wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
  40.             self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
  41.             self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
  43.             Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
  44.             self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
  46.     def OnOk(self,event):
  47.         self.Close()
  50. class MyApp(wx.App):
  51.     def OnInit(self):
  52.         frame = Frame1(None, -1, 'Frame1')
  53.         frame.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
  54.         frame.Show(True)
  55.         self.SetTopWindow(frame)
  56.         return True
  59. app = MyApp(0)
  60. app.MainLoop()
Dec 14 '07 #1
4 4797
You'd probably have more luck getting a response if you mentioned what your code currently does, and how you want that to be different.
Jan 31 '08 #2
import wx

class frames(wx.App):

def myframe(self):

self.frame1 = wx.Frame(None, wx.ID_ANY, 'Main Frame',size=(300,150), style=wx.DEFAULT_FRAME_STYLE)
Ok1 = wx.Button(self.frame1, -1, 'Ok',wx.Point(50,50))

def ok1(self,event):
self.frame2 = wx.Frame(None, wx.ID_ANY, 'sub Frame2',size=(300,150), style=wx.DEFAULT_FRAME_STYLE)
Ok2 = wx.Button(self.frame2, -1, 'Ok2',wx.Point(50,50))
#self.frame1.Close() if u want to hide the first frame too
#del self.frame1 if u want to delete the object instance

def ok2(self,event):

self.frame3 = wx.Frame(None, wx.ID_ANY, 'sub Frame3',size=(300,150), style=wx.DEFAULT_FRAME_STYLE)
Ok3 = wx.Button(self.frame3, -1, 'Ok3',wx.Point(50,50))
del self.frame2

def ok3(self,event):
print 'Button 3 clicked'

obj = frames(0)
Jan 31 '08 #3
Try This hope this will suit ur purpose.Am a Wx beginner hoping a lot more interaction from u guys

Jan 31 '08 #4
Maybe you can just add this line in your code.....

def OnOk(self,event):
self.dlg2 = Frame3(self,-1)
self.Show(False) <----------- Add this

and the second Frame will hide when you open the third...
Jan 31 '08 #5

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

Similar topics

by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
by: Jive Dadson | last post by:
I'm trying (without conspicuous success) to start learning wxPython. Sooo... I opened the doc page wxPythonManual.html#wxpython-overview. The very first example does not work. Try it. I find...
by: Jared Russell | last post by:
I've recently decided to try my hand at GUI programming with wxPython, and I've got a couple questions about the general conventions regarding it. To mess around with it, I decided to create a...
by: rbann11 | last post by:
Hi, I am looking for example code that consists of just a frame and a grid(10x2). The grid must fill the its parent even if the frame is resized. Thanks in advance, Roger
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
by: mark.martinez2 | last post by:
This is a wxPython question.. the wxPython group is pretty much inactive. I have an MDI parent frame and child frame set up. In the child frame, I want to use part of the frame to display the...
by: Jimmy | last post by:
Hi, wxPython is cool and easy to use, But I ran into a problem recently when I try to write a GUI. The thing is I want to periodically update the content of StatixText object, so after create...
by: Stef Mientki | last post by:
Peter Anderson wrote: In PyScripter, you should run wxPython in the plain remote machine (not the wxPython remote), and you should set "reset before run flag" or reset the remote machine each...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.