ArtProvider mit eigenen Grafiken

Plattformunabhängige GUIs mit wxWidgets.
Antworten
hmueller
User
Beiträge: 39
Registriert: Montag 27. November 2006, 16:07
Wohnort: Linz, Oberösterreich

Hallo,

in meinem Programm funktioniert das schon ganz gut, per wx.ArtProvider die Standardicons zu verwenden.

Es wäre aber nicht schlecht, wenn man das ganze etwas umdesignen könnte, deshalb wollte ich den ArtProvider durch einen eigenen ersetzen.
Leider ist die Dokumentation im Netz da spärlich, und es ist mir nicht klar, was man da beim Ableiten von dieser Klasse wirklich ersetzen muss.
Ausserdem: reicht dann statt

Code: Alles auswählen

self.artprovider = wx.ArtProvider()
einfach

Code: Alles auswählen

self.artprovider = myArtProvider()
oder was war damit?

Code: Alles auswählen

wx.ArtProvider.Push(myArtProvider())
Ich wäre echt dankbar, wenn jemand ein ordentliches Verwendungsbeispiel hätte.
H.
I must not fear. Fear is the mind-killer. Fear is the little death that brings total obliteration.
I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path.
hmueller
User
Beiträge: 39
Registriert: Montag 27. November 2006, 16:07
Wohnort: Linz, Oberösterreich

Also mal hier ein paar Zeilen, wie weit es mal bei mir geht...

Code: Alles auswählen

wx.ArtProvider.PushProvider(Art.FreeArtProvider())
und die eigene Implementierung im Modul "Art":

Code: Alles auswählen

from wx import BitmapFromImage

class FreeArtProvider(wx.ArtProvider):
    
    def __init__(self):
        wx.ArtProvider.__init__(self)
        
    def CreateBitmap(self, artid, client, size):
        bmp = wx.NullBitmap
        #Possible clients:
            # wx.ART_TOOLBAR
            # wx.ART_MENU
            # wx.ART_FRAME_ICON
            # wx.ART_CMN_DIALOG
            # wx.ART_HELP_BROWSER
            # wx.ART_MESSAGE_BOX
            # wx.ART_BUTTON
            # wx.ART_OTHER
        ####################################
        # return bitmap according to artid #
        ####################################
        # wx.ART_ADD_BOOKMARK
        # ...
        # wx.ART_GO_HOME
        # wx.ART_FILE_OPEN
        if artid == wx.ART_FILE_OPEN:
            img = GetImageFromCustomResourceDummyMethod()
            img = img.Scale(size.x, size.y)
            bmp = BitmapFromImage(img)
        # wx.ART_FILE_SAVE
        # ...
        return bmp
Vielleicht hilft das jemandem, der die gleichen Fragen hat wie ich... anscheinend hab ich das jetzt im Griff.
I must not fear. Fear is the mind-killer. Fear is the little death that brings total obliteration.
I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path.
Antworten