This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Python: Select Opaque inquiry

Tags: None
(comma "," separated)
User avatar
ren062408
Registered Member
Posts
29
Karma
0
OS

Python: Select Opaque inquiry

Mon Oct 29, 2018 6:25 am
Hi, I am working on a script that involves the use of the 'Select Opaque'. Been browsing the Class Reference for things I can use but no luck. The selection object doesn't seem to have such function. Is it possible to do a select opaque using python?

Also, since we are talking about something that can be found on the menu bar(Select>Select Opaque), can we use the things inside the menu bar using some lines of code? that would really make things more awesome.
User avatar
scottpetrovic
Registered Member
Posts
520
Karma
4
OS

Re: Python: Select Opaque inquiry  Topic is solved

Mon Oct 29, 2018 12:13 pm
For a lot of things in Krita that are on the UI like menus, you use "Actions". This is a PyQt class, so you have a lot of available things you can do with them. Krita just uses this concept for a lot of things...

from krita import *

# http://pyqt.sourceforge.net/Docs/PyQt4/ ... ction.html
# http://pyqt.sourceforge.net/Docs/PyQt4/qaction.html (has most of the properties you want)
for action in Krita.instance().actions():
print(action.text())

# call action to run its code
Krita.instance().action("next_frame").trigger()

Add an indent by the print line as this forum doesn't seem to handle multiple spaces
If you just print out a list of all available actions, that should get you an idea of all of the things you can do. Select Opaque should be one
User avatar
ren062408
Registered Member
Posts
29
Karma
0
OS

Re: Python: Select Opaque inquiry

Mon Oct 29, 2018 12:56 pm
scottpetrovic wrote:For a lot of things in Krita that are on the UI like menus, you use "Actions". This is a PyQt class, so you have a lot of available things you can do with them. Krita just uses this concept for a lot of things...

from krita import *

# http://pyqt.sourceforge.net/Docs/PyQt4/ ... ction.html
# http://pyqt.sourceforge.net/Docs/PyQt4/qaction.html (has most of the properties you want)
for action in Krita.instance().actions():
print(action.text())

# call action to run its code
Krita.instance().action("next_frame").trigger()
...

Wow, that was pretty enlightening. I got:
Code: Select all
Krita.instance().action("select_opaque").trigger()

Working great, thank you very much :)

By the way, you seem like you really know your stuffs in krita scripting, if you have the time, can you help me figure out what's happening here? viewtopic.php?f=139&t=155530


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]