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 -
import wx
-
import os, sys
-
import string
-
import re
-
import cfgparse
-
import cmd
-
import wx.lib.dialogs
-
import pyExcelerator as xl
-
-
class Frame1(wx.Frame):
-
def __init__(self, parent, id, title):
-
wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
-
self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
-
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
-
-
Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
-
self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
-
-
def OnOk(self,event):
-
self.dlg1 = Frame2(self,-1)
-
self.dlg1.Show(True)
-
-
-
class Frame2(wx.Frame):
-
def __init__(self, parent, id, title = "Frame2"):
-
wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
-
self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
-
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
-
-
Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
-
self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
-
-
def OnOk(self,event):
-
self.dlg2 = Frame3(self,-1)
-
self.dlg2.Show(True)
-
-
class Frame3(wx.Frame):
-
def __init__(self, parent, id, title = "Frame3"):
-
wx.Frame.__init__(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
-
self.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
-
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
-
-
Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
-
self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)
-
-
def OnOk(self,event):
-
self.Close()
-
-
-
class MyApp(wx.App):
-
def OnInit(self):
-
frame = Frame1(None, -1, 'Frame1')
-
frame.SetIcon(wx.Icon('PyCrust.ico',wx.BITMAP_TYPE_ICO))
-
frame.Show(True)
-
self.SetTopWindow(frame)
-
return True
-
-
-
app = MyApp(0)
-
app.MainLoop()
-
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.
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)
self.frame1.Show()
Ok1 = wx.Button(self.frame1, -1, 'Ok',wx.Point(50,50))
self.Bind(wx.EVT_BUTTON,self.ok1,Ok1)
def ok1(self,event):
self.frame2 = wx.Frame(None, wx.ID_ANY, 'sub Frame2',size=(300,150), style=wx.DEFAULT_FRAME_STYLE)
self.frame2.Show()
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
self.Bind(wx.EVT_BUTTON,self.ok2,Ok2)
def ok2(self,event):
self.frame3 = wx.Frame(None, wx.ID_ANY, 'sub Frame3',size=(300,150), style=wx.DEFAULT_FRAME_STYLE)
self.frame3.Show()
Ok3 = wx.Button(self.frame3, -1, 'Ok3',wx.Point(50,50))
self.frame2.Close()
del self.frame2
self.Bind(wx.EVT_BUTTON,self.ok3,Ok3)
def ok3(self,event):
print 'Button 3 clicked'
obj = frames(0)
obj.myframe()
obj.MainLoop()
Try This hope this will suit ur purpose.Am a Wx beginner hoping a lot more interaction from u guys
thanks
Maybe you can just add this line in your code.....
def OnOk(self,event):
self.dlg2 = Frame3(self,-1)
self.dlg2.Show(True)
self.Show(False) <----------- Add this
and the second Frame will hide when you open the third...
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...
| |