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 4844
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=(30 0,150), style=wx.DEFAUL T_FRAME_STYLE)
self.frame1.Sho w()
Ok1 = wx.Button(self. frame1, -1, 'Ok',wx.Point(5 0,50))
self.Bind(wx.EV T_BUTTON,self.o k1,Ok1)
def ok1(self,event) :
self.frame2 = wx.Frame(None, wx.ID_ANY, 'sub Frame2',size=(3 00,150), style=wx.DEFAUL T_FRAME_STYLE)
self.frame2.Sho w()
Ok2 = wx.Button(self. frame2, -1, 'Ok2',wx.Point( 50,50))
#self.frame1.Cl ose() if u want to hide the first frame too
#del self.frame1 if u want to delete the object instance
self.Bind(wx.EV T_BUTTON,self.o k2,Ok2)
def ok2(self,event) :
self.frame3 = wx.Frame(None, wx.ID_ANY, 'sub Frame3',size=(3 00,150), style=wx.DEFAUL T_FRAME_STYLE)
self.frame3.Sho w()
Ok3 = wx.Button(self. frame3, -1, 'Ok3',wx.Point( 50,50))
self.frame2.Clo se()
del self.frame2
self.Bind(wx.EV T_BUTTON,self.o k3,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 a ocx developed my me use vc6,this ocx works
fine in wxpython.
but you can see i only change this ocx with a new DICOM ocx and set up
eventClass,
|
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 much of what follows
to be incomprehensible. Is there a good tutorial for novices?
Here's the example that does not work. ("No module named frame")
import wx
|
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 small app to check my
Gmail. I want something that will just sit in my system tray checking
for new emails every ten minutes or so. As such, I have no need for an
actual window anywhere. So I'm wondering if I should still use a Frame
or not. ...
|
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.
But the "app.MainLoop()" in wxpython looks like conflicting with
the "while 1:" in socket server. After I commented the
"app.MainLoop()", everything is working except two things:
1. if I click anywhere on the screen with the mouse, the image is...
| |
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 "Run" button, the GUI would
close, and the 12 input variables would then be available for the rest
of the program.
So far, what I have been able to do is mostly a reverse engineering
job to get the frame to look right and return the text variable...
|
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 output from a .py that
is mainly matplotlib (a graph) in a section of the frame. How can I
get it to automatically run that script and place the resultant graph
in a panel?
Thanks
|
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 them, I pack them into a list...the problem
comes when I later try to extract them from the list! I don't know
why?
my code is as following:
import wx, socket
import thread
|
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 time yourself.
cheers,
Stef
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |