List Info

Thread: having trouble with Toolbook




having trouble with Toolbook
country flaguser name
United States
2007-10-19 11:04:52
I'm having trouble with Toolbook. I can't see the image
list, below is my 
code:


ID_PLANNER_DAY_MODE = wx.NewId()
ID_PLANNER_WEEK_MODE = wx.NewId()
ID_PLANNER_MONTH_MODE = wx.NewId()

images = (
	'gnome-day.png', 
	'gnome-week.png', 
	'gnome-month.png'
)

class PlannerToolbook(wx.Toolbook):

    def __init__(self, *args, **kwargs):
        wx.Toolbook.__init__(self, *args, **kwargs)

        il = wx.ImageList(22, 22)
        for i in images:
            try:
                il.AddIcon(wx.Image(i, wx.BITMAP_TYPE_PNG))
            except:
                print "Error adding image to the
ImageList"

        self.AssignImageList(il)

        self.day_mode = DayModePanel(self, wx.GROW)
        self.week_mode = WeekModePanel(self, wx.GROW)
        self.month_mode = MonthModePanel(self, wx.GROW)

        self.AddPage(self.day_mode, "Daily",
ID_PLANNER_DAY_MODE)
        self.AddPage(self.week_mode, "Weekly",
ID_PLANNER_WEEK_MODE)
        self.AddPage(self.month_mode, "Monthly",
ID_PLANNER_MONTH_MODE)



What am I doing wrong?


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


Re: having trouble with Toolbook
country flaguser name
United States
2007-10-19 13:17:56
Patrick J. Anderson wrote:
> I'm having trouble with Toolbook. I can't see the image
list, below is my 
> code:
> 

>         il = wx.ImageList(22, 22)
>         for i in images:
>             try:
>                 il.AddIcon(wx.Image(i,
wx.BITMAP_TYPE_PNG))

Try this instead:
                   il.Add(wx.Bitmap(i, wx.BITMAP_TYPE_PNG))



-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java
give you jitters?  Relax with wxPython!


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


Re: Re: having trouble with Toolbook
country flaguser name
Japan
2007-10-19 18:43:43
Hello,

When calling AddPage you need to tell the page which image
to use  
from the list by telling it the images index.

Currently you are doing this:
         self.AddPage(self.day_mode, "Daily",
ID_PLANNER_DAY_MODE)
         self.AddPage(self.week_mode, "Weekly",
ID_PLANNER_WEEK_MODE)
         self.AddPage(self.month_mode, "Monthly",
ID_PLANNER_MONTH_MODE)

Those calls should look something like this, where 0, 1, 2
are the  
values of the index returned when you called Add on the
image list  
for the wanted image.

        self.AddPage(self.day_mode, "Daily",
imageId=0)
        self.AddPage(self.week_mode, "Daily",
imageId=1)
        self.AddPage(self.month_mode, "Daily",
imageId=2)

The ID_* values you are passing now are acting as a boolean
for the  
"select" keyword argument of AddPage.

cody

On Oct 19, 2007, at 3:41 PM, Patrick J. Anderson wrote:

> On Fri, 19 Oct 2007 11:17:56 -0700, Robin Dunn wrote:
>
>> Patrick J. Anderson wrote:
>>> I'm having trouble with Toolbook. I can't see
the image list,  
>>> below is
>>> my code:
>>>
>>>
>>>         il = wx.ImageList(22, 22)
>>>         for i in images:
>>>             try:
>>>                 il.AddIcon(wx.Image(i,
wx.BITMAP_TYPE_PNG))
>>
>> Try this instead:
>>                    il.Add(wx.Bitmap(i,
wx.BITMAP_TYPE_PNG))
>
> Thanks, Robin, for your quick reply. That didn't throw
an error, but I
> still can't see the image list. Do I need to manually
Show(it) ? I  
> looked
> at the demo, but from the code it seems like it only
needs to be  
> assigned
> to a toolbook.
>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
> For additional commands, e-mail: wxPython-users- 
> helplists.wxwidgets.org
>


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )