display a bokeh graph in wxpython - python-2.7

can someone post an example to load a bokeh graph into wxpython gui (on Windows 7).
I tried following but wasn't able to see anything loaded.
https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/8YqCZdRBgJs

Not directly. The bokeh project currently does not have a way to export the graphs as png or jpg files. See https://github.com/bokeh/bokeh/issues/538 for more information
Until this issue is formally resolved, you won't be able to show them inside of wxPython unless you use wxPython's webview widget. The webview widget is basically a wrapper around webkit (Linux / Mac) so theoretically you could use that to view a graph generated by bokeh.

Related

How to put system icons in menus?

I have run the menu example from Qt and there are no icons on menus, only text. Most apps (like pcmanfm and caja from Ubuntu) have similar icons, so I suppose they are system-wide and not application specific. How could I put icons in menu items? A code sample would be interesting.
To obtain the icons of the systems you must use the method QIcon::fromTheme()
Example:
newAct = new QAction(tr("&New"), this);
newAct->setIcon(QIcon::fromTheme("document-new"));
Qt uses as a backend to freedesktop icon, it has a rule in the names, the updated list of them can be found in the following link
The QIcon::fromTheme() function found in the other answer is unfortunately not portable to Mac or windows. You may have better luck using QStyle::standardIcon().

How to create an Evernote kind of widget for global menu of a MacOS/X desktop using QT?

How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.

Any way to forward drag/drop events to embedded process window?

A bit of background:
I need to embed a webview of some kind into a Qt application (that embeds python/PyQt) in order to display some html content. I am stuck with the MinGW build of Qt because that is what the Windows version of our software is built with and it is not feasible to migrate over to Visual C++. Unfortunately for me, QtWebKit has been removed from recent versions of Qt and its replacement, QtWebEngine, is not supported by the MinGW builds of Qt.
It appears my remaining options are one of
Maintain a custom build of Qt that reincludes the old QtWebKit code.
Embed some other rendering engine.
Launch a web browser in a separate process and embed its window in the main program.
I have looked into the first two options, and both sound like a bit of a PITA with a combination of outdated/abandoned code, and complicated build processes with patchy/outdated/conflicting documentation, and limited Windows support.
I've decided to explore the option of embedding a web browser process into my application. I've been successful at getting a firefox process embedded in PyQt using QWindow::fromWinId and QWidget::createWindowContainer
self.process = QtCore.QProcess()
self.process.setProgram('C:/Program Files (x86)/Mozilla Firefox/firefox.exe')
self.process.start()
time.sleep(1)
hwnd = get_window_handle(self.process.processId())
ext_win = QtGui.QWindow.fromWinId(hwnd)
widget = QtWidgets.QWidget.createWindowContainer(ext_win)
widget.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.ForeignWindow)
self.layout().addWidget(widget)
I can drag and drop html files into the embedded firefox window and they load just fine. I thought I might be able to exploit this feature by faking drag/drop events in order to programatically load files.
def fakeDragDropEvent(self, urls):
point = QtCore.QPoint(self.width()/2, self.height()/2)
self.mimedata = QtCore.QMimeData()
self.mimedata.setUrls(urls)
dragevent = QtGui.QDragEnterEvent(point, QtCore.Qt.CopyAction, self.mimedata, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier)
app.postEvent(self, dragevent)
time.sleep(0.1)
dropevent = QtGui.QDragEnterEvent(point, QtCore.Qt.CopyAction, self.mimedata, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier)
app.postEvent(self, dropevent)
These fake events can be picked up by the main window etc when I implement event handlers and set acceptDrops(True), however they seem to have no effect on the embedded process window.
Is there any way to make my embedded process window pick up these events? Or do I maybe need to program the drag/drop events using the native Windows API instead?
I'm also open to any other suggestions about how I can display html in my application.

Is there a list of Gtk2 widgets?

Is there a list of Gtk2 widgets along with screenshots or demonstrations somewhere? I want to find out what a widget is called.
You are looking for the widget gallery.
Also, there should be a demonstration program installed along with GTK; try running gtk-demo at your terminal (gtk3-demo for GTK 3.)

Carbide / Symbian C++ - Change Application Icon

I am using Carbide (just upgraded to 2.0) to develop an S60 3rd Edition application.
I would like to know the easiest way to change the icon (both the application icon on the device menu and the icon at the top left of the main view) because I have the need to skin my application in many different ways as easily as possible.
All my efforts with messing around with .mif files have so far failed. I have a 44x44 .svg icon I made with Illustrator, could someone please help me in the right direction?
Thanks!
To change the app icon when you run your app use (in the status bar):
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknContextPane* cp=(CAknContextPane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidContext));
_LIT(KContextBitMapFile, "my_bitmap_file.mbm");
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmBitmap);
CleanupStack::PushL(bitmap);
CFbsBitmap* bitmapmask = iEikonEnv->CreateBitmapL(KContextBitMapFile, EMbmBitmapMask);
CleanupStack::PushL(bitmapmask);
cp->SetPicture(bitmap, bitmapmask);
CleanupStack::Pop(); // bitmapmask
CleanupStack::Pop(); // bitmap
DrawNow();
I'm not aware of any possibility of changing the app icon in the menu list programmatically, other than reinstalling the app with different mif file.
If you want to change the icon in your SIS file and then overinstall it on device then you may have to reboot your device after installation - the application icon is in the Symbian cache and is not updated.
http://wiki.forum.nokia.com/index.php/CS000808_-_Creating_and_adding_an_icon_to_an_S60_3rd_Edition_application
With latest QMake and Qt SDK (4.6.2) you don't need to create any .mif file yourself. An SVG file will do.
For more detailed instructions see: How to Set Qt Application Icon and Title in Symbian S60.
Although the article uses Qt Creator, as long as you use QMake then it's the same thing.