More

How to customize the visibility of buttons in QGIS?

How to customize the visibility of buttons in QGIS?


The built-in toolbar named "Composer" has an icon "Duplicate Composer".

I wish to toggle the visibility of this button in the toolbar.

How do I achieve this using pyqgis?


You probably moved on ages ago, but for anyone else with this problem, I found a hack'ish way to disable the Save button in all open composer windows:

for c in iface.activeComposers(): if c.isVisible(): w = c.composerWindow() # the QMainWindow of the print composer t = w.childAt(20,30) # its composer QToolBar t.setMovable(False) # to ensure nobody moves the toolbar which will mess with our logic b = t.childAt(18,12) # that toolbar's first QToolButton a = b.defaultAction() # that button's QAction a.setEnabled(False) # disable it ;-)

the QWidget's childAt method does the magic to return a reference to the objects we're interested in, so you could disable your "Duplicate Composer" button by increasing the first argument(x) ofb = t.childAt(18,12)until it works. In fact, this could theoretically be used to find and manipulate any object in the print composer window. The x/y coordinates are relative to the top left corner of the window.

Since the QGIS GUI is programmed to use standard size icons (24x24 pixels) and menu sizes no matter what resolution your screen is, this should be fairly reliable, but the further away from the origin you go the more you risk future QGIS button additions ruining your carefully crafted code.

I hope one day the QGIS devs will expose all composer widgets in the API just like they've done for the main QGIS interface, then we could do this properly…


How to display only one of the show/hide buttons using jquery?

I am stuck here. Here is what I am trying to do..If the image and description list are visible, only the hide button should be displayed. If the image and description list are hidden, only the show button should be visible. Here is what I tried to do:

Here is my js code: $(document).ready(function()< $("#hide").click(function()< $("img, dl").hide() >) $("#show").click(function() < $("img, dl").show() $(document).ready(function()< $('#show').hide() function clickHandler() < $('#hide').toggle('slow') $('#show').toggle('slow') >>) >) >) When the page loads only the hide button should show. If the image and description lists are not visible, the show button should be displayed. Both buttons are displayed when the page loads What is wrong with this?


You can touch the volume button and start sliding your finger left or right to adjust the volume up or down.

No need to lift your finger.

The same goes for the brightness as well.

You can change this via a 3rd party app, or you can set it using System Preferences.

  1. Open the System Preferences app.
  2. Select the Keyboard option (third row, sixth item or just search 'keyboard' and it will highlight itself)
  3. On the first tab (also called Keyboard), locate the dropdown for "Touch Bar shows" and choose "Expanded Control Strip".

This will give you this layout:

I suggest you to give Pock a try, you can set up the old volume up & volume down key on your touch bar in pock's preferences. Besides, it's a free app !


1 Answer 1

Your condition for visibility is checking whether RadioButton1 equals $GlobalConstant.True. But if you want the Stores Issues radio group to be displayed based on what's selected in the Call Category radio group, what you need to check is what the value of the radio button group is. In your example, RadioButton1 is a Choice resource, not a radio group.

If you want to display the Stores Issues radio group when the first radio button (RadioButton1) in the Call Category is selected, your criteria would be:

Your second group wasn't showing up in the start screen because the RadioButton1 Choice is of type Text, and you're comparing it to the boolean true. Assuming RadioButton1 has a text value, that comparison will always be false.


Customisation of the print view window

If you wish to customise the print view document, this can be done through the customize method of the print button type. This is a callback function that is executed when the print view document has been created, and gives you the ability to modify it to suit your needs. The function is given a single parameter - the window object for the print view document.

This simple example shows:

  • How an image can be inserted into the print view document using jQuery
  • The document's font-size can be adjusted to be suitable for printing
  • A class added to the table to improve its layout for printing
  • The font-size of the table set to match the main document's font-size.
Name Position Office Age Start date Salary
Tiger Nixon System Architect Edinburgh 61 2011/04/25 $320,800
Garrett Winters Accountant Tokyo 63 2011/07/25 $170,750
Ashton Cox Junior Technical Author San Francisco 66 2009/01/12 $86,000
Cedric Kelly Senior Javascript Developer Edinburgh 22 2012/03/29 $433,060
Airi Satou Accountant Tokyo 33 2008/11/28 $162,700
Brielle Williamson Integration Specialist New York 61 2012/12/02 $372,000
Herrod Chandler Sales Assistant San Francisco 59 2012/08/06 $137,500
Rhona Davidson Integration Specialist Tokyo 55 2010/10/14 $327,900
Colleen Hurst Javascript Developer San Francisco 39 2009/09/15 $205,500
Sonya Frost Software Engineer Edinburgh 23 2008/12/13 $103,600
Jena Gaines Office Manager London 30 2008/12/19 $90,560
Quinn Flynn Support Lead Edinburgh 22 2013/03/03 $342,000
Charde Marshall Regional Director San Francisco 36 2008/10/16 $470,600
Haley Kennedy Senior Marketing Designer London 43 2012/12/18 $313,500
Tatyana Fitzpatrick Regional Director London 19 2010/03/17 $385,750
Michael Silva Marketing Designer London 66 2012/11/27 $198,500
Paul Byrd Chief Financial Officer (CFO) New York 64 2010/06/09 $725,000
Gloria Little Systems Administrator New York 59 2009/04/10 $237,500
Bradley Greer Software Engineer London 41 2012/10/13 $132,000
Dai Rios Personnel Lead Edinburgh 35 2012/09/26 $217,500
Jenette Caldwell Development Lead New York 30 2011/09/03 $345,000
Yuri Berry Chief Marketing Officer (CMO) New York 40 2009/06/25 $675,000
Caesar Vance Pre-Sales Support New York 21 2011/12/12 $106,450
Doris Wilder Sales Assistant Sydney 23 2010/09/20 $85,600
Angelica Ramos Chief Executive Officer (CEO) London 47 2009/10/09 $1,200,000
Gavin Joyce Developer Edinburgh 42 2010/12/22 $92,575
Jennifer Chang Regional Director Singapore 28 2010/11/14 $357,650
Brenden Wagner Software Engineer San Francisco 28 2011/06/07 $206,850
Fiona Green Chief Operating Officer (COO) San Francisco 48 2010/03/11 $850,000
Shou Itou Regional Marketing Tokyo 20 2011/08/14 $163,000
Michelle House Integration Specialist Sydney 37 2011/06/02 $95,400
Suki Burks Developer London 53 2009/10/22 $114,500
Prescott Bartlett Technical Author London 27 2011/05/07 $145,000
Gavin Cortez Team Leader San Francisco 22 2008/10/26 $235,500
Martena Mccray Post-Sales support Edinburgh 46 2011/03/09 $324,050
Unity Butler Marketing Designer San Francisco 47 2009/12/09 $85,675
Howard Hatfield Office Manager San Francisco 51 2008/12/16 $164,500
Hope Fuentes Secretary San Francisco 41 2010/02/12 $109,850
Vivian Harrell Financial Controller San Francisco 62 2009/02/14 $452,500
Timothy Mooney Office Manager London 37 2008/12/11 $136,200
Jackson Bradshaw Director New York 65 2008/09/26 $645,750
Olivia Liang Support Engineer Singapore 64 2011/02/03 $234,500
Bruno Nash Software Engineer London 38 2011/05/03 $163,500
Sakura Yamamoto Support Engineer Tokyo 37 2009/08/19 $139,575
Thor Walton Developer New York 61 2013/08/11 $98,540
Finn Camacho Support Engineer San Francisco 47 2009/07/07 $87,500
Serge Baldwin Data Coordinator Singapore 64 2012/04/09 $138,575
Zenaida Frank Software Engineer New York 63 2010/01/04 $125,250
Zorita Serrano Software Engineer San Francisco 56 2012/06/01 $115,000
Jennifer Acosta Junior Javascript Developer Edinburgh 43 2013/02/01 $75,650
Cara Stevens Sales Assistant New York 46 2011/12/06 $145,600
Hermione Butler Regional Director London 47 2011/03/21 $356,250
Lael Greer Systems Administrator London 21 2009/02/27 $103,500
Jonas Alexander Developer San Francisco 30 2010/07/14 $86,500
Shad Decker Regional Director Edinburgh 51 2008/11/13 $183,000
Michael Bruce Javascript Developer Singapore 29 2011/06/27 $183,000
Donna Snider Customer Support New York 27 2011/01/25 $112,000
Name Position Office Age Start date Salary
  • Javascript
  • HTML
  • CSS
  • Ajax
  • Server-side script
  • Comments

The Javascript shown below is used to initialise the table shown in this example:

In addition to the above code, the following Javascript library files are loaded for use in this example:

The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:

This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:

The following CSS library files are loaded for use in this example to provide the styling of the table:

This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.

The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side processing scripts can be written in any language, using the protocol described in the DataTables documentation.


How To Create a Custom Radio Button

Example

/* Customize the label (the container) */
.container <
display: block
position: relative
padding-left: 35px
margin-bottom: 12px
cursor: pointer
font-size: 22px
-webkit-user-select: none
-moz-user-select: none
-ms-user-select: none
user-select: none
>

/* Hide the browser's default radio button */
.container input <
position: absolute
opacity: 0
cursor: pointer
height: 0
width: 0
>

/* Create a custom radio button */
.checkmark <
position: absolute
top: 0
left: 0
height: 25px
width: 25px
background-color: #eee
border-radius: 50%
>

/* On mouse-over, add a grey background color */
.container:hover input

.checkmark <
background-color: #ccc
>

/* When the radio button is checked, add a blue background */
.container input:checked

.checkmark <
background-color: #2196F3
>

/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after <
content: ""
position: absolute
display: none
>

/* Show the indicator (dot/circle) when checked */
.container input:checked

.checkmark:after <
display: block
>

/* Style the indicator (dot/circle) */
.container .checkmark:after <
top: 9px
left: 9px
width: 8px
height: 8px
border-radius: 50%
background: white
>


1 Answer 1

There are lots of ways to do this, but I would recommend against using an icon like the one you have chosen (which could be platform specific). The concept of more information is a bit abstract to represent with an icon that can easily translate across cultures.

If the information is to be shown in a overlay panel, then a downward arrow should be suitable:

This approach is how StackExchange displays more user information quickly in an overlayed panel:

Unless clicking the company name does something else, I would make clicking the company name or the arrow show the overlay panel.

If the arrow is not clear enough, I would add some text. Note that clicking more info or the arrow should trigger the overlay panel:

If the infromation is to be on it's own screen in the application, then it is better to just be explicit and use a button:

In this case, there is no mistake and confusion as to how the user can get more information about the company. You should also style the button to suit your application.


Finding and displaying color infrared imagery for the U.S.

If you need color infrared (false-color) photos for vegetation analysis, you may find these instructions useful. Many sites (e.g., the USDA Geo Gateway) strip the near-IR band from recent imagery to keep file sizes small. Fortunately, the complete, four-band images are available from the National Map web site. Keep reading to learn how to find and use CIR imagery.

3) Zoom in on your area of interest using either the scroll wheel on your mouse or the zoom tool at the top of the map window
4) Click the Download Data button You will be asked if you wish to define a download area by drawing a box, by using 1:24k quad sheets, by using the entire visible map, or by entering coordinates. Choose the first option (bounding box). Click and drag over your area of interest (AOI).


5) Next, you are presented with list of available data for your AOI. Choose Orthoimagery and click Next.

6) You will be shown a list of imagery available for your AOI. The first option, 10:1 Compressed NAIP, contains the 2010-2012 4-band imagery. (Note under “Band” these data are listed as 4B (red, green, blue, and near-infrared)). Check the box next to 10:1Compressed NAIP, then click Next.

7) Your ‘shopping cart’ will appear on the left side of your browser window. Click the Checkout button.

8) Enter your email address twice on the next screen and click Place Order.

9) You should see a confirmation of your order in a pop-up window. Click OK to dismiss the pop-up.

You will receive an e-mail message with links to your download. Note that orthophotos are distributed in 3.75-minute tiles, so each 7.5-minute (1:24,000 scale USGS quagrangle map) will be covered by four photos. A county may require several dozen images for complete coverage.

Four USGS 7.5-minute quads are shown in the image above (Point Nipigon, Cheboygan, Aloha, and Mullett Lake). Sixteen images would need to be downloaded to cover this

II. Displaying Color infrared (CIR) Imagery in ArcGIS

1) After downloading your images, start ArcMap and open a new map document.

2) Use the ArcCatalog tab or the Add Data tool to browse to your data folder. Add the downloaded images to your map. By default, ArcGIS will display the images using a standard, “visible color” scheme (red-green-blue).

3) Right-click on an image and choose Properties…

4) Choose the Symbology tab and change Red to Band_4, Green to Band_1, and Blue to Band_2. Click Apply, then OK.

5) Your image should change from primarily green to red (assuming you are viewing a forested or otherwise vegetated area).

The top image above is shown in standard (R-G-B) colors the one below in ‘false color’ NIR-R-G. Healthy, chlorophyll-rich green vegetation is depicted in reds and pinks in false color imagery. Note that Sherman Field, Michigan Tech’s football field, is artificial turf: it appears green to the naked eye (standard color image), but is nearly black on the CIR image. Infrared film was originally known as ‘camouflage detection film’ due to the ability to resolve ‘fake’ vegetation in this manner.

6) Repeat the band settings (changing to bands 4-1-2) for each image in your map.

III. Displaying Color Infrared (CIR) Imagery in QGIS

1) After downloading your images, start QGIS and open a new project document (loading a new, empty project document is the default behavior).

2) Use the Browser to view your data folder. If you don’t see the Browser, go to View > Panels and ensure that Browser is checked.

3) Next, expand the directory that contains the images you downloaded. Add any images you need by dragging them from the Browser to the map. By default, QGIS will display color imagery using a standard, “visible color” scheme (red-green-blue).

You could instead use the Add Raster Layer tool (above) to add your images but I find the Browser easier to use.

4) Right-click on an image in your Layers list and choose Properties

5) Select the Style panel. Set the Red band to display Band 4, the Green to Band 1, and the Blue to Band 2. Click Apply and then OK.

6) QGIS will now display your image in shades of red instead of green (assuming you are viewing a forested or otherwise vegetated area).

Note that conifers have different leaf cell structure and contain less chlorophyll than deciduous vegetation, so along with differences in texture (conifers often appear coarser), coniferous trees are usually darker on false-color imagery because they reflect less energy in the NIR band. A coniferous stand is highlighted in the two images above.


How to display EnumProperty control like radio buttons, while keeping the selection exclusive?

I have an EnumProperty set up on the Scene in the register function:

Now, elsewhere in the code I have a Panel, which is to display the 'enum' for selection:

So far so good, the control draws correctly, but not the way I want:

Thing is - I wanted a different appearance - I didn't want a dropdown field, instead I want a radio-button like field, as the one found for example here:

. where I can choose one of the options regarding the color mode (BW , RGB or RGBA).

I've found that I can put the "ENUM_FLAG" in the options field of the EnumProperty definition:

This too worked fine, the result I got now is this:

But now I can activate both buttons at once using Shift , and that's what I want to avoid:

So How can make the selection exclusive? How to force Blender to switch from one option to the other (or in other words: How to disable the Shift functionality)?


Watch the video: QGIS Font button demo