Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-13 Thread WhereGroup

Hey AF,

oh, looks like the help() for those Qt objects is not as comprehensive 
as I hoped.


>>> type(iface.mainWindow().statusBar())


https://doc.qt.io/qt-5/qstatusbar.html ->
https://doc.qt.io/qt-5/qstatusbar-members.html ->
https://doc.qt.io/qt-5/qwidget.html#styleSheet-prop

>>> iface.mainWindow().statusBar().setStyleSheet("background-color:red;")

Now my status bar is red.

No idea about fonts...

Have fun!
Hannes

Am 13.12.22 um 03:40 schrieb afernandez:

Hello Johannes,
Querying was how I found the method 
self.iface.mainWindow().statusBar().styleSheet() along with many 
others. I circled back and tried to use 'help' to figure out what I 
was missing. However, help for 
self.iface.mainWindow().statusBar().styleSheet() only tells me that 
styleSheet is a method of the self.iface.mainWindow.statusBar instance 
that returns a string. I also explored another method 
self.iface.mainWindow().statusBar().setFont(), which is supposed to 
take a QFont, but I still haven't been able to make it work properly 
either.
The bottom line is that I can add widgets to the statusBar and style 
them, but even changing the font type for the whole statusBar remains 
elusive. At least this route allows me to move on with the project 
while I figure out all the other details.

Thanks,
AF


--
Johannes Kröger / GIS-Entwickler/-Berater

-
Where2B Konferenz 2022
15. Dezember 2022 in Bonn und Online
https://where2b-conference.com/
-

WhereGroup GmbH
Grevenweg 89
20537 Hamburg
Germany

Tel: +49 (0)228 / 90 90 38 - 36
Fax: +49 (0)228 / 90 90 38 - 11

johannes.kroe...@wheregroup.com
www.wheregroup.com
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
---
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-12 Thread afernandez via QGIS-Developer

Hello Johannes,
Querying was how I found the method
self.iface.mainWindow().statusBar().styleSheet() along with many others. I
circled back and tried to use 'help' to figure out what I was missing.
However, help for self.iface.mainWindow().statusBar().styleSheet() only
tells me that styleSheet is a method of the self.iface.mainWindow.statusBar
instance that returns a string. I also explored another method
self.iface.mainWindow().statusBar().setFont(), which is supposed to take a
QFont, but I still haven't been able to make it work properly either.
The bottom line is that I can add widgets to the statusBar and style them,
but even changing the font type for the whole statusBar remains elusive. At
least this route allows me to move on with the project while I figure out
all the other details.
Thanks,
AF
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-12 Thread WhereGroup

Hi  AF,

you can always query objects for their type with type(objectname) or 
even access their documentation in an interactive interpreter session 
with help(objectname). Then you know what methods and attributes they 
expose or which Qt documentation page is matching whatever object you 
are handling.


Be aware that pages like https://doc.qt.io/qt-5/qstatusbar.html only 
list the "direct" members and that the objects might have already 
inherited others. For that you can click the "List of all members, 
including inherited members" link.


CaSe matters! Best use an IDE that helps you with autocompletion and 
inspection, this helps a lot when learning. For PyCharm all you need to 
do is select the python-qgis.bat file as interpreter and let it scan the 
Python modules for a while.


When googling for QGIS Python classes, make sure you are reading 
up-to-date documentation matching your QGIS version, e. g. 
https://qgis.org/pyqgis/3.28/gui/QgisInterface.html


Cheers, Hannes

Am 12.12.22 um 01:42 schrieb afernandez via QGIS-Developer:

Hi Nyall,
Obviously I'm not an expert in Qt/QGIS (only been using it for a few 
weeks) and still have many things to learn. Most of the code works 
fine (by staying away from very complex structures) and styling 
widgets has been no problem until now when trying to do anything with 
the statusBar. From your comment, I went back to the 
PyQGISDeveloperCookbook(v3.22) and snippets like
    myicon = 
QIcon("/home/ubuntu/.local/share/QGIS/QGIS3/profiles/default/python/plugins/app/appicon.png")

