I have 2 frames and on a button click event on frame 1 I want to hide frame 1 and show frame 2
I can hide frame 1 but frame 2 does not appear.
I would really appreciate all the help.
I am learning progamming so please go easy on the terminologies
Heres the code
***********app1 .py*******autog enerated code -
import wx
-
-
import Frame2
-
import Frame1
-
-
modules ={'Frame1': [0, '', u'Frame1.py'], 'Frame2': [2, 'Second frame', u'Frame2.py']}
-
-
-
class BoaApp(wx.App):
-
def OnInit(self):
-
self.main = Frame1.create(None)
-
self.main.Show()
-
self.SetTopWindow(self.main)
-
return True
-
-
def main():
-
application = BoaApp(0)
-
application.MainLoop()
-
-
if __name__ == '__main__':
-
main()
*************** Frame1.py****** *************** **** -
-
#Boa:Frame:Frame1
-
-
import wx
-
import Frame2
-
-
def create(parent):
-
return Frame1(parent)
-
-
[wxID_FRAME1, wxID_FRAME1BUTTON1] = [wx.NewId() for _init_ctrls in range(4)]
-
-
class Frame1(wx.Frame):
-
def _init_ctrls(self, prnt):
-
-
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
-
pos=wx.Point(423, 374), size=wx.Size(374, 226),
-
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
-
self.SetClientSize(wx.Size(366, 199))
-
-
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1,
-
label='Hide frame1 and show frame 2', name='button1', parent=self,
-
pos=wx.Point(56, 56), size=wx.Size(270, 47), style=0)
-
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
-
id=wxID_FRAME1BUTTON1)
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
-
def OnButton1Button(self, event):
-
-
#frm1=self.Frame1()
-
self.Hide() #Frame1 does get hidden but
-
frm2 = Frame2()
-
frm2.Show() #Frame 2 does not appear
*************** *************** Frame 2************** ********** -
-
class Frame2(wx.Frame):
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prnt,
-
pos=wx.Point(451, 306), size=wx.Size(504, 360),
-
style=wx.DEFAULT_FRAME_STYLE, title='Frame2')
-
self.SetClientSize(wx.Size(496, 333))
-
-
self.grid1 = wx.grid.Grid(id=wxID_FRAME2GRID1, name='grid1',
-
parent=self, pos=wx.Point(16, 48), size=wx.Size(472, 272),
-
style=0)
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
self.grid1.CreateGrid(5,5)
-
self.grid1.Show()
-
-
for i in range (0, 4):
-
for j in range (0, 4):
-
self.grid1.SetCellValue(i, j, ("%s,%s") % (i, j))
3 6217 bartonc 6,596
Recognized Expert Expert
This should work. Your way may also have worked if you had given the "parent" argument to frame2(). I'm thinking that you are getting an error printed in the Boa Constructor report area, but it is collapsed. - #Boa:Frame:Frame1
-
-
import wx
-
import Frame2
-
-
def create(parent):
-
return Frame1(parent)
-
-
[wxID_FRAME1, wxID_FRAME1BUTTON1] = [wx.NewId() for _init_ctrls in range(4)]
-
-
class Frame1(wx.Frame):
-
def _init_ctrls(self, prnt):
-
-
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
-
pos=wx.Point(423, 374), size=wx.Size(374, 226),
-
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
-
self.SetClientSize(wx.Size(366, 199))
-
-
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1,
-
label='Hide frame1 and show frame 2', name='button1', parent=self,
-
pos=wx.Point(56, 56), size=wx.Size(270, 47), style=0)
-
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
-
id=wxID_FRAME1BUTTON1)
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
# it's OK to edit this. In fact, this is the place TO edit in BC
-
# !!! correction. need module.class for creation !!!
-
self.frm2 = Frame2.Frame2(self) # frame1 is the parent of frame2
-
-
def OnButton1Button(self, event):
-
-
#frm1=self.Frame1()
-
self.Hide() #Frame1 does get hidden but
-
self.frm2.Show() #Frame 2 should appear
*************** *************** Frame 2************** ********** -
-
class Frame2(wx.Frame):
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.Frame.__init__(self, id=wxID_FRAME2, name='', parent=prnt,
-
pos=wx.Point(451, 306), size=wx.Size(504, 360),
-
style=wx.DEFAULT_FRAME_STYLE, title='Frame2')
-
self.SetClientSize(wx.Size(496, 333))
-
-
self.grid1 = wx.grid.Grid(id=wxID_FRAME2GRID1, name='grid1',
-
parent=self, pos=wx.Point(16, 48), size=wx.Size(472, 272),
-
style=0)
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
self.grid1.CreateGrid(5,5)
-
self.grid1.Show()
-
-
for i in range (0, 4):
-
for j in range (0, 4):
-
self.grid1.SetCellValue(i, j, ("%s,%s") % (i, j))
bartonc 6,596
Recognized Expert Expert
Here are a couple of tested frames with some neat tricks thrown in: - #Boa:Frame:Frame1
-
-
import wx
-
import Frame2
-
-
def create(parent):
-
return Frame1(parent)
-
-
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1,
-
] = [wx.NewId() for _init_ctrls in range(3)]
-
-
class Frame1(wx.Frame):
-
def _init_coll_boxSizer1_Items(self, parent):
-
# generated method, don't edit
-
-
parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND)
-
-
def _init_sizers(self):
-
# generated method, don't edit
-
self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
-
-
self._init_coll_boxSizer1_Items(self.boxSizer1)
-
-
self.SetSizer(self.boxSizer1)
-
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(110, 110),
-
size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
-
self.SetClientSize(wx.Size(392, 223))
-
-
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0),
-
size=wx.Size(392, 223), style=wx.TAB_TRAVERSAL)
-
-
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1', name='button1',
-
parent=self.panel1, pos=wx.Point(168, 96), size=wx.Size(75, 23), style=0)
-
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1, id=wxID_FRAME1BUTTON1)
-
-
self._init_sizers()
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
self.childFrame = Frame2.Frame2(self)
-
-
def OnButton1(self, event):
-
pos = self.GetPosition()
-
self.childFrame.Move(pos)
-
self.childFrame.Show()
-
self.Hide()
-
- #Boa:Frame:Frame2
-
-
import wx
-
-
def create(parent):
-
return Frame2(parent)
-
-
[wxID_FRAME2, wxID_FRAME2BUTTON1, wxID_FRAME2PANEL1,
-
] = [wx.NewId() for _init_ctrls in range(3)]
-
-
class Frame2(wx.Frame):
-
def _init_coll_boxSizer1_Items(self, parent):
-
# generated method, don't edit
-
-
parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND)
-
-
def _init_sizers(self):
-
# generated method, don't edit
-
self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
-
-
self._init_coll_boxSizer1_Items(self.boxSizer1)
-
-
self.SetSizer(self.boxSizer1)
-
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.Frame.__init__(self, id=wxID_FRAME2, name='Frame2', parent=prnt, pos=wx.Point(132, 132),
-
size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame2')
-
self.SetClientSize(wx.Size(392, 223))
-
-
self.panel1 = wx.Panel(id=wxID_FRAME2PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0),
-
size=wx.Size(392, 223), style=wx.TAB_TRAVERSAL)
-
-
self.button1 = wx.Button(id=wxID_FRAME2BUTTON1, label='button1', name='button1',
-
parent=self.panel1, pos=wx.Point(144, 88), size=wx.Size(75, 23), style=0)
-
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1, id=wxID_FRAME2BUTTON1)
-
-
self._init_sizers()
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
self.parent = parent
-
-
def OnButton1(self, event):
-
pos = self.GetPosition()
-
self.parent.Move(pos)
-
self.parent.Show()
-
self.Hide()
-
Thank you very much, i really appreciate the help....The code did work and I did see the Frame 2....But I also discovered MDI frames so I will try to impliment the whole thing in it...But still thank for the help....
Later
Apoorva
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Equis Uno |
last post by:
Hi,
I'm trying to run some Python software I downloaded off of sf.net.
It's called Boa.
It uses wxPython.
It appears my install of Python cannot see my install of wxPython.
|
by: Simon Erikson |
last post by:
Hello:
I would like to build an app consisting of a "root" frame that can
contain an arbitrary number of child frames (the user will click to
create them). Each of these child frames needs the full functionality
of a frame (title,menu,status bars, min,max,close icons, scroll bars,
sizing, moving). In addition, the user must be able to create
grandchild frames within these child frames, to an arbitrary depth (in
practice limited to 10...
|
by: Grant Edwards |
last post by:
I've decided to learn wxPython, and I'm afraid I just don't
grok the whole "id" thing where you have to pull unique
integers out of your, er, the air and then use those to refer
to objects:
From whe wxPython wiki examples:
self.button =wxButton(self, 10, "Save", wxPoint(200, 325))
EVT_BUTTON(self, 10, self.OnClick)
|
by: Erik Johnson |
last post by:
I am looking for some input on GUI libraries. I want to build a
Python-driven GUI, but don't really understand the playing field very well.
I have generally heard good things about wxPython. I happen to already own
John Grayson's book about Tkinter programming, so that is rather handy if I
decide to use Tkinter. I have done some things slightly more involved than
"Hello World" in Tkinter - I have never used wxPython. So, basically the...
|
by: dr_tyson |
last post by:
I am trying to embed images into a wxPython app (created using Boa
Constructor), but have not been able to do so. I know how to embed
plots, but images seem to be a problem. I've tried using code analogous
to the example given at the Matplotlib website to no avail. If anybody
has been successful at this could you please post some sample code?
That would be greatly appreciated. Thanks!
Randy
| |
by: rodmc |
last post by:
I am totally new to Python and WxPython and need to write an
application which can open up an external windows from a plug-in within
GAIM (using pyGAIM). I have managed to hack some code together from
what little I have covered so far, however GAIM refuses to open until I
have closed the extra window. I appreciate this is probably a simple
point but I would be grateful for any advice people can offer on how I
can make them both appear so...
|
by: Glurt Wuntal |
last post by:
I am a newbie with Python. It's a great language, but I would like to be
able to present a simple gui menu for some of my scripts; something better
than using 'raw_input' prompts.
Any recommendations for a program that will allow me to create the gui
screens? Something useable in Linux.
thanks.
|
by: Robin Dunn |
last post by:
Announcing
----------
The 2.6.3.0 release of wxPython is now available for download at
http://wxpython.org/download.php. There have been many enhancements
and fixes implemented in this version, many of which are listed
below and at http://wxpython.org/recentchanges.php.
What is wxPython?
|
by: Andrea Gavana |
last post by:
Hi Diez & All,
Do you mind explaining "why" you find it *buttugly*? I am asking just
out of curiosity, obviously. I am so biased towards wxPython that I
won't make any comment on this thread in particular, but I am curious
to know why some people find it "ugly" or "bad" or whatever. It has
its own bugs and missing features, of course, but it is one of the
major GUI player in the arena, together with PyQt and PyGTK.
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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...
| |