Dividers/headlines in the Tree view

Got a good idea? You can suggest new features here.
Post Reply
skribb
Experienced User
Posts: 162
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Dividers/headlines in the Tree view

Post by skribb » Sun May 21, 2017 11:29 am

... would be a good way to improve the organisation of macros
Automation is life.

Win7 64bit
EG: r1722

User avatar
kgschlosser
Site Admin
Posts: 3406
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Dividers/headlines in the Tree view

Post by kgschlosser » Sun May 21, 2017 5:46 pm

I have been working on a threaded version of the macros running. And I have been trying to think of a way to organize the actual log. And you have me an idea using the fold panel bar. But the fold panel bar could also be used to do the base elements of the tree. I have not figured out how to put a fold panel bar inside another fold panel bar. So something like nested folders would not work. And there is also no means to add an icon on it either. I remember the speed of it not being all that fantastic either I think that is due to the calculations being done for the position while it is rendering. I would have to look at it again.

But the macro/folder item could handle it's own rendering as well as drag and drop name changes things of that nature. This would be a cool idea because the bars them selves could change color if the macro is running. And could be double clicked to show any log information for that macro. I am still thinking in terms of the threaded events. This idea gave me some inspiration. I will have to work on it again.
If you like the work I have been doing then feel free to Image

skribb
Experienced User
Posts: 162
Joined: Thu Feb 12, 2015 7:22 pm
Location: Win7 64bit

Re: Dividers/headlines in the Tree view

Post by skribb » Sun May 21, 2017 11:10 pm

kgschlosser wrote:I have been working on a threaded version of the macros running. And I have been trying to think of a way to organize the actual log. And you have me an idea using the fold panel bar. But the fold panel bar could also be used to do the base elements of the tree. I have not figured out how to put a fold panel bar inside another fold panel bar. So something like nested folders would not work. And there is also no means to add an icon on it either. I remember the speed of it not being all that fantastic either I think that is due to the calculations being done for the position while it is rendering. I would have to look at it again.

But the macro/folder item could handle it's own rendering as well as drag and drop name changes things of that nature. This would be a cool idea because the bars them selves could change color if the macro is running. And could be double clicked to show any log information for that macro. I am still thinking in terms of the threaded events. This idea gave me some inspiration. I will have to work on it again.
Some questions:
  • what is a fold panel bar?
  • What do you mean by changing colors?
  • Folder nesting is working as of now, do you mean it would stop working with the implementations you were considering?
  • Would it not be possible to have like a dummy (empty) macro with another font color/background color to use as headlines?
Automation is life.

Win7 64bit
EG: r1722

User avatar
kgschlosser
Site Admin
Posts: 3406
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Dividers/headlines in the Tree view

Post by kgschlosser » Mon May 22, 2017 4:03 am

well there are some things that would have to worked out with it.. but here is an example of what a Fold Panel Bar is.

copy and paste this code into a python script and run the script

Be sure to check the Fold Panel menu at the top there are more setting in there

Code: Select all



import wx
from cStringIO import StringIO

import wx.lib.agw.foldpanelbar as fpb

def GetCollapsedIconData():
    return (
        '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06'
        '\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00'
        '\x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81'
        '\xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1'
        '\xc9J&\x96L"5lX\xcc\x0bl\xf7v\xb2\x7fZ\xa5\x98\xebU\xbdz\xf5\\\x9deW\x9f\xf8'
        'H\\\xbfO|{y\x9dT\x15P\x04\x01\x01UPUD\x84\xdb/7YZ\x9f\xa5\n\xce\x97aRU\x8a'
        '\xdc`\xacA\x00\x04P\xf0!0\xf6\x81\xa0\xf0p\xff9\xfb\x85\xe0|\x19&T)K\x8b\x18'
        '\xf9\xa3\xe4\xbe\xf3\x8c^#\xc9\xd5\n\xa8*\xc5?\x9a\x01\x8a\xd2b\r\x1cN\xc3'
        '\x14\t\xce\x97a\xb2F0Ks\xd58\xaa\xc6\xc5\xa6\xf7\xdfya\xe7\xbdR\x13M2\xf9'
        '\xf9qKQ\x1fi\xf6-\x00~T\xfac\x1dq#\x82,\xe5q\x05\x91D\xba@\xefj\xba1\xf0\xdc'
        'zzW\xcff&\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H'
        '\x18\x15\x84\xa0q@]\xe54\x8d\xa3\xedf\x05M\xe3\xd8Uy\xc4\x15\x8d\xf5\xd7\x8b'
        '~\x82\x0fh\x0e"\xb0\xad,\xee\xb8c\xbb\x18\xe7\x8e;6\xa5\x89\x04\xde\xff\x1c'
        '\x16\xef\xe0p\xfa>\x19\x11\xca\x8d\x8d\xe0\x93\x1b\x01\xd8m\xf3(;x\xa5\xef='
        '\xb7w\xf3\x1d$\x7f\xc1\xe0\xbd\xa7\xeb\xa0(,"Kc\x12\xc1+\xfd\xe8\tI\xee\xed)'
        '\xbf\xbcN\xc1{D\x04k\x05#\x12\xfd\xf2a\xde[\x81\x87\xbb\xdf\x9cr\x1a\x87\xd3'
        '0)\xba>\x83\xd5\xb97o\xe0\xaf\x04\xff\x13?\x00\xd2\xfb\xa9`z\xac\x80w\x00'
        '\x00\x00\x00IEND\xaeB`\x82'
    )


def GetCollapsedIconBitmap():
    return wx.BitmapFromImage(GetCollapsedIconImage())


def GetCollapsedIconImage():
    import cStringIO


    stream = cStringIO.StringIO(GetCollapsedIconData())
    return wx.ImageFromStream(stream)


# ----------------------------------------------------------------------
def GetExpandedIconData():
    return (
        '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06'
        '\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00'
        '\x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI'
        '\xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!'
        '\x95\x0c\r\r\x1fK\x81g\xb2\x99\x84\xb4\x0fY\xd6\xbb\xc7\xf7>=\'Iz\xc3\xbcv'
        '\xfbn\xb8\x9c\x15 \xe7\xf3\xc7\x0fw\xc9\xbc7\x99\x03\x0e\xfbn0\x99F+\x85R'
        '\x80RH\x10\x82\x08\xde\x05\x1ef\x90+\xc0\xe1\xd8\ryn\xd0Z-\\A\xb4\xd2\xf7'
        '\x9e\xfbwoF\xc8\x088\x1c\xbbae\xb3\xe8y&\x9a\xdf\xf5\xbd\xe7\xfem\x84\xa4'
        '\x97\xccYf\x16\x8d\xdb\xb2a]\xfeX\x18\xc9s\xc3\xe1\x18\xe7\x94\x12cb\xcc\xb5'
        '\xfa\xb1l8\xf5\x01\xe7\x84\xc7\xb2Y@\xb2\xcc0\x02\xb4\x9a\x88%\xbe\xdc\xb4'
        '\x9e\xb6Zs\xaa74\xadg[6\x88<\xb7]\xc6\x14\x1dL\x86\xe6\x83\xa0\x81\xba\xda'
        '\x10\x02x/\xd4\xd5\x06\r\x840!\x9c\x1fM\x92\xf4\x86\x9f\xbf\xfe\x0c\xd6\x9ae'
        '\xd6u\x8d \xf4\xf5\x165\x9b\x8f\x04\xe1\xc5\xcb\xdb$\x05\x90\xa97@\x04lQas'
        '\xcd*7\x14\xdb\x9aY\xcb\xb8\\\xe9E\x10|\xbc\xf2^\xb0E\x85\xc95_\x9f\n\xaa/'
        '\x05\x10\x81\xce\xc9\xa8\xf6><G\xd8\xed\xbbA)X\xd9\x0c\x01\x9a\xc6Q\x14\xd9h'
        '[\x04\xda\xd6c\xadFkE\xf0\xc2\xab\xd7\xb7\xc9\x08\x00\xf8\xf6\xbd\x1b\x8cQ'
        '\xd8|\xb9\x0f\xd3\x9a\x8a\xc7\x08\x00\x9f?\xdd%\xde\x07\xda\x93\xc3{\x19C'
        '\x8a\x9c\x03\x0b8\x17\xe8\x9d\xbf\x02.>\x13\xc0n\xff{PJ\xc5\xfdP\x11""<\xbc'
        '\xff\x87\xdf\xf8\xbf\xf5\x17FF\xaf\x8f\x8b\xd3\xe6K\x00\x00\x00\x00IEND\xaeB'
        '`\x82'
    )


