Files
Phoenix/demo/BannerWindow.py
Robin Dunn f039f7c367 Initial port of wxPython demo from Classic to Phoenix.
Pulled and squashed from https://github.com/RobinD42/Phoenix/pull/7
Thanks Metallicow!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@74199 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-06-13 06:06:29 +00:00

1 line
3.6 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wx
import wx.adv
phoenix = ("A phoenix is a mythical bird with a colorful plumage and a tail of gold and scarlet \n"
"(or purple and blue, according to some sources). It has a 500 to 1,000 year life-cycle, \n"
"near the end of which it builds itself a nest of myrrh twigs that then ignites; both nest \n"
"and bird burn fiercely and are reduced to ashes, from which a new, young phoenix or phoenix \n"
"egg arises, reborn anew to live again. The new phoenix is destined to live as long as its old \n"
"self. In some stories, the new phoenix embalms the ashes of its old self in an egg made of myrrh \n"
"and deposits it in the Egyptian city of Heliopolis (sun city in Greek). The bird was also said to \n"
"regenerate when hurt or wounded by a foe, thus being immortal and invincible - it is also said that \n"
"it can heal a person with a tear from its eyes and make them temporarily immune to death. \n"
"The Phoenix is a symbol of fire and divinity. ")
class MyBannerWindowFrame(wx.Frame):
def __init__(self, parent, id, title):
# ... create the frame itself ...
wx.Frame.__init__(self, parent, id, title)
# Set background Colour. This will become the black border
self.SetBackgroundColour(wx.BLACK)
pnxBmp = wx.Bitmap('bitmaps/phoenix_top.png')
bmpsz = pnxBmp.GetSize()
# Create and initialize the banner.
whitePanel = wx.Panel(self, -1, size=(-1, bmpsz[1]))
whitePanel.SetBackgroundColour(wx.WHITE)
# Create and initialize the 1st banner and define a bitmap.
banner1 = wx.adv.BannerWindow(whitePanel, dir=wx.BOTTOM)
banner1.SetBitmap(pnxBmp)
whiteSizer = wx.BoxSizer(wx.HORIZONTAL)
whiteSizer.Add(banner1, 1)
whitePanel.SetSizer(whiteSizer)
# Create and initialize the 2nd banner and define the gradient text.
banner2 = wx.adv.BannerWindow(self, dir=wx.TOP)
banner2.SetGradient(start='#FF8000', end='#FFFFFF')
banner2.SetText(phoenix, "")
# Layout
vsizer = wx.BoxSizer(wx.VERTICAL)
vsizer.Add(whitePanel, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 5)
vsizer.Add(banner2, 1, wx.BOTTOM | wx.LEFT | wx.RIGHT, 5)
self.SetSizer(vsizer)
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
b = wx.Button(self, -1, "Create and Show a BannerWindow", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
def OnButton(self, evt):
win = MyBannerWindowFrame(self, -1, "This is a BannerWindow")
win.SetSize((700, 350))
win.CenterOnParent(wx.BOTH)
win.Show(True)
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
#---------------------------------------------------------------------------
overview = """\
A simple banner window showing either a bitmap or text.
Banner windows can be used to present some overview of the current window contents
to the user in an aesthetically pleasant way. They are typically positioned along
the left or top edge of the window (although this class also supports right-aligned
and bottom-aligned banners) and show either a bitmap with a logo or a few lines of
text on a gradient-filled background.
"""
if __name__ == '__main__':
app = wx.App()
win = MyBannerWindowFrame(None, -1, "This is a BannerWindow")
win.SetSize((700, 350))
win.CenterOnParent(wx.BOTH)
win.Show(True)
app.MainLoop()