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*******autogenerated 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 6196
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))
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...
|
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:
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |