FlatNotebok questions

Hello all,

I'm trying to use FlatNotebook first time and i have some questions:

Sizers:

When put a FlatNotebook on a sizer an do sizer.SetSizeHints(flatnotebook) the size is calculated for the active tab contents, if there is another tab with a bigger content is ignored.
May I calculate the size of all tabs content and tell the sizer the biggest size?

Enable/Disable:

I view than FlatNotebook overrides wx.Windows.Enable() and then the method works only for individual tabs. I don't find any method for Disable all and later reenable it and restore all tabs to original state.

Making same tests seem that: super(wx.Panel, self.flatnotebook).Enable(False) do the job, but is correct this way?

Thanks (sorry the bad english).

···

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************

Hi Oswaldo,

Sizers:

When put a FlatNotebook on a sizer an do sizer.SetSizeHints(flatnotebook) the
size is calculated for
the active tab contents, if there is another tab with a bigger content is ignored.
May I calculate the size of all tabs content and tell the sizer the biggest size?

Uhm, do you mean the FlatNotebook pages? It's not very clear to me,
can you provide a sample that shows the problem? In theory,
FlatNotebook should give all the pages the same size, but maybe I m
overlooking something.
However, you can always do something like:

flatnotebook.SetSize((sizex, sizey))

And the sizer will respect those dimensions.

Enable/Disable:

I view than FlatNotebook overrides wx.Windows.Enable() and then the method
works only for individual
tabs. I don't find any method for Disable all and later reenable it and restore all
tabs to original state.

Making same tests seem that: super(wx.Panel, self.flatnotebook).Enable(False)
do the job, but is correct this way?

You're right, at the moment is the only way to do that. However, I am
wondering if it would be worth renaming the FlatNotebook method to
something like EnablePage() or EnableTab(), in order to avoid
shadowing of the wx.Window.Enable method. Does anyone see anything
against this approach? I can provide a patch to Robin if necessary.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 6/25/07, Oswaldo Hernández wrote:

Oswaldo Hernández wrote:

Hello all,

I'm trying to use FlatNotebook first time and i have some questions:

Sizers:

When put a FlatNotebook on a sizer an do sizer.SetSizeHints(flatnotebook) the size is calculated for the active tab contents, if there is another tab with a bigger content is ignored.
May I calculate the size of all tabs content and tell the sizer the biggest size?

Probably the best thing to do for this is to change FlatNotebook to derive from wx.PyPanel and override DoGetBestSize. That method should find the biggest best size of the pages and add space for the tabs and return the result.

···

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

Andrea Gavana wrote:

Making same tests seem that: super(wx.Panel, self.flatnotebook).Enable(False)
do the job, but is correct this way?

You're right, at the moment is the only way to do that. However, I am
wondering if it would be worth renaming the FlatNotebook method to
something like EnablePage() or EnableTab(), in order to avoid
shadowing of the wx.Window.Enable method. Does anyone see anything
against this approach?

It makes sense to me.

···

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

Hi Robin and Oswaldo,

Oswaldo Hernández wrote:
> Hello all,
>
> I'm trying to use FlatNotebook first time and i have some questions:
>
> Sizers:
>
> When put a FlatNotebook on a sizer an do
> sizer.SetSizeHints(flatnotebook) the size is calculated for the active
> tab contents, if there is another tab with a bigger content is ignored.
> May I calculate the size of all tabs content and tell the sizer the
> biggest size?

Probably the best thing to do for this is to change FlatNotebook to
derive from wx.PyPanel and override DoGetBestSize. That method should
find the biggest best size of the pages and add space for the tabs and
return the result.

I have implemented a patch for FlatNotebook and its demo: it seems to
work, but I would appreciate if someone will double-check what I have
done:

1) The Enable method is now called EnableTab;
2) FlatNotebook now derives from wx.PyPanel, and I have implemented
the DoGetBestSize method (hopefully correctly).

Please let me know if you see something strange...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

flatnotebook.patch (3.36 KB)

flatnotebookdemo.patch (719 Bytes)

···

On 6/25/07, Robin Dunn wrote:

Andrea Gavana escribió:

Hi Robin and Oswaldo,

Oswaldo Hernández wrote:
> Hello all,
>
> I'm trying to use FlatNotebook first time and i have some questions:
>
> Sizers:
>
> When put a FlatNotebook on a sizer an do
> sizer.SetSizeHints(flatnotebook) the size is calculated for the active
> tab contents, if there is another tab with a bigger content is ignored.
> May I calculate the size of all tabs content and tell the sizer the
> biggest size?

Probably the best thing to do for this is to change FlatNotebook to
derive from wx.PyPanel and override DoGetBestSize. That method should
find the biggest best size of the pages and add space for the tabs and
return the result.

I have implemented a patch for FlatNotebook and its demo: it seems to
work, but I would appreciate if someone will double-check what I have
done:

1) The Enable method is now called EnableTab;
2) FlatNotebook now derives from wx.PyPanel, and I have implemented
the DoGetBestSize method (hopefully correctly).

Please let me know if you see something strange...

Andrea, Robin, you are fantastic :slight_smile:

I apply the patch and now SetSizeHints() calculate the size of the bigger tab, and Enable now enable/disable the whole notebook.

Another question that i forgot in the previous message:

If you have the focus outside of notebook and press TAB key for navigation, the focues never enter into the notebook.

I attach a sample program for test size, enable and the navigation .

Thanks

testnotebook.py (2.58 KB)

···

On 6/25/07, Robin Dunn wrote:

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************

Hi Oswaldo,

Andrea Gavana escribio:
> Hi Robin and Oswaldo,
>
>> Oswaldo Hernandez wrote:
>> > Hello all,
>> >
>> > I'm trying to use FlatNotebook first time and i have some questions:
>> >
>> > Sizers:
>> >
>> > When put a FlatNotebook on a sizer an do
>> > sizer.SetSizeHints(flatnotebook) the size is calculated for the active
>> > tab contents, if there is another tab with a bigger content is ignored.
>> > May I calculate the size of all tabs content and tell the sizer the
>> > biggest size?
>>
>> Probably the best thing to do for this is to change FlatNotebook to
>> derive from wx.PyPanel and override DoGetBestSize. That method should
>> find the biggest best size of the pages and add space for the tabs and
>> return the result.
>
> I have implemented a patch for FlatNotebook and its demo: it seems to
> work, but I would appreciate if someone will double-check what I have
> done:
>
> 1) The Enable method is now called EnableTab;
> 2) FlatNotebook now derives from wx.PyPanel, and I have implemented
> the DoGetBestSize method (hopefully correctly).
>
> Please let me know if you see something strange...
>

Andrea, Robin, you are fantastic :slight_smile:

Thanks :-D, but I believe all the gratitude should go to Robin,
wxPython would be vaporware without him. I am just a little endian
working to somewhat enhancing this unequalled GUI package...

I apply the patch and now SetSizeHints() calculate the size of the bigger tab, and Enable now
enable/disable the whole notebook.

Another question that i forgot in the previous message:

If you have the focus outside of notebook and press TAB key for navigation, the focues never enter
into the notebook.

I attach a sample program for test size, enable and the navigation .

Uhm, I am at work right now and I can't test the latest modifications
I made yesterday evening... can you try to include the
style=wx.TAB_TRAVERSAL in FlatNotebook to see if it works? You might
probably do it for both FlatNotebook and PageContainer, but I am not
sure. I will investigate this evening :smiley:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 6/26/07, Oswaldo Hernandez wrote:

> On 6/25/07, Robin Dunn wrote:

Andrea Gavana escribió:

Hi Oswaldo,

Andrea Gavana escribio:
> Hi Robin and Oswaldo,
>
>> Oswaldo Hernandez wrote:
>> > Hello all,
>> >
>> > I'm trying to use FlatNotebook first time and i have some questions:
>> >
>> > Sizers:
>> >
>> > When put a FlatNotebook on a sizer an do
>> > sizer.SetSizeHints(flatnotebook) the size is calculated for the active
>> > tab contents, if there is another tab with a bigger content is ignored.
>> > May I calculate the size of all tabs content and tell the sizer the
>> > biggest size?
>>
>> Probably the best thing to do for this is to change FlatNotebook to
>> derive from wx.PyPanel and override DoGetBestSize. That method should
>> find the biggest best size of the pages and add space for the tabs and
>> return the result.
>
> I have implemented a patch for FlatNotebook and its demo: it seems to
> work, but I would appreciate if someone will double-check what I have
> done:
>
> 1) The Enable method is now called EnableTab;
> 2) FlatNotebook now derives from wx.PyPanel, and I have implemented
> the DoGetBestSize method (hopefully correctly).
>
> Please let me know if you see something strange...
>

Andrea, Robin, you are fantastic :slight_smile:

Thanks :-D, but I believe all the gratitude should go to Robin,
wxPython would be vaporware without him. I am just a little endian
working to somewhat enhancing this unequalled GUI package...

I apply the patch and now SetSizeHints() calculate the size of the bigger tab, and Enable now
enable/disable the whole notebook.

Another question that i forgot in the previous message:

If you have the focus outside of notebook and press TAB key for navigation, the focues never enter
into the notebook.

I attach a sample program for test size, enable and the navigation .

Uhm, I am at work right now and I can't test the latest modifications
I made yesterday evening... can you try to include the
style=wx.TAB_TRAVERSAL in FlatNotebook to see if it works? You might
probably do it for both FlatNotebook and PageContainer, but I am not
sure. I will investigate this evening :smiley:

Andrea,
I have tryed wx.TAB_TRAVERSAL on flatnotebook and on the parent Panel whith same result.

Thanks

···

On 6/26/07, Oswaldo Hernandez wrote:

> On 6/25/07, Robin Dunn wrote:

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************

Hi,

I try to add a FileDropTarget to a ListCtrl : under windows, no problem.
But under mac, it doesn't work at all...

Do you know if a workaround exist for this problem ? because I seek on the Internet a way to solve this problem (set the drop on other elements ?), but I found nothing...

here a example of the problem (I found this code on the Internet) (with wxPython 2.6)

import wx
class MyFileDropTarget(wx.FileDropTarget):
    def __init__(self, parent):
        wx.FileDropTarget.__init__(self)
        self.parent = parent

    def OnDropFiles(self, x, y, files):
        for file in files:
            self.parent.c.InsertStringItem(0, file)

class TestFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "test")
        size = self.GetClientSize()
        self.c = wx.ListCtrl(self, 1860,
            style=wx.LC_REPORT|wx.SUNKEN_BORDER,
            size=size, pos=(0,0))

        self.c.InsertColumn(0, "Filename",
            width = size[0])

        self.c.SetDropTarget(MyFileDropTarget(self))

    def onStartDrag(self, evt):
        print 'something'
        evt.Skip()

class TestApp(wx.App):
    def OnInit(self):
        frame = TestFrame()
        frame.Show(True)
        return True

if __name__ == '__main__':
    TestApp(0).MainLoop()

Andrea Gavana wrote:

I have implemented a patch for FlatNotebook and its demo: it seems to
work, but I would appreciate if someone will double-check what I have
done:

1) The Enable method is now called EnableTab;
2) FlatNotebook now derives from wx.PyPanel, and I have implemented
the DoGetBestSize method (hopefully correctly).

Please let me know if you see something strange...

Looks good to me. Thanks for the patch.

···

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

Wursteisen David wrote:

Hi,

I try to add a FileDropTarget to a ListCtrl : under windows, no problem.
But under mac, it doesn't work at all...

Do you know if a workaround exist for this problem ? because I seek on the Internet a way to solve this problem (set the drop on other elements ?), but I found nothing...

here a example of the problem (I found this code on the Internet) (with wxPython 2.6)

       self.c.SetDropTarget(MyFileDropTarget(self))

On wxGTK and wxMac the wxListCtrl is actually a composite of 2 windows, so setting the drop target like this actually set's it for the window that is behind the one that is showing the items. Try this instead:

  self.c.GetMainWindow().SetDropTarget(MyFileDropTarget(self))

···

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

Oswaldo Hernández escribió:

Andrea Gavana escribió:

Hi Oswaldo,

Andrea Gavana escribio:
> Hi Robin and Oswaldo,
>
>> Oswaldo Hernandez wrote:
>> > Hello all,
>> >
>> > I'm trying to use FlatNotebook first time and i have some questions:
>> >
>> > Sizers:
>> >
>> > When put a FlatNotebook on a sizer an do
>> > sizer.SetSizeHints(flatnotebook) the size is calculated for the active
>> > tab contents, if there is another tab with a bigger content is ignored.
>> > May I calculate the size of all tabs content and tell the sizer the
>> > biggest size?
>>
>> Probably the best thing to do for this is to change FlatNotebook to
>> derive from wx.PyPanel and override DoGetBestSize. That method should
>> find the biggest best size of the pages and add space for the tabs and
>> return the result.
>
> I have implemented a patch for FlatNotebook and its demo: it seems to
> work, but I would appreciate if someone will double-check what I have
> done:
>
> 1) The Enable method is now called EnableTab;
> 2) FlatNotebook now derives from wx.PyPanel, and I have implemented
> the DoGetBestSize method (hopefully correctly).
>
> Please let me know if you see something strange...
>

Andrea, Robin, you are fantastic :slight_smile:

Thanks :-D, but I believe all the gratitude should go to Robin,
wxPython would be vaporware without him. I am just a little endian
working to somewhat enhancing this unequalled GUI package...

I apply the patch and now SetSizeHints() calculate the size of the bigger tab, and Enable now
enable/disable the whole notebook.

Another question that i forgot in the previous message:

If you have the focus outside of notebook and press TAB key for navigation, the focues never enter
into the notebook.

I attach a sample program for test size, enable and the navigation .

Uhm, I am at work right now and I can't test the latest modifications
I made yesterday evening... can you try to include the
style=wx.TAB_TRAVERSAL in FlatNotebook to see if it works? You might
probably do it for both FlatNotebook and PageContainer, but I am not
sure. I will investigate this evening :smiley:

Andrea,
I have tryed wx.TAB_TRAVERSAL on flatnotebook and on the parent Panel whith same result.

Andrea, i would like help you,

I'm looking flatnotebook.py and, in the following code (line 3474):

def OnNavigationKey(self, event):
     ...
     else:
         # pass to the parent
         if self.GetParent():
             event.SetCurrentFocus(self)
             self.GetParent().ProcessEvent(event)

if change to:

     else:
         # pass to the parent
         event.Skip()
  
The navigation with keyboard works, except the first press that the focus dissapear (i suposse that the focus is in the tab label)

I don't know if the change may affect to other things.

···

On 6/26/07, Oswaldo Hernandez wrote:

> On 6/25/07, Robin Dunn wrote:

--
*****************************************
Oswaldo Hernández
oswaldo (@) soft-com (.) es
*****************************************

Oswaldo Hernández wrote:

The navigation with keyboard works, except the first press that the focus dissapear (i suposse that the focus is in the tab label)

If that's true then it would be nice if it would draw a focus indicator and also allow the changing of tabs via the keyboard like the native notebooks do.

···

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

Robin Dunn a écrit :

Wursteisen David wrote:

Hi,

I try to add a FileDropTarget to a ListCtrl : under windows, no problem.
But under mac, it doesn't work at all...

Do you know if a workaround exist for this problem ? because I seek on the Internet a way to solve this problem (set the drop on other elements ?), but I found nothing...

here a example of the problem (I found this code on the Internet) (with wxPython 2.6)

       self.c.SetDropTarget(MyFileDropTarget(self))

On wxGTK and wxMac the wxListCtrl is actually a composite of 2 windows, so setting the drop target like this actually set's it for the window that is behind the one that is showing the items. Try this instead:

    self.c.GetMainWindow().SetDropTarget(MyFileDropTarget(self))

Unfortunately, it doesn't work....

The bug doesn't occur under Gnome (I haven't tested it by myself...)

So, the bug is specific to wxMac ? Can I solve it by fix it directly into the source (if I can...), or it's just the right behavious of this component under Mac ?

Thanks for your answer !

Wursteisen David a écrit :

Robin Dunn a écrit :

Wursteisen David wrote:

Hi,

I try to add a FileDropTarget to a ListCtrl : under windows, no problem.
But under mac, it doesn't work at all...

