move tools in a toolbar

I am interested whether is there a way to move tools through toolbar,

more precisely i need to swap two neighbor tools.

Remove one tool and insert a new one with the same properties at the new location. Then call Realize again.

···

On 12/20/11 1:30 PM, smgorelik wrote:

I am interested whether is there a way to move tools through toolbar,

more precisely i need to swap two neighbor tools.

--
Robin Dunn
Software Craftsman

Done it before , but stumbled on a strange behavior ,
i tried to insert a labeled bmp tool to a given position, but the tool
has been inserted at the end of the toolbar,
and i needed it to be inserted between two tools.

···

On Dec 21, 1:38 am, Robin Dunn <ro...@alldunn.com> wrote:

On 12/20/11 1:30 PM, smgorelik wrote:

> I am interested whether is there a way to move tools through toolbar,

> more precisely i need to swap two neighbor tools.

Remove one tool and insert a new one with the same properties at the new
location. Then call Realize again.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Please make a runnable, small as possible, sample application that demonstrates the problem, and let us know the platform and wx version. MakingSampleApps - wxPyWiki

···

On 12/21/11 4:31 AM, smgorelik wrote:

Done it before , but stumbled on a strange behavior ,
i tried to insert a labeled bmp tool to a given position, but the tool
has been inserted at the end of the toolbar,
and i needed it to be inserted between two tools.

--
Robin Dunn
Software Craftsman

I tried to reproduce the insert to the end of the toolbar without any
success,
Although my example below still does not succeed in inserting the tool
to a given position.

I'll appreciate if someone will explain to me where is my mistake.

btw: my first try was to use "AddCheckLabelTool" instead of
"AddLabelTool" but i didn't find an insert method that is consistent
with "AddCheckLabelTool".

import wx
class MyFrame ( wx.Frame ): def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title =
wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 250,140 ),
style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
sizer = wx.BoxSizer( wx.VERTICAL ) self.m_toolBar =
wx.ToolBar( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
wx.TB_HORIZONTAL|wx.TB_TEXT )
self.m_toolBar.AddLabelTool(100,"A",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="A",longHelp="A")

self.m_toolBar.AddLabelTool(102,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="B",longHelp="B")

self.m_toolBar.AddLabelTool(103,"C",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="C",longHelp="C")

self.m_toolBar.AddLabelTool(104,"D",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="D",longHelp="D")
self.m_toolBar.Realize() self.button =
wx.Button( self, wx.ID_ANY, u"Swap() : B and C", wx.DefaultPosition,
wx.DefaultSize, 0 ) self.button.Bind(wx.EVT_BUTTON,
self.OnSwap) sizer.Add( self.m_toolBar, 0,
wx.ALL|wx.EXPAND, 5 ) sizer.Add( self.button, 0, wx.ALL, 5 )
self.SetSizer( sizer ) self.Layout()
self.Centre( wx.BOTH ) def OnSwap(self, evt): print
"position %d" % self.m_toolBar.GetToolPos(102)
self.m_toolBar.RemoveTool(102)
self.m_toolBar.InsertLabelTool(2,
105,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="B",longHelp="B")
def __del__( self ):
pass#----------------------------------------------------------------------
if __name__ == "__main__": app = wx.App(False) frame =
MyFrame(None) frame.Show() app.MainLoop()

···

On Dec 21, 10:54 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 12/21/11 4:31 AM, smgorelik wrote:

> Done it before , but stumbled on a strange behavior ,
> i tried to insert a labeled bmp tool to a given position, but the tool
> has been inserted at the end of the toolbar,
> and i needed it to be inserted between two tools.

Please make a runnable, small as possible, sample application that
demonstrates the problem, and let us know the platform and wx version.MakingSampleApps - wxPyWiki

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

strange , before the edit of the message the code seemed ok , but
after the message sent the code is not aligned correctly .

···

On Dec 22, 11:36 am, smgorelik <smgore...@gmail.com> wrote:

I tried to reproduce the insert to the end of the toolbar without any
success,
Although my example below still does not succeed in inserting the tool
to a given position.

I'll appreciate if someone will explain to me where is my mistake.

btw: my first try was to use "AddCheckLabelTool" instead of
"AddLabelTool" but i didn't find an insert method that is consistent
with "AddCheckLabelTool".

import wx
class MyFrame ( wx.Frame ): def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title =
wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 250,140 ),
style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
sizer = wx.BoxSizer( wx.VERTICAL ) self.m_toolBar =
wx.ToolBar( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
wx.TB_HORIZONTAL|wx.TB_TEXT )
self.m_toolBar.AddLabelTool(100,"A",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NOR MAL,shortHelp="A",longHelp="A")

self.m_toolBar.AddLabelTool(102,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NOR MAL,shortHelp="B",longHelp="B")

self.m_toolBar.AddLabelTool(103,"C",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NOR MAL,shortHelp="C",longHelp="C")

self.m_toolBar.AddLabelTool(104,"D",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NOR MAL,shortHelp="D",longHelp="D")
self.m_toolBar.Realize() self.button =
wx.Button( self, wx.ID_ANY, u"Swap() : B and C", wx.DefaultPosition,
wx.DefaultSize, 0 ) self.button.Bind(wx.EVT_BUTTON,
self.OnSwap) sizer.Add( self.m_toolBar, 0,
wx.ALL|wx.EXPAND, 5 ) sizer.Add( self.button, 0, wx.ALL, 5 )
self.SetSizer( sizer ) self.Layout()
self.Centre( wx.BOTH ) def OnSwap(self, evt): print
"position %d" % self.m_toolBar.GetToolPos(102)
self.m_toolBar.RemoveTool(102)
self.m_toolBar.InsertLabelTool(2,
105,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="B",longHelp=" B")
def __del__( self ):
pass#----------------------------------------------------------------------
if __name__ == "__main__": app = wx.App(False) frame =
MyFrame(None) frame.Show() app.MainLoop()

On Dec 21, 10:54 pm, Robin Dunn <ro...@alldunn.com> wrote:

> On 12/21/11 4:31 AM, smgorelik wrote:

> > Done it before , but stumbled on a strange behavior ,
> > i tried to insert a labeled bmp tool to a given position, but the tool
> > has been inserted at the end of the toolbar,
> > and i needed it to be inserted between two tools.

> Please make a runnable, small as possible, sample application that
> demonstrates the problem, and let us know the platform and wx version.MakingSampleApps - wxPyWiki

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

Hi,

strange , before the edit of the message the code seemed ok , but
after the message sent the code is not aligned correctly .

Yes, this is why you should send it as an attachement :wink:

self.Centre( wx.BOTH ) def OnSwap(self, evt): print
"position %d" % self.m_toolBar.GetToolPos(102)
self.m_toolBar.RemoveTool(102)
self.m_toolBar.InsertLabelTool(2,
105,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="B",longHelp=" B")
def __del__( self ):

Hard to read from the mangled code but guess would be that its because
your not calling Realize again after changing the toolbar in OnSwap.

Cody

···

On Thu, Dec 22, 2011 at 3:38 AM, smgorelik <smgorelik@gmail.com> wrote:

Thanks, it solved this problem.

···

On Dec 22, 4:33 pm, Cody <codyprec...@gmail.com> wrote:

Hi,

On Thu, Dec 22, 2011 at 3:38 AM, smgorelik <smgore...@gmail.com> wrote:
> strange , before the edit of the message the code seemed ok , but
> after the message sent the code is not aligned correctly .

Yes, this is why you should send it as an attachement :wink:

>> self.Centre( wx.BOTH ) def OnSwap(self, evt): print
>> "position %d" % self.m_toolBar.GetToolPos(102)
>> self.m_toolBar.RemoveTool(102)
>> self.m_toolBar.InsertLabelTool(2,
>> 105,"B",wx.NullBitmap,wx.NullBitmap,wx.ITEM_NORMAL,shortHelp="B",longHelp=" B")
>> def __del__( self ):

Hard to read from the mangled code but guess would be that its because
your not calling Realize again after changing the toolbar in OnSwap.

Cody