I intend to makea wx python application that can request and show the google map (or map from another similar map service) for a specific set of coordinates.
The application should:
Show a particular section of the map, rather than the whole screen.
Be able to adjust the resolution/magnification of image.
Be able to show map view and satelite image.
Where do I start?
Where to start:
import wx
Now that I have that out of my system :-) ... The first place you should start is to determine if wx can host a browser capable of displaying google maps. wxPython on windows can natively host IE so you could use that for displaying google maps on windows. (Dig around in the demo)
I am not sure if you can host Mozilla or Chrome inside a wx application. So, first determine if you can even display google maps in a wx app.
There is no pre-made widget that can do this for you. wxPython does have a WebView widget, starting in wxPython 2.9, that uses a web browser on the backend and is a bit more robust than the ActiveX version of the widget that was in older versions of wx. You could use that to display the map. Note that you will still need to figure out how to send Google API commands to the wrapped browser instance to manipulate the map.
You might also take a look at PySlip, which can be used to display large images in a tiled manner: https://code.google.com/p/pyslip/wiki/Introduction
Related
I am trying to make a GUI application to control my robot. The purpose of the GUI is to be able to call appropriate services/publish some data when the button is pressed. I have been able to do these by connecting the callbacks of the button elements to the ROS2 service callbacks/publisher callbacks. I am currently using RViz to visualise my robot and the environment. I would like to embed the RViz GUI within my PyQt5 GUI, so that I can see the robot and interact(rotate, zoom, etc.) with the robot, but inside my GUI.
I attach an example of what it should look like in the image below:
I know that I can publish the camera feed as images using TextLabels, but this would defeat my purpose of being able to interact with the environment within RViz. Does anybody know how to do that, or have a minimal example of how I can embed RViz inside my PyQt5 app? I am completely new to GUI development, which is why I am facing some issues with understanding what sort of QWidget I would need to use.
Thanks in advance for your help!
At the moment rviz2 doesn't seem to have Python bindings. It's been requested as a feature though. Check the following issue for updates on its implementation:
https://github.com/ros2/rviz/issues/640
Rviz for ROS 1 does have Python bindings. See the following tutorial for how to integrate rviz visualization frames into your pyqt5 application:
http://docs.ros.org/en/melodic/api/rviz_python_tutorial/html/index.html
You could possibly use the ros1_bridge to interface an rviz1 application to ROS 2:
https://github.com/ros2/ros1_bridge
I want to retrieve information from a tooltip in the system tray programmatically.
The image shows the tooltip.
Now, I found that by using Microsoft's inspect.exe, which is "a Windows-based tool that enables you select any UI element and view the element's accessibility data", that it is in theory possible to retrieve this value programmatically.
Hovering over the the pandora icon in the toolbar shows me the following properties
It shows one property "name" that contains the exact data I need. I'm unsure how to retrieve this value programmatically using the win32api. I have a hwnd to the pandora icon already.
Additionally, a different ui spy tool, UiSpy.exe calls this same property "helpText" (different song name :p)
I tried using getWindowText(pandoraSystrayIconHwnd) but that returns a different text. Does anyone know what this "name" value is, and how I can retrieve it using the win32api? It should be possible because inspect.exe is an external program that can access the data somehow
I'm doing this in Python, as the target application is written in Python already.
These spy apps are probably using Active Accessibility and/or UI Automation.
You can try calling AccessibleObjectFromWindow on the toolbar HWND or AccessibleObjectFromPoint if you care about the mouse position and then call IAccessible::get_accName.
Keep in mind that the classname and window hierarchy of the tray icon toolbar is undocumented.
If you only care about Pandora and not other applications then I would strongly suggest that you look for other alternatives first. Perhaps they have a hidden window with the title etc.
If you don't mind hacks then you could take a look at TraySaver, it is open source and knows the internal format of the data stored for each icon in the tray toolbar. Keep in mind that it is pretty old and might not work on newer versions of Windows. If you go down this path (and I don't recommend it) then you have to remember that you need to support both 32-bit and 64-bit Explorer.
Maybe GUI automation library pywinauto could help you. It uses Win32 API or UI Automation under the hood (by your choice). Core concept is described in the Getting Started Guide.
Method .window_text() returns exactly the same as Name property shows in Inspect.exe.
To interact with tray area icons you can use this example on StackOverflow.
I've searched on Google and StackOverflow but am having trouble finding the answer, even though it seems like it should be easy to do.
How can I use Python to load a URL into its own window, rather than in a browser? I imagine this should be trivial in Tkinter or some other GUI package.
Yeah. that's very easy with QWebView in PyQt/PySide
You basically instantiate a new QWebView and pass the url to it
QWebView.load(QUrl('http://www.www.pythoncentral.io'))
you can read more here
http://pythoncentral.io/pyside-pyqt-tutorial-qwebview/
and also in the pyQt docs
http://pyqt.sourceforge.net/Docs/PyQt4/qwebview.html
A new option would be: pywebview
pywebview is a lightweight cross-platform wrapper around a webview
component that allows to display HTML content in its own native GUI
window. It gives you power of web technologies in your desktop
application, hiding the fact that GUI is browser based.
See here:
https://github.com/r0x0r/pywebview
I am developing the GUI for my application using wxpython and have most of the features down, except in the main frame/window I want to have a box for choosing a file (in this case, the input will have to be an excel file). Something similar to the standard filebrowser that is accessed whenever you choose "open" from a menu.
Below is an image to show exactly what I want...
You probably want a wx.FileDialog. It provides access to the default file dialog of the OS your app is running in. You can see an example of how it's used in the wxPython demo package. This tutorial also has some screenshots and sample code:
http://www.blog.pythonlibrary.org/2010/06/26/the-dialogs-of-wxpython-part-1-of-2/
The screenshot you show appears to be an interface to actually open the dialog. You can easily create that using sizers and basic widgets. Then just bind the open button to a handler that will show the dialog.
You might also want to take a look at the FileBrowseButton from wx.lib.filebrowsebutton (also in the demo).
There are a few other related widgets which you might be interested in too: wx.DirDialog, MultiDirDialog or wx.GenericDirDialog.
Assuming you know the basics of wxPython you can use wx.GenericDirCtrl and wx.ListCtrl to make nice browser
I'm writing a simple OSX app using Python and PyObjC. I designed the settings dialog using Interface Builder and I use ibtool to compile it, then load it from Python. The problem is how to access the controls I have in this window from the Python code? I played around with iPhone development a bit before and I remember I need to have an IBOutlet in the controller class which will be connected to the UI control in the interface builder. It should look something like this in Python:
class MyClass(NSObject):
my_outlet = objc.IBOutlet('my_outlet')
But since I'm not working in XCode (all I have is a .py file and a .xib file), Interface Builder doesn't know about my outlets. How can I do the binding in this case? Or how else can I access the UI elements from the code?
First, the use of Xcode or not has nothing to do with NIB loading (beyond making it more convenient).
As Ole said, you can use IB to manually add the outlet's you need to file's owner or to the custom object instances that you have in the NIB file. By doing so, it will all "just work".
However, this statement is what prompted my relatively similar answer:
all I have is a .py file and a .xib
file
Are you trying to write a bit of UI code outside of a .app wrapper? If so, that is a wholly unsupported pattern, very difficult to get correct, and quite likely to break across software updates or major releases (as it has many times in the past).
The best way to solve your problem is to use an Xcode project and build a standard application. The templates are no longer shipped with the dev tools. Just download them separately.
If you need to run it from the command line, you can still do so.
I haven't tried this, but you can also define outlets directly in IB. Open the Library panel, select Classes in the segmented control at the top and select your custom class you want to define an outlet for. Let's say you have a NSWindow subclass called MyWindow. Select the NSWindow class in the list, click on the action button at the bottom left, select New Subclass... and name it MyWindow. Now switch to the Outlets tab and create a NSButton outlet for your window. Now you connect a button to the outlet.
I don't know how this will transfer to PyObjC but I'd love to see your results when you try it out.