Do you know if a workaround exist for this problem ? because I seek on the Internet a way to solve this problem (set the drop on other elements ?), but I found nothing...

here a example of the problem (I found this code on the Internet) (with wxPython 2.6)

       self.c.SetDropTarget(MyFileDropTarget(self))

On wxGTK and wxMac the wxListCtrl is actually a composite of 2 windows, so setting the drop target like this actually set's it for the window that is behind the one that is showing the items. Try this instead:

    self.c.GetMainWindow().SetDropTarget(MyFileDropTarget(self))

Unfortunately, it doesn't work....

The bug doesn't occur under Gnome (I haven't tested it by myself...)

So, the bug is specific to wxMac ? Can I solve it by fix it directly into the source (if I can...), or it's just the right behavious of this component under Mac ?

Thanks for your answer !

I try my little example, and it work fine with wxPython 2.8. But in my application, python crash earch time I try to drop a file (I don't know yet why...)

···

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Andrea,

Any chance that you can put this latest version onto your site?

Werner

Hi Werner,

Any chance that you can put this latest version onto your site?

I'll do it this evening when I get back home; I'll add Oswaldo patch
and I'll try also to implement Robin's suggestion about the focus
indicator/keyboard navigation.
By the way, is there a particular reason why you need the website
version updated? Just out of curiosity...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 6/27/07, Werner F. Bruhin wrote:

Hi All,

Hi Werner,

> Any chance that you can put this latest version onto your site?

I'll do it this evening when I get back home; I'll add Oswaldo patch
and I'll try also to implement Robin's suggestion about the focus
indicator/keyboard navigation.
By the way, is there a particular reason why you need the website
version updated? Just out of curiosity...

I have implemented the feature Robin suggested, and the patch provided
by Oswaldo. Moreover, the FlatNotebook version on my webpage is now up
to date to this latest implementation.
I attach a patch against this evening SVN (I hope).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

flatnotebook.patch (8.92 KB)

···

On 6/27/07, Andrea Gavana wrote:

On 6/27/07, Werner F. Bruhin wrote:

Hi Andrea,

Andrea Gavana wrote:

Hi Werner,

Any chance that you can put this latest version onto your site?

I'll do it this evening when I get back home; I'll add Oswaldo patch
and I'll try also to implement Robin's suggestion about the focus
indicator/keyboard navigation.
By the way, is there a particular reason why you need the website
version updated? Just out of curiosity...

I have an issue which I thought might get fixed with this latest version and I didn't want to setup cvs access to wxPython just to get this latest version.

The issue is:
On start up I create a flatnotebook with 8 tabs, this was too slow, so I changed it that the tabs are created using a dummy wxPanel (empty) with the exception of the first tab and the other tabs get loaded with the correct wxPanel when the user clicks on the tab. But I do get strange problems that the controls on certain tabs are sometimes not available/reacting as they should (e.g. can't select an item on a treectrl).

Will work on this again today and see if it is me doing something stupid. Will create a small test app if I can't figure out what is going on.

Thanks and best regards
Werner

···

On 6/27/07, Werner F. Bruhin wrote:

Hi Andrea,

Werner F. Bruhin wrote:

...
The issue is:
On start up I create a flatnotebook with 8 tabs, this was too slow, so I changed it that the tabs are created using a dummy wxPanel (empty) with the exception of the first tab and the other tabs get loaded with the correct wxPanel when the user clicks on the tab. But I do get strange problems that the controls on certain tabs are sometimes not available/reacting as they should (e.g. can't select an item on a treectrl).

Will work on this again today and see if it is me doing something stupid. Will create a small test app if I can't figure out what is going on.

Just for the archive.

If I use:
self.flatnotebook.RemovePage(sel)
self.flatnotebook.InsertPage(sel, self.newPage, self.tabNames[sel], True, -1)

I can't select a control on the new page with the mouse and in some cases controls disappear (have to minimize/maximize.

Fix is easy, using DeletePage instead works:
self.flatnotebook.DeletePage(sel)
self.flatnotebook.InsertPage(sel, self.newPage, self.tabNames[sel], True, -1)

Werner