How can I add icons to a GtkToolbar using PyGObject?
I can create the toolbar and an icon without any problems:
self.toolbar = Gtk.Toolbar()
self.item = Gtk.ToolItem()
But adding the item to the toolbar doesn't seem to work like this (Found this in the PyGTK documentation):
self.toolbar.Container.add(self.item)
The solution is actually pretty simple:
self.button = Gtk.ToolButton(Gtk.STOCK_ABOUT)
self.toolbar.insert(self.button, 0)
User button instead of item and then choose an icon from this list: http://python-gtk-3-tutorial.readthedocs.org/en/latest/stock.html
Then use .inset with the object and the position (in this case 0, meaning the first item in the toolbar).
Related
I have a couple of UIKit pop-up menu buttons with identical menu items on the same screen in a Swift app. The buttons are built by calling a function that uses an array of strings to create the list of menu items.
The problem is that depending on the button's vertical position on the screen, the menu items may appear in the order specified by the function, or reversed. If the button is in the upper half of the screen, the menu items are listed in the correct order. If the button is in the lower half of the screen the menu items are listed in reverse order.
I would prefer the menu items to appear in the same order regardless of the button's position on the screen. I could check the button location and have the menu creation function reverse the order, but that seems kind of clunky. I am hoping there's a cleaner way to override this behaviour.
The code and array used to create the button menus:
let buttonMenuItems = ["Spring","Summer","Autumn","Winter"]
func createAttributeMenu(menuNumber: Int)->UIMenu {
var menuActions: [UIAction] = []
for attribute in buttonMenuItems {
let item = UIAction(title: attribute) { action in
self.updateMenu(menuID: menuNumber, selected: attribute)
}
menuActions.append(item)
}
return UIMenu(title: "", children: menuActions)
}
The result is this:
Versions I'm using now in testing: Xcode 14.1, iOS 16.1, but I have seen this behaviour on earlier versions as well. (back to iOS 14.x)
Starting with iOS 16, there is a .preferredMenuElementOrder property that can be set on the button:
case automatic
A constant that allows the system to choose an ordering strategy according to the current context.
case priority
A constant that displays menu elements according to their priority.
case fixed
A constant that displays menu elements in a fixed order.
Best I can tell (as with many Apple definitions), there is no difference between .automatic and .priority.
From the .priority docs page:
Discussion
This ordering strategy displays the first menu element in the UIMenu closest to the location of the user interaction.
So, we get "reversed" order based on the position of the menu relative to the button.
To keep your defined order:
buttonNearTop.menu = createAttributeMenu(menuNumber: 1)
buttonNearBottom.menu = createAttributeMenu(menuNumber: 2)
if #available(iOS 16.0, *) {
buttonNearBottom.preferredMenuElementOrder = .fixed
buttonNearTop.preferredMenuElementOrder = .fixed
} else {
// out of luck... you get Apple's "priority" ordering
}
I use DotNetBar controls. I can change colours for buttons with:
Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
Office2007ButtonItemColorTable bt = table.ButtonItemColors[6];
bt.Default.Background = new LinearGradientColorTable(Color.White);
bt.MouseOver.Background = new LinearGradientColorTable(Color.Green);
Unfortunate I cannot find how I can change colour for a focused button.
Is it possible?
I'm looking for a widget like this.
http://ppt.cc/RPfL
Clicking "View" and triangle (drop down icon) need to perform two different functions.
Clicking the triangle opening the menu.
I tried creating 2 buttons to emulate, but the 2 buttons have extra space in between them.
How can I eliminate the space between buttons or, is there a convenient way to accomplish this?
thank you all!!
An IconMenuButton (which is a sub class of IconButton) will provide what you need.
Menu menu = new Menu();
MenuItem newItem = new MenuItem("New");
MenuItem openItem = new MenuItem("Open");
MenuItem saveItem = new MenuItem("Save");
MenuItem saveAsItem = new MenuItem("Save As");
menu.setItems(newItem, openItem, saveItem, saveAsItem);
IconMenuButton menuButton = new IconMenuButton("View", menu);
Also check SmartGWT samples I've given in my comment and RibbonBar sample.
I want to remove the File, edit, Source, Refactor, etc. menus from my RCP application
Can I use hideActionSet() ? or what should I do ?
That's right; in your ApplicationWorkbenchWindowAdvisor, override postWindowOpen().
The tricky bit is usually figuring out the names of the actionsets that you want to remove, but you can use the old standby ALT-SHIFT-F2 (the default keybinding for 'Plugin-in Menu Spy') and click on one of the menu items that you want to remove.
Note that if the menu item is disabled, the spy won't give you any info on it.
public void postWindowOpen() {
runApplicationWorkbenchDelegate();
// remove unwanted UI contributions that eclipse makes by default
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (int i = 0; i < windows.length; ++i) {
IWorkbenchPage page = windows[i].getActivePage();
if (page != null) {
// hide generic 'File' commands
page.hideActionSet("org.eclipse.ui.actionSet.openFiles");
// hide 'Convert Line Delimiters To...'
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo");
// hide 'Search' commands
page.hideActionSet("org.eclipse.search.searchActionSet");
// hide 'Annotation' commands
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
// hide 'Forward/Back' type navigation commands
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
}
}
}
Although the question is old:
Lars Vogel's tutorial about Eclipse Activities shows how to hide entire menus in an RCP application rather than removing single menu-entries.
EDIT:
Alternatively you can use the MenuManager attached to the workbench window to show or hide Menus/Contributions.
Try the following code to hide all menus:
WorkbenchWindow workbenchWin = (WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow();
MenuManager menuManager = workbenchWin.getMenuManager();
IContributionItem[] items = menuManager.getItems();
for(IContributionItem item : items) {
item.setVisible(false);
}
I'm creating a vertical SWT ToolBar:
ToolBar toolBar = new ToolBar( parent, SWT.RIGHT | SWT.VERTICAL );
And then adding items to it:
for ( MyObject myObject: myObjects ) {
ToolItem toolItem = new ToolItem( toolBar, SWT.NONE );
toolItem.setText( myObject.getLabel() );
toolItem.setImage( myObject.getImage() );
}
The toolbar is created correctly, but as some labels are too long, there are some cases in which new items are created on a second column, in front of the previous item.
So, instead of getting a toolbar that looks like
Item with a very long label
Tiny item
Little item
I get a toolbar that looks like
Item with a very long label
Tiny item Little item
If the long label is long enough, a third column will appear.
Does anyone know if there's a way to prevent the creation of a new column on the toolbar?
Thank you.