Create new frame in DC context

Hi!

I'm learning Python to do a project of ini parser/merger. I've take wxPython
for GUI interface.
I've created the code for viewing current content of ini file (color config of
a program) and my page is so full in 1024x768 that I have no place for menu.

Then I have created an other file acting as menu, with buttons. But now How to
launch other file within this "menu file"?

Here is my menu code :

class MainFrame( wx.Frame ):
  def __init__( self, imageFilename ):
    wx.Frame.__init__( self, None, -1 )
    self.SetBackgroundColour('#EFEFEF')
    self.SetPosition( (600, 15) )
    self.SetClientSize( (500, 325) )
    png = wx.Image(opj(imageFilename), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    wx.StaticBitmap(self, 0, png, (20, 20), (225, 260))
    # Les bouttons
    self.button = wx.Button(self, label="See Actual Colors", size=(125,35),
pos=(350, 100))
    self.Bind(wx.EVT_PAINT, self.OnPaint, self.button)
# Some other menu items....

  def OnPaint(self, evt):
    dc = wx.PaintDC(self)
    self.PrepareDC(dc)
    self.Draw(dc)

  def Draw(self, dc, rgn=None, vs=None):
    print 'On a trouve Cumulus'
    self.SetBackgroundColour(wx.Colour(0,128,0))
    dc = wx.PaintDC(self)
    self.PrepareDC(dc)
    dc.SetTextForeground("BLACK")
    # make an interesting background...
    dc.SetPen(wx.MEDIUM_GREY_PEN)
    
    brush = wx.Brush('#000000', wx.TRANSPARENT)
    dc.SetBrush(brush)
    dc.SetFont(self.font2)
    dc.SetTextForeground("#666666")
    dc.DrawText("Cumulus main screen", 22, 11)

class MainApp( wx.App ):
    def __init__( self, imageFilename=None, redirect=False ):
        wx.App.__init__( self, redirect )
        appFrame = MainFrame( imageFilename )
        appFrame.Show()
        
    #some more lines... before launcher

···

#------------------------------------------------------------------------------
if __name__ == '__main__':
    imageFilename = 'images/station.png'
    app = MainApp(imageFilename)
    app.MainLoop()
#end if

Then, how to launch other(s) frame in dc context?

Thanks for your help

Jacques

May be with something like attached.

Although there are drawbacks: I didn't find any other solution than
a button to recover the new filename (EVT_FILEPICKER_CHANGED is only
triggered once at Frame2 opening (WTF?) and never after:(

I also didn't find any manner to refer to the parent: in Frame2,
self.parent don't exist (?!); so I used an ugly global var to
do that.

HIH

2_windows_2nd_pass_info_to_parent_manualadd.py (5.55 KB)

···

On Sat, 17 Dec 2011 17:48:06 +0000 (UTC) Jacques <jacques.desroches@meteodu quebec.com> wrote:

I'm learning Python to do a project of ini parser/merger. I've take wxPython
for GUI interface.
I've created the code for viewing current content of ini file (color config of
a program) and my page is so full in 1024x768 that I have no place for menu.

Then I have created an other file acting as menu, with buttons. But now How to
launch other file within this "menu file"?

--
Ninety percent of everything is crap.
    -- Theodore Sturgeon

I'm learning Python to do a project of ini parser/merger. I've take wxPython
for GUI interface.
I've created the code for viewing current content of ini file (color config of
a program) and my page is so full in 1024x768 that I have no place for menu.

Then I have created an other file acting as menu, with buttons. But now How to
launch other file within this "menu file"?

May be with something like attached.

Although there are drawbacks: I didn't find any other solution than
a button to recover the new filename (EVT_FILEPICKER_CHANGED is only
triggered once at Frame2 opening (WTF?) and never after:(

It works fine here. What platform and version? How are you binding the event?

I also didn't find any manner to refer to the parent: in Frame2,
self.parent don't exist (?!); so I used an ugly global var to
do that.

There is self.GetParent() or the self.Parent property.

···

On 12/18/11 11:50 AM, Jean-Yves F. Barbier wrote:

On Sat, 17 Dec 2011 17:48:06 +0000 (UTC) > Jacques<jacques.desroches@meteodu quebec.com> wrote:

--
Robin Dunn
Software Craftsman

To put the other answers in a nutshell, you simply have to Bind and handle the event that you want to cause the other frame to be opened, and then create an instance of it in that handler and call its Show method.

···

On 12/17/11 9:48 AM, Jacques wrote:

Hi!

I'm learning Python to do a project of ini parser/merger. I've take wxPython
for GUI interface.
I've created the code for viewing current content of ini file (color config of
a program) and my page is so full in 1024x768 that I have no place for menu.

Then I have created an other file acting as menu, with buttons. But now How to
launch other file within this "menu file"?

Here is my menu code :

Then, how to launch other(s) frame in dc context?

--
Robin Dunn
Software Craftsman

>
> Although there are drawbacks: I didn't find any other solution than
> a button to recover the new filename (EVT_FILEPICKER_CHANGED is only
> triggered once at Frame2 opening (WTF?) and never after:(

It works fine here. What platform and version? How are you binding the
event?

Linux Debian sid, V. 2.8.12.1-5
Creating FilePickerCtrl with 666 ID &
self.filePickerF2Bind(wx.EVT_FILEPICKER_CHANGED, self.myMethod(666))

> I also didn't find any manner to refer to the parent: in Frame2,
> self.parent don't exist (?!); so I used an ugly global var to
> do that.

There is self.GetParent() or the self.Parent property.

Ok, I try that.

···

On Mon, 19 Dec 2011 09:34:15 -0800 Robin Dunn <robin@alldunn.com> wrote:

--
Windows without the X is like making love without a partner.
    -- MaDsen Wikholm, mwikholm@at8.abo.fi