iface.mainWindow().setWindowIcon(myicon)
iface.mainWindow().setWindowTitle("Tailoring QGIS")
had worked in the past. One problem has been to find specific 
documentation about iface.mainWindow().statusBar(), let alone examples 
and those online (e.g. 
https://gis.stackexchange.com/questions/210327/how-to-display-qgis-processing-bar-from-a-plugin) 
kind of suggests that my initial snippet could work. I'll continue 
reading the cookbook tomorrow but, in the meantime, is there any other 
documentation discussing iface in general or 
iface.mainWindow().statusBar() that I should also be reading? (Note: I 
also checked https://doc.qt.io/qt-5/qstatusbar.html)

Thanks,
AF
P.S. Again sorry about the extra messages that shouldn't have been 
sent to the thread (hopefully it won't happen again)




___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer


--
Johannes Kröger / GIS-Entwickler/-Berater

-
Where2B Konferenz 2022
15. Dezember 2022 in Bonn und Online
https://where2b-conference.com/
-

WhereGroup GmbH
Grevenweg 89
20537 Hamburg
Germany

Tel: +49 (0)228 / 90 90 38 - 36
Fax: +49 (0)228 / 90 90 38 - 11

johannes.kroe...@wheregroup.com
www.wheregroup.com
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
---
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-11 Thread afernandez via QGIS-Developer

Hi Nyall,
Obviously I'm not an expert in Qt/QGIS (only been using it for a few weeks)
and still have many things to learn. Most of the code works fine (by
staying away from very complex structures) and styling widgets has been no
problem until now when trying to do anything with the statusBar. From your
comment, I went back to the PyQGISDeveloperCookbook(v3.22) and snippets
like
myicon 
QIcon("/home/ubuntu/.local/share/QGIS/QGIS3/profiles/default/python/plugins/app/appicon.png")

iface.mainWindow().setWindowIcon(myicon)
iface.mainWindow().setWindowTitle("Tailoring QGIS")
had worked in the past. One problem has been to find specific documentation
about iface.mainWindow().statusBar(), let alone examples and those online
(e.g.
https://gis.stackexchange.com/questions/210327/how-to-display-qgis-processing-bar-from-a-plugin)
kind of suggests that my initial snippet could work. I'll continue reading
the cookbook tomorrow but, in the meantime, is there any other
documentation discussing iface in general or iface.mainWindow().statusBar()
that I should also be reading? (Note: I also checked
https://doc.qt.io/qt-5/qstatusbar.html)
Thanks,
AF
P.S. Again sorry about the extra messages that shouldn't have been sent to
the thread (hopefully it won't happen again)
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-11 Thread coder via QGIS-Developer

Hello Andrea,
Sorry for the delay as it has been a busy Sunday with several commitments.
I've been trying to implement your proposed solution using different
approaches but still unsucessfully (even after trying different
combinations). From several posts, a potential syntax would be something
like:
variable1 = self.iface.mainWindow().statusBar().styleSheet()
variable1.setstyleSheet("background-color: black;")
However, this is not effective and 'variable' is returning
QStatusBar::item{border: none;}, which I'm unsure how to intepret or how to
define the variable so that setstyleSheet can be applied.
I also tried a more simplified version (following the suggestion at
https://stackoverflow.com/questions/23490017/how-to-add-style-via-setstylesheet-without-losing-orignal-style-in-qt):

setstyleSheet("background-color: black;")
self.iface.mainWindow().statusBar().styleSheet()
However, it returns 'setstyleSheet' is not defined so it doesn't seem to
take setstyleSheet w/o an assignment. Do you have any suggestion on how you
would proceed?
Thanks,
AF
P.S. My apologies for the previous reply (it didn't go as anticipated)
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-11 Thread Nyall Dawson via QGIS-Developer
On Mon, 12 Dec 2022, 7:06 am afernandez via QGIS-Developer, <
qgis-developer@lists.osgeo.org> wrote:

> Hello Andrea,
> Sorry for the delay as it has been a busy Sunday with several commitments.
> I've been trying to implement your proposed solution using different
> approaches but still unsucessfully (even after trying different
> combinations). From several posts, a potential syntax would be something
> like:
> variable1 = self.iface.mainWindow().statusBar().styleSheet()
> variable1.setstyleSheet("background-color: black;")
> However, this is not effective and 'variable' is returning
> QStatusBar::item{border: none;}, which I'm unsure how to intepret or how to
> define the variable so that setstyleSheet can be applied.
> I also tried a more simplified version (following the suggestion at
> https://stackoverflow.com/questions/23490017/how-to-add-style-via-setstylesheet-without-losing-orignal-style-in-qt
> ):
> setstyleSheet("background-color: black;")
> self.iface.mainWindow().statusBar().styleSheet()
> However, it returns 'setstyleSheet' is not defined so it doesn't seem to
> take setstyleSheet w/o an assignment. Do you have any suggestion on how you
> would proceed?
>

Respectfully, your code has many fundamental issues. I would suggest
reading the qt documentation and getting a better grasp on qt and the qt
API before attempting to write this script.

Nyall

Thanks,
> AF
> P.S. My apologies for the previous reply (it didn't go as anticipated)
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-11 Thread afernandez via QGIS-Developer

Hello Andrea,
Sorry for the delay as it has been a busy Sunday with several commitments.
I've been trying to implement your proposed solution using different
approaches but still unsucessfully (even after trying different
combinations). From several posts, a potential syntax would be something
like:
variable1 = self.iface.mainWindow().statusBar().styleSheet()
variable1.setstyleSheet("background-color: black;")
However, this is not effective and 'variable' is returning
QStatusBar::item{border: none;}, which I'm unsure how to intepret or how to
define the variable so that setstyleSheet can be applied.
I also tried a more simplified version (following the suggestion at
https://stackoverflow.com/questions/23490017/how-to-add-style-via-setstylesheet-without-losing-orignal-style-in-qt):

setstyleSheet("background-color: black;")
self.iface.mainWindow().statusBar().styleSheet()
However, it returns 'setstyleSheet' is not defined so it doesn't seem to
take setstyleSheet w/o an assignment. Do you have any suggestion on how you
would proceed?
Thanks,
AF
P.S. My apologies for the previous reply (it didn't go as anticipated)
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-11 Thread afernandez via QGIS-Developer

Get BlueMail  for Desktop
afernandez via QGIS-Developer wrote:
Hello,
I'm facing some problems while trying to modify some of the properties of
the statusBar. For example, trying to use the styleSheet method with the
following snippet:
stilus = "background-color: black;"
self.iface.mainWindow().statusBar().styleSheet(stilus)
produces the error:
TypeError: styleSheet(self): too many arguments
It's like if styleSheet didn't take any parameter and I've been unable to
find similar uses online. [Note: Also tried modifying the syntax defining
the style (just in case) but it's always the same error]
Another problem is that I can add a string to the statusBar as in the
following example:
text = "CPU: "+cpu_nomen
self.iface.mainWindow().statusBar().showMessage(text)
This will output the string. However, doing anything of substance (e.g.
opening a plugin) erases the new text and I'm unsure how to make it
permanent.
Thanks,
AF
Hello,
I'm facing some problems while trying to modify some of the properties of
the statusBar. For example, trying to use the styleSheet method with the
following snippet:
stilus = "background-color: black;"
self.iface.mainWindow().statusBar().styleSheet(stilus)
produces the error:
TypeError: styleSheet(self): too many arguments
It's like if styleSheet didn't take any parameter and I've been unable to
find similar uses online. [Note: Also tried modifying the syntax defining
the style (just in case) but it's always the same error]
Another problem is that I can add a string to the statusBar as in the
following example:
text = "CPU: "+cpu_nomen
self.iface.mainWindow().statusBar().showMessage(text)
This will output the string. However, doing anything of substance (e.g.
opening a plugin) erases the new text and I'm unsure how to make it
permanent.
Thanks,
AF
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] Problems configuring the statusBar

2022-12-10 Thread Andrea Giudiceandrea via QGIS-Developer

Il 10/12/2022 18:06, afernandez via QGIS-Developer ha scritto:

self.iface.mainWindow().statusBar().styleSheet(stilus)
produces the error:
TypeError: styleSheet(self): too many arguments



Hi AF,
maybe you need to use setStyleSheet(const QString ) to set a 
style sheet.


Best regards.

Andrea Giudiceandrea___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] Problems configuring the statusBar

2022-12-10 Thread afernandez via QGIS-Developer

Hello,
I'm facing some problems while trying to modify some of the properties of
the statusBar. For example, trying to use the styleSheet method with the
following snippet:
stilus = "background-color: black;"
self.iface.mainWindow().statusBar().styleSheet(stilus)
produces the error:
TypeError: styleSheet(self): too many arguments
It's like if styleSheet didn't take any parameter and I've been unable to
find similar uses online. [Note: Also tried modifying the syntax defining
the style (just in case) but it's always the same error]
Another problem is that I can add a string to the statusBar as in the
following example:
text = "CPU: "+cpu_nomen
self.iface.mainWindow().statusBar().showMessage(text)
This will output the string. However, doing anything of substance (e.g.
opening a plugin) erases the new text and I'm unsure how to make it
permanent.
Thanks,
AF
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer