How to let user select a CRS in QGIS Python plugin? - pyqt

I am currently developing a QGIS Plugin in python. In it, the user should be able to select a Coordinate Reference System (CRS). In QGIS built-in dialogs, there often is this window called "Coordinate Reference System Selector" which allows selection of recently used CRS, as well as other Systems and also a Information box and visualisation of the Bbox of the CRS.
Is there a way to replicate this? It would be very tideous to recreate all this informations and functionality. I would have excpected at least something CRS related in "QGIS custom widgets" in QT Designer, but I couldn't find anything.
Or if this isn't possible, is there at least a way to get all CRS's to display them in a Combobox?

You should be able to use QgsProjectionSelectionDialog:
from qgis.gui import QgsProjectionSelectionDialog
dialog = QgsProjectionSelectionDialog()
dialog.exec_()
crs = dialog.crs()
print(crs)
There is also QgsProjectionSelectionWidget if you want to embed it into your own dialog.

Related

Access to GTK4 Widgets in C Using Gnome Builder

I'm fairly new to coding for Linux, and haven't done a lot of GUI programming. I've run into problems using Gnome Builder and programmatic access to UI widgets.
How the heck to you access a widget (built in a UI file and instantiated by widget templates in the *-window.c source file) to do anything with the widget? I could use gtk_builder calls in GTK3 to access widgets, but the GTK4 model is completely different, and I haven't found useful information that describes or demonstrates how to do it.
There are 2 ways of doing this in GTK (both 3 and 4) with UI files:
Parse the UI definition using something like gtk_builder_new_from_resource(). You can then use API like gtk_builder_get_object() to fetch the widgets you want by their id attribute
Use composite templates like gtk_widget_class_bind_template_child(). You can find an example of how to do this in the second chapter of the GNOME beginners tutorial
Usually, the second option is preferred, as it tends to lead to less boilerplate code

Questions about Citymaps

1、I want to create a circle and set an image that customized to fill the circle,use this as a marker on the map, not only could change the image but also the color of circle anytime,what can I do to implements this function? Please look at the picture below!
2、Like your CityMaps app show,when I enlarge the map, some business icon that hide are show on the map,which are hide again while shrink the map, How to achieve this effect?
3、After I initialization the Object Marker and called the method marker.setFadeTime(3000),the software give my tips the method is no exist and I see the class Marker.java but really not find the method,Why is it so?
4、I want to add some stars beside the marker like this:
What can I do to add the stars?the label only can set the text beside the marker.
5、I want to load your maps at the fragment,not the activity that extends FragmentActivity,I found the SupportCitymapsMapFragment is no use,What I can do to complete this requirement?
6、In your apps,it is locate that place after input New York in the search box,What can i do to complete this function whatever i input?
7、During I develop the apps about the Citymaps,I found a serious problem so that your apps had happend too. When I run the apps, the program force flash back all of a sudden and I run your apps Citymaps at this time,the problems are same of the front,I found some error in logical view that is follows:15327-15374/com.map.maplbs A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 15374 (Thread-1819).
To solve the problem,I must restart my device. Why is it so?
I am a developer on the Citymaps SDK, I will do my best to answer your questions.
1) I recommend using the Android Canvas API to construct the images, and then use a Marker to display it on the map. See the documentation for details: http://developer.citymaps.com/markers
2) This is built into the Citymaps BusinessLayer. This functionality is not exposed through an API. If you wish to use the Citymaps BusinessLayer, you should create a CitymapsMapView or CitymapsMapFragment/SupportCitymapsMapFragment and it will automatically be added to your map.
3) At this time, there appears to be a known issue with the fadeTime API. Thank you for bringing this to our attention. We will fix it in an upcoming release. For now, you can animate the alpha property of the Marker.
4) Once again, the functionality of the BusinessLayer is not directly exposed. If you wish to create similar markers, I recommend you construct the image using Android's Canvas and then adding it as a Marker to the map.
5) If you wish to load the map inside of a fragment, you can accomplish this using child fragments (check Android documentation for more details). You can also accomplish this by instantiating CitymapsMapView or MapView directly and adding it to your view hierarchy either in XML or in code. However if you do this, remember to call the lifecycle methods on your map instance, or else the map will not behave properly.
6) If you wish to have a search in your app, it is up to you to implement this feature. We do not currently provide a search API out of the box.
7) Thank you for the bug report. We will investigate this issue and fix it in a future release.
If you have any more questions, feel free to ask, and thank you for using the Citymaps SDK.

How do you make a template for screens in ScreenManager?

I was wondering how you make a template for screens in kivy using ScreenManager.
I want to be able to have a template that will create screens with a grid layout in which I can change the background image of the screen and add a label and button to it.
I tried using
[ScreenMenu#BoxLayout]:
Button:
text: ctx.title
Image:
source: ctx.image
And then using
screen1 = Builder.template('ScreenMenu', title='Hello', image='C:/Users/mmoma_000/Pictures/Wallpapers/aot.png')
But I can't access the screens it makes (if it even successfully makes a screen)
I assume I will need to do something about adding the widgets to screen manager but I'm not sure what that is.
Any help is appreciated, thanks.
Templates are deprecated, don't use them, use dynamic classes instead.
I don't know exactly what your problem is though. Are you using Builder in the kv file or in python?
Of course, you could also solve the problem by just using a normal class.

How to change Nokia full touch lwuit form header color

I want to to change the header color of nokia lwuit based full touch form and i have tried setTitleComponent method but it is not working. Please also check the following link
http://projects.developer.nokia.com/LWUIT_for_Series_40/wiki/UsingSeries40FullTouchFeatures
in which it is mentioned we cannot style the header but is it means we cannot change the bgcolor as well or put custom images in the header?
Note that when using LWUIT for Series 40 port, the default way of running LWUIT apps is a normal-size canvas in Series 40 full touch devices. Thus the Series 40 chrome shows on top of canvas. And there is no way of customising it (other than the title text).
If you want to provide branding elements to the title, the options are:
1. create an additional lable below the Series 40 headerbar
2. run the application in full-screen. We are planning to create a high-level API for this but currently it is already possible using the following trick:
((GameCanvas) (javax.microedition.lcdui.Display.getDisplay(this)).getCurrent()).setFullScreenMode(true);
In the latter option you will of course lose the Series 40 full touch layout.
Use lwuit source, you can change method visibility if required, this is example what i used to use gradient color
form.getTitleComponent().getStyle().setBackgroundType(Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL);
form.getTitleComponent().getStyle().setBackgroundGradientEndColor(Color.GRADIENT_END);
form.getTitleComponent().getStyle().setBackgroundGradientStartColor(Color.GRADIENT_START);
form.getTitleComponent().getStyle().setFgColor(Color.WHITE);
form.getTitleComponent().getStyle().setPadding(10,10,0,0);
form.getTitleComponent().getStyle().setFont(font);
Here Color is my custom class that is used for color code, you can use your one.

OrchardCMS - Can't find correct alternative to render widget

I'm trying to add a image carousel to my CMS site and in the process learn about Alternatives.
I've go the following content types
BannerImage (TextField and a MediaPicker field)
ImageGallery (Container)
I've created a bunch of images, added them as 'Containables' to a new ImageGallery and
I then create a widget, put it in BeforeContent and it renders as an ugly list (default rendering)
I have been able to customize the images by using the alternative Content-BannerImage.Summary.cshtml, sweet.. so far so good.
BUT I'm not able to customize the rendering of the ImageGallery at all. The alternative
Content-ImageGallery.Summary.cshtml or .Detail or even Widget-Container.cshtml do not work at all.
The alternative that IS being used is Widget.Wrapper.cshtml which came with the theme I'm using. I'm not able to find the correct alternative so I can prevent the ImageGallery from rendering it's name/title (which it does by default from the Widget.Wrapper.cshtml alternative.
Any help is greatly appreciated and before it's mentioned... I've read http://docs.orchardproject.net/Documentation/Accessing-and-rendering-shapes which is a great doco, but I'm too dumb to figure it out :)
Ta
To create an alternate (not alternative) for a widget, you first have to activate the Widget Alternates module.
Once you have done so, create your widget, and activate the Shape Tracing module. Go to the page where the widget appears, click on the shape tracing button on the bottom right corner to show the shape tracing and select your widget.
You should now see a list of possible alternates for your widget. Select one and click the link to create it. Now you just have to edit it to your taste.
Depending on how the image gallery module you're using is working, the shape that you need to override to render the list of images. It is probably the List shape that you need to change. This article should give you a good starting point: http://weblogs.asp.net/bleroy/archive/2011/03/27/taking-over-list-rendering-in-orchard.aspx

Resources