Eto.Forms.ToolBar how to set button size?

Hi @Trav and @curtisw,

i have a form with an Eto.Forms.ToolBar to which i add commands without text (only image). These images are 64x64px however the ToolItems are displayed much smaller. I cannot find how to control the button size. I’ve tried this:

item = Eto.Forms.ButtonToolItem(command)
item.ControlObject.MinHeight = 32
item.ControlObject.MinWidth = 32

and only the button scales larger, howewer the image (which i set in the command) remains small. How can i set the button size properly ?

thanks,
c.

Hi @clement,

Generally speaking, the image should dictate the size of the button.

If you have some sample code that isn’t working the way you’d like, please share.

– Dale

Hi @dale, below is the shortest i could make.

ETO_ToolBarTest.py (4.3 KB)

thanks for taking a look,
c.

Hi @clement,

It might be that a Toolbar still uses a fixed-size image. I’ll let @curtisw handle this.

In the mean time, I’ve coded up an alternative - see if this works for you.

ETO_ToolBarTest.py (8.5 KB)

– Dale

Hi @dale, thank you for this example which is probably only for Rhino 7. Using Rhino 6 i get this error:

Message: ‘Rhino.UI.Controls’ object has no attribute ‘RhinoButtonRow’

I’ve coded an alternative using just regular buttons with image too, there it respects my desired button size and scales the button images accordingly.

One follow up question as it is related. I am coding this since i need to have a cross platform toolbar which can be updated and distributed without too much work for RH6 (win) and RH7 (win and mac). There currently is no easy way to convert my windows toolbars (rui) to mac so i created this modeless dialog with button commands which works better than nothing. However, there is one problem i have no solution for yet:

If a user clicks on one of the “toolbar” buttons, i invoke a Rhino command for each button, eg. this:

! _-RunPythonScript ScriptName.py

The script gets called as it should and the dialog remains open but the command cannot be repeated, instead it just repeats the previous command (or the opening of the toolbar). Can i run a command in a way Rhino thinks it was run like a seperate command, so it is added to the repeat list ?

thanks,
c.

Hey @clement, yeah the toolbar button sizes are hard coded to 16x16 in windows unfortunately.

One way to “hack” it to be larger is to get to the contained Image control like so:

item = Eto.Forms.ButtonToolItem(command)
wpfImage = item.ControlObject.Content.Children[0]
wpfImage.MaxHeight = 64
wpfImage.MaxWidth = 64

Do note that using ControlObject does not work on both platforms as it is the native control, in this case a WPF Button that contains both an WPF Image and TextBlock. See here for its implementation.

Also, Eto’s implementation for ButtonToolItem may change over time so the above may not always work.

Hope this helps!

Thank you @curtisw, i ended up using just simple Eto.Forms.Button items in a dynamic row since the ToolItem solution and the one using Rhino.UI.Controls.RhinoButtonRow both had the problem that i needed to click twice on the button to invoke the command. The first click did activate the dialog, the second then started the button command. Somehow, using simple buttons, this was not required so i kept it.

_
c.