def GetExpandedIconBitmap():
    return wx.BitmapFromImage(GetExpandedIconImage())


def GetExpandedIconImage():
    stream = StringIO(GetExpandedIconData())
    return wx.ImageFromStream(stream)

class FoldPanelBar(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(
            self,
            eg.document.frame,
            -1,
            size=(700, 650),
            style=wx.DEFAULT_FRAME_STYLE
        )
        self._flags = 0
        self._pnl = None
        self.SetMenuBar(self.CreateMenuBar())
        self.Bind(wx.EVT_SCROLL, self.OnSlideColour)
        self.ReCreateFoldPanel(0)

    def OnQuit(self, event):
        self.Destroy()


    def ReCreateFoldPanel(self, fpb_flags):

        # delete earlier panel
        self.DestroyChildren()

        # recreate the foldpanelbar

        self._pnl = fpb.FoldPanelBar(
            self,
            -1,
            wx.DefaultPosition,
            wx.Size(-1, -1),
            agwStyle=fpb_flags
        )

        Images = wx.ImageList(16, 16)
        Images.Add(GetExpandedIconBitmap())
        Images.Add(GetCollapsedIconBitmap())

        item = self._pnl.AddFoldPanel(
            "Caption Colours",
            collapsed=False,
            foldIcons=Images
        )

        self._pnl.AddFoldPanelWindow(item,
            wx.StaticText(item, -1, "Set Caption Bar Color #1"),
            fpb.FPB_ALIGN_WIDTH, 5, 20)

        # RED colour spin control
        self._rslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._rslider1,
            fpb.FPB_ALIGN_WIDTH,
            2,
            20
        )

        # GREEN colour spin control
        self._gslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._gslider1,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        # BLUE colour spin control
        self._bslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._bslider1,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        self._pnl.AddFoldPanelSeparator(item)

        self._pnl.AddFoldPanelWindow(
            item,
            wx.StaticText(item, -1, "Set Caption Bar Color #2"),
            fpb.FPB_ALIGN_WIDTH,
            5,
            20
        )

        # RED colour spin control
        self._rslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._rslider2,
            fpb.FPB_ALIGN_WIDTH,
            2,
            20
        )

        # GREEN colour spin control
        self._gslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._gslider2,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        # BLUE colour spin control
        self._bslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._bslider2,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        self._pnl.AddFoldPanelSeparator(item)

        self._pnl.AddFoldPanelWindow(
            item,
            wx.StaticText(item, -1, "Set the Font Color"),
            fpb.FPB_ALIGN_WIDTH,
            5,
            20
        )

        # RED colour spin control
        self._rslider3 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._rslider3,
            fpb.FPB_ALIGN_WIDTH,
            2,
            20
        )

        # GREEN colour spin control
        self._gslider3 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._gslider3,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        # BLUE colour spin control
        self._bslider3 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(
            item,
            self._bslider3,
            fpb.FPB_ALIGN_WIDTH,
            0,
            20
        )

        self._pnl.AddFoldPanelSeparator(item)

        button1 = wx.Button(item, wx.ID_ANY, "Apply To All")
        button1.Bind(wx.EVT_BUTTON, self.OnExpandMe)
        self._pnl.AddFoldPanelWindow(item, button1)

        # read back current gradients and set the sliders
        # for the colour which is now taken as default

        style = self._pnl.GetCaptionStyle(item)
        col = style.GetFirstColour()
        

        self._rslider1.SetValue(col.Red())
        self._gslider1.SetValue(col.Green())
        self._bslider1.SetValue(col.Blue())

        col = style.GetSecondColour()
        self._rslider2.SetValue(col.Red())
        self._gslider2.SetValue(col.Green())
        self._bslider2.SetValue(col.Blue())

        font_col = style.GetCaptionColour()
        self._rslider3.SetValue(font_col.Red())
        self._gslider3.SetValue(font_col.Green())
        self._bslider3.SetValue(font_col.Blue())

        # put down some caption styles from which the user can
        # select to show how the current or all caption bars will look like

        item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images)

        self.ID_USE_VGRADIENT = wx.NewId()
        self.ID_USE_HGRADIENT = wx.NewId()
        self.ID_USE_SINGLE = wx.NewId()
        self.ID_USE_RECTANGLE = wx.NewId()
        self.ID_USE_FILLED_RECTANGLE = wx.NewId()

        currStyle = wx.RadioButton(
            item,
            self.ID_USE_VGRADIENT,
            "&Vertical Gradient"
        )
        self._pnl.AddFoldPanelWindow(
            item,
            currStyle,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )

        currStyle.SetValue(True)

        radio1 = wx.RadioButton(
            item,
            self.ID_USE_HGRADIENT,
            "&Horizontal Gradient"
        )
        radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour")
        radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box")
        radio4 = wx.RadioButton(
            item,
            self.ID_USE_FILLED_RECTANGLE,
            "&Filled Rectangle Box"
        )

        currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)

        self._pnl.AddFoldPanelWindow(
            item,
            radio1,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )
        self._pnl.AddFoldPanelWindow(
            item,
            radio2,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )
        self._pnl.AddFoldPanelWindow(
            item,
            radio3,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )
        self._pnl.AddFoldPanelWindow(
            item,
            radio4,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )

        self._pnl.AddFoldPanelSeparator(item)

        self._single = wx.CheckBox(item, -1, "&Only This Caption")
        self._pnl.AddFoldPanelWindow(
            item,
            self._single,
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )

        # one more panel to finish it

        cs = fpb.CaptionBarStyle()
        cs.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE)

        item = self._pnl.AddFoldPanel(
            "Misc Stuff",
            collapsed=True,
            foldIcons=Images,
            cbstyle=cs
        )

        button2 = wx.Button(item, wx.NewId(), "Collapse All")
        self._pnl.AddFoldPanelWindow(item, button2)
        self._pnl.AddFoldPanelWindow(
            item,
            wx.StaticText(item, -1, "Enter Some Comments"),
            fpb.FPB_ALIGN_WIDTH,
            5,
            20
        )
        self._pnl.AddFoldPanelWindow(
            item,
            wx.TextCtrl(item, -1, "Comments"),
            fpb.FPB_ALIGN_WIDTH,
            fpb.FPB_DEFAULT_SPACING,
            10
        )

        button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe)
        self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4]

        self.Refresh()

    def OnCreateBottomStyle(self, event):

        # recreate with style collapse to bottom, which means
        # all panels that are collapsed are placed at the bottom,
        # or normal

        if event.IsChecked():
            self.GetMenuBar().Check(self._singlestyle, False)
            self.GetMenuBar().Check(self._exclusivestyle, False)
            self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD
            self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD
            self._flags = self._flags | fpb.FPB_COLLAPSE_TO_BOTTOM
        else:
            self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM

        self.ReCreateFoldPanel(self._flags)

    def OnCreateNormalStyle(self, event):

        # recreate with style where only one panel at the time is
        # allowed to be opened

        if event.IsChecked():
            self.GetMenuBar().Check(self._bottomstyle, False)
            self.GetMenuBar().Check(self._exclusivestyle, False)
            self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD
            self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM
            self._flags = self._flags | fpb.FPB_SINGLE_FOLD
        else:
            self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD

        self.ReCreateFoldPanel(self._flags)

    def OnCreateExclusiveStyle(self, event):

        # recreate with style where only one panel at the time is
        # allowed to be opened and the others are collapsed to bottom

        if event.IsChecked():
            self.GetMenuBar().Check(self._singlestyle, False)
            self.GetMenuBar().Check(self._bottomstyle, False)
            self._flags = self._flags & ~fpb.FPB_SINGLE_FOLD
            self._flags = self._flags & ~fpb.FPB_COLLAPSE_TO_BOTTOM
            self._flags = self._flags | fpb.FPB_EXCLUSIVE_FOLD
        else:
            self._flags = self._flags & ~fpb.FPB_EXCLUSIVE_FOLD

        self.ReCreateFoldPanel(self._flags)

    def OnCollapseMe(self, event):

        for i in range(0, self._pnl.GetCount()):
            item = self._pnl.GetFoldPanel(i)
            self._pnl.Collapse(item)

    def OnExpandMe(self, event):

        col1 = wx.Colour(
            self._rslider1.GetValue(),
            self._gslider1.GetValue(),
            self._bslider1.GetValue()
        )
        col2 = wx.Colour(
            self._rslider2.GetValue(),
            self._gslider2.GetValue(),
            self._bslider2.GetValue()
        )

        col3 = wx.Colour(
            self._rslider3.GetValue(),
            self._gslider3.GetValue(),
            self._bslider3.GetValue()
        )

        style = fpb.CaptionBarStyle()

        style.SetFirstColour(col1)
        style.SetSecondColour(col2)
        style.SetCaptionColour(col3)

        counter = 0
        for items in self.radiocontrols:
            if items.GetValue():
                break
            counter = counter + 1

        if counter == 0:
            mystyle = fpb.CAPTIONBAR_GRADIENT_V
        elif counter == 1:
            mystyle = fpb.CAPTIONBAR_GRADIENT_H
        elif counter == 2:
            mystyle = fpb.CAPTIONBAR_SINGLE
        elif counter == 3:
            mystyle = fpb.CAPTIONBAR_RECTANGLE
        else:
            mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE

        style.SetCaptionStyle(mystyle)
        self._pnl.ApplyCaptionStyleAll(style)

    def OnSlideColour(self, event):

        col1 = wx.Colour(
            self._rslider1.GetValue(),
            self._gslider1.GetValue(),
            self._bslider1.GetValue()
        )
        col2 = wx.Colour(
            self._rslider2.GetValue(),
            self._gslider2.GetValue(),
            self._bslider2.GetValue()
        )
        col3 = wx.Colour(
            self._rslider3.GetValue(),
            self._gslider3.GetValue(),
            self._bslider3.GetValue()
        )

        style = fpb.CaptionBarStyle()

        counter = 0
        for items in self.radiocontrols:
            if items.GetValue():
                break

            counter = counter + 1

        if counter == 0:
            mystyle = fpb.CAPTIONBAR_GRADIENT_V
        elif counter == 1:
            mystyle = fpb.CAPTIONBAR_GRADIENT_H
        elif counter == 2:
            mystyle = fpb.CAPTIONBAR_SINGLE
        elif counter == 3:
            mystyle = fpb.CAPTIONBAR_RECTANGLE
        else:
            mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE

        style.SetFirstColour(col1)
        style.SetSecondColour(col2)
        style.SetCaptionColour(col3)
        style.SetCaptionStyle(mystyle)

        item = self._pnl.GetFoldPanel(0)
        self._pnl.ApplyCaptionStyle(item, style)

    def OnStyleChange(self, event):

        style = fpb.CaptionBarStyle()

        eventid = event.GetId()

        if eventid == self.ID_USE_HGRADIENT:
            style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_H)

        elif eventid == self.ID_USE_VGRADIENT:
            style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V)

        elif eventid == self.ID_USE_SINGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_SINGLE)

        elif eventid == self.ID_USE_RECTANGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE)

        elif eventid == self.ID_USE_FILLED_RECTANGLE:
            style.SetCaptionStyle(fpb.CAPTIONBAR_FILLED_RECTANGLE)

        else:
            raise "ERROR: Undefined Style Selected For CaptionBar: " + repr(
                eventid
            )

        col1 = wx.Colour(
            self._rslider1.GetValue(),
            self._gslider1.GetValue(),
            self._bslider1.GetValue()
        )
        col2 = wx.Colour(
            self._rslider2.GetValue(),
            self._gslider2.GetValue(),
            self._bslider2.GetValue()
        )

        col3 = wx.Colour(
            self._rslider3.GetValue(),
            self._gslider3.GetValue(),
            self._bslider3.GetValue()
        )

        style.SetFirstColour(col1)
        style.SetSecondColour(col2)
        style.SetCaptionColour(col3)
        
        if self._single.GetValue():
            item = self._pnl.GetFoldPanel(1)
            self._pnl.ApplyCaptionStyle(item, style)
        else:
            self._pnl.ApplyCaptionStyleAll(style)

    def CreateMenuBar(self, with_window=False):

        # Make a menubar
        file_menu = wx.Menu()

        FPBTEST_QUIT = wx.NewId()
        FPBTEST_REFRESH = wx.NewId()
        FPB_BOTTOM_FOLD = wx.NewId()
        FPB_SINGLE_FOLD = wx.NewId()
        FPB_EXCLUSIVE_FOLD = wx.NewId()

        file_menu.Append(FPBTEST_QUIT, "&Exit")

        option_menu = None

        if with_window:
            # Dummy option
            option_menu = wx.Menu()
            option_menu.Append(FPBTEST_REFRESH, "&Refresh picture")

        # make fold panel menu

        fpb_menu = wx.Menu()
        fpb_menu.AppendCheckItem(FPB_BOTTOM_FOLD,
            "Create with &fpb.FPB_COLLAPSE_TO_BOTTOM")

        # Now Implemented!
        fpb_menu.AppendCheckItem(FPB_SINGLE_FOLD,
            "Create with &fpb.FPB_SINGLE_FOLD")

        # Now Implemented!
        fpb_menu.AppendCheckItem(FPB_EXCLUSIVE_FOLD,
            "Create with &fpb.FPB_EXCLUSIVE_FOLD")

        menu_bar = wx.MenuBar()

        menu_bar.Append(file_menu, "&File")
        menu_bar.Append(fpb_menu, "&FoldPanel")

        if option_menu:
            menu_bar.Append(option_menu, "&Options")

        self.Bind(wx.EVT_MENU, self.OnQuit, id=FPBTEST_QUIT)
        self.Bind(wx.EVT_MENU, self.OnCreateBottomStyle, id=FPB_BOTTOM_FOLD)
        self.Bind(wx.EVT_MENU, self.OnCreateNormalStyle, id=FPB_SINGLE_FOLD)
        self.Bind(wx.EVT_MENU, self.OnCreateExclusiveStyle,
            id=FPB_EXCLUSIVE_FOLD)

        self._bottomstyle = FPB_BOTTOM_FOLD
        self._singlestyle = FPB_SINGLE_FOLD
        self._exclusivestyle = FPB_EXCLUSIVE_FOLD

        return menu_bar

eg.globals.FoldPanelBar = FoldPanelBar()
eg.globals.FoldPanelBar.CenterOnParent()
eg.globals.FoldPanelBar.Show()
eg.globals.FoldPanelBar.Raise()


If you like the work I have been doing then feel free to Image

Post Reply