I can only see one view, but multiple views have visible=True?

Win10, Krita 5.2.9

I’m trying to find out which document/view/canvas is visible to me (the user). I have the setting subwindows set since a long time ago because the tabs used up space. Same for scrollbars and status bar. I only ever use one “view” of a document.

If you have multiple documents open this should print

from krita import *
app = Krita.instance()
win = app.activeWindow()
for view in win.views():
    print(view, view.visible())
<PyKrita.krita.View object at 0x000002458109CA60> True
<PyKrita.krita.View object at 0x000002458109C670> True

Using PluginDevTools inspector I see each QWidget (KisView) has objectName like view_0, view_1, view_2, etc. It also shows the value for “visible” is also True for every single one.


My motivation here is I’ve been trying to make a simple indicator for if the view is mirrored, since I often lose track, especially when going between documents.

I have tried using signals, the notifier signals: viewCreated, viewClosed, and the window signal: activeViewChanged. The first 2 worked ok, but activeViewChanged seemed only to include opening a new document, and changing the view, but it didn’t really help since I still don’t know which “view” is active.

I also found the signal canvasMirrorModeChanged(bool) in a QAbstractScrollArea as a child of the view widget, but it seemed to not work once the view changed, or closed, or a new one opened.

Here is the plugin, it adds a new action (mirror view with indicator) that also runs the action “Mirror View” (internally named mirror_canvas… ok)

I believe a sticking point is line 60. If I knew which index to pick I guess I wouldn’t have much of an issue anymore :man_shrugging:
canvas_widget = opengl_widgets[0].parent().parent()

Relevant topic: Indicator that Mirror View is active

This should help on finding current view in Krita’s Window.

Side note: QMdiArea.subWindowActivated(sub_window) is nice signal that can be used to get signal on view changes.

from krita import Krita
from PyQt5.QtWidgets import QMdiArea

def iter_view_and_qview_pairs(window):
    qwindow = window.qwindow()
    qmdi_area = qwindow.findChild(QMdiArea)
    return iter(zip(window.views(), qmdi_area.subWindowList()))

# testing
app = Krita.instance()
window = app.activeWindow()
for view, qview in iter_view_and_qview_pairs(window):
    name = qview.widget().objectName()
    is_mirroring = view.canvas().mirror()
    is_current_view = qview is qview.mdiArea().currentSubWindow()
    print(f'{name = }, {is_mirroring = }, {is_current_view = }')

/AkiR

1 Like

There we are :partying_face: thanks AkiR

I should do some reading about krita themes/stylesheets, I can’t even remember if I changed my theme from the default, might be slightly lighter grey idk. May look completely out of place for someone else.

1 Like

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.