Extra Icon on NavigationToolbar2QTAgg - python-2.7

I have recently used a solution found in StackOverflow to remove icons on the Toolbar, however, I cannot remove one and I do not know why. I was wondering if anyone has seen and removed this extra icon successfully. The answer I used was: https://stackoverflow.com/a/15549675
This is how I used it:
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
class NavigationToolbar(NavigationToolbar):
# only display the buttons we need
toolitems = [t for t in NavigationToolbar.toolitems if
t[0] in ('Pan', 'Zoom', 'Save')]
And the extra icon looks like:
http://i.imgur.com/DQaq5Vj.png?1
Thanks!

See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_qt4.py#L586 for where that icon is added. It is done outside of the toolitem list, hence why this method didn't work.
Adding
matplotlib.backends.backend_qt.figureoptions = None
will do what you want.

Related

Actions Menu Interactive Grid

Is there any way to remove 'Chart' from Actions Menu in an Interactive Grid?
So I posted a short answer that should have honestly probably been a comment with a link to https://hardlikesoftware.com/weblog/2017/01/24/how-to-hack-apex-interactive-grid-part-2/
Then I had some time and decided to try to actually execute this and got to a solution thanks to https://community.oracle.com/thread/4324589 where they also further reference https://community.oracle.com/thread/4319050
So you know where to go for more information on this topic.
As for your solution:
Go into the Attributes of the IG, Find Javascript Initialization Code under Advanced.
Then paste the following code:
function(config) {
var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar();
config.toolbarData = toolbarData;
toolbarData.toolbarRemove( "chart-view" );
return config;
}
Hope this works for you, it worked for me.
EDIT:
In response to you asking how to find the name to remove.
Well thats not exactly simple. See if perhaps its mentioned in one of the posts. Otherwise you will have to search through the js file.
How I went about it is that once on the page, I opened up the console and ran $.apex.interactiveGrid.copyDefaultToolbar();
, opened up the returned array, and jumped to the definition of ToolbarRemove. This opened up InteractiveGrid.min.js so I could search there. Then I Ctrl + F there to find "chart".
What you could also do so you arent just searching blindly until you find it is that these labels need to be referenced for translation. So if you go to
http://translate-apex.com
And you find what the label is called, you can just search for that.
For the chart you could go to the translations and find the Chart item which is APEX.IG.CHART. Then in the js you find APEX.IG.CHART which only occurs once, instead of the 10 times "chart" occurs.
EDIT 2:
You asked about the Flashback dialog.
function(config) {
var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar();
config.toolbarData = toolbarData;
toolbarData.toolbarRemove( "show-flashback-dialog" );
return config;
}
This works for me
Check the attributes of the interactive grid and turn off the "Define chart view"
Check this image

Add accelerator ctrl+F for text search

I am trying to add a Ctrl+F accelerator to my gtkmm textview program. I already implemented the search function into an gtk Entry field, so the only thing I need is to get focus the find entry when Ctrl+F is pressed.
I googled and checked tutorials/reference of gtkmm (2.4, I'm working with that) but the only things I found were accelerators in context with menus and toolbars using UIManager, which I don't have in that .cc file I use (and I can't add them, cause its an existing program).
I tried to add an action with an AccelKey on a button or tried the function add_accelerator() but I wasn't able to use them properly (I am pretty new to gtkmm and there aren't enough samples - at least none I understand). Here some examples I tried:
_gtkActionGroup->add(
Gtk::Action::create("find", "Find", "search in file"),
Gtk::AccelKey("<control>F"),
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
I didn't know how to add this action to the button (in the toolbar) I created...
_gtkAccelGroup(Gtk::AccelGroup::create()) //initialized in the constructor of the class
...
_gtkBtnFind.add_accelerator("find", _gtkAccelGroup, GDK_Find,
Gdk::ModifierType::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
I tried here something, but I didn't really understand neither the parameters I needed to enter here nor how this method works - ofc it didn't work...
I'd be really happy if anyone can explain me how this things work properly and sorry for my bad english. If there are any things you need just tell me please. Thanks in advance
Greetings
edit: I looked up in the gtk sources and tried to understand the parameters of add_accelerator. Now I tried this but still doesn't work...:
_gtkBtnFind.add_accelerator("clicked", _gtkAccelGroup, GDK_KEY_F /* or better GDK_KEY_f ?*/,
Gdk::ModifierType(GDK_CONTROL_MASK), Gtk::AccelFlags(GTK_ACCEL_VISIBLE));
_gtkBtnFind.signal_clicked().connect(
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
UPDATE:
Okay I have understood most I think now, and I know why it doesn't work. The problem is that I have to add the accel_group to the window widget, but I got only a scrolled window and boxes in my program....and now I have no clue how to continue... :)
UPDATE2:
Alright I managed to do it without accelerators by using the "on_key_press_event" handler by checking the state and keyval parameter. Hope this helps some ppl at least ^^.
bool on_key_press_event(GdkEventKey* event) { /* declaration in my constructor removed */
if(event->state == GDK_CONTROL_MASK && event->keyval == GDK_KEY_f
|| event->state == (GDK_CONTROL_MASK | GDK_LOCK_MASK)
&& event->keyval == GDK_KEY_F) {
_gtkEntFind.grab_focus();
}
return false;
}
I would be still interested in a solution with the accelerators if there is any ! Greetings

wxGrid GetSelectedCells returns empty array

I want to delete selected rows when the use click on a button.
so far the code looks like that:
this->grid_ = new wxGrid(parent, ...)
this->grid_->SetSelectionMode(wxGrid::wxGridSelectCells);
// Later, whene the button is clicked
this->grid_->SetFocus();
wxGridCellCoordsArray wx_cells = this->grid_->GetSelectedCells();
The problem is that the wx_cells variable is always empty whatever I select.
I tried with GetSelectedRows with no success.
I've added SetFocus and SetSelectionMode hoping it would help but it did not.
How can I get this to work ?
What version of wxgrid are you using? There seems to be an issue with old wxgrid that it always return empty when calling GetSelectedCells. Perhaps you can refer to http://forums.wxwidgets.org/viewtopic.php?t=6335 to try if it fits in your case.

wxPython - how to colour the text of a statusbar

I searched for the answer in the forum, but I didn't find anything, if I am wrong, I am sorry.
Anyway, question is simple, I have this Frame, with a Status Bar I use to print messages or notifies.
I would like to use it for mistakes or not permitted operations. But I would like these messages to be coloured. I am looking for a solution on wxPython demo -because i read somewhere on the web to get some inspirations by it-, but i still did not find anything.
Do you have any ideas or solutions?
thank you in advance.
I would try the SetForegroundColour or SetBackgroundColour methods of the status bar widget. These methods don't always work on every platform though as each OS has its own rules and wxPython follows those rules. If they do not work, then you'll have to roll your own statusbar, probably by using a couple of panels in a sizer or a splitter window.
There is also the 3rd party EnhancedStatusbar widget which might work for you. It can be found at http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
Simple solution: pin wx.StaticText on the status bar and write text in it. Text coloring in wx.StaticText works well.
For example:
self.sb = self.ws.CreateStatusBar()
self.sbtext = wx.StaticText(self.sb, -1, '', pos=(8, 4))
...
self.sbtext.SetForegroundColour(wx.Colour(color))
self.sbtext.SetLabel(text)

Using images in QListWidget, is this possible?

I am using QT to create a chat messenger client. To display the list of online users, I'm using a QListWidget, as created like this:
listWidget = new QListWidget(horizontalLayoutWidget);
listWidget->setObjectName("userList");
QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(listWidget->sizePolicy().hasHeightForWidth());
listWidget->setSizePolicy(sizePolicy1);
listWidget->setMinimumSize(QSize(30, 0));
listWidget->setMaximumSize(QSize(150, 16777215));
listWidget->setBaseSize(QSize(100, 0));
listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
Users are shown by constantly refreshing the list, like this: (Note: There are different channels, with different userlists, so refreshing it is the most efficient thing to do, as far as I know.)
void FMessenger::refreshUserlist()
{
if (currentPanel == 0)
return;
listWidget = this->findChild<QListWidget *>(QString("userList"));
listWidget->clear();
QList<FCharacter*> charList = currentPanel->charList();
QListWidgetItem* charitem = 0;
FCharacter* character;
foreach(character, charList)
{
charitem = new QListWidgetItem(character->name());
// charitem->setIcon(QIcon(":/Images/status.png"));
listWidget->addItem(charitem);
}
}
This has always worked perfectly. The line that I commented out is the one I have problems with: my current goal is to be able to display a user's online status with an image, which represents whether they are busy, away, available, etc. Using setIcon() does absolutely nothing though, apparently; the items still show up as they used to, without icons.
I'm aware that this is probably not the way this function needs to be used, but I have found little documentation about it online, and absolutely no useful examples of implementations. My question is, can anybody help me with fixing this problem?
This is how you may conduct your debugging:
Try the constructor that has both icon and text as arguments.
Try to use that icon in another context to ensure it is displayable (construct a QIcon with same argument and use it elsewhere, e.g. QLabel!).
Use icon() from the QListWidgetItem to receive back the icon and then look at that QIcon.
Create a new QListWidget, change nothing, and ordinarily add some stock items in your MainWidget's constructor. See if the icons show up there.