Bonjour ,
J'ai réussis a créer un event sur sur image dans un scrolledwindow:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
 
import wx
 
class Affichage(wx.Frame):
    def __init__(self, titre):
        wx.Frame.__init__(self, None, 1, title = titre, size = (400, 400))
 
 
        self.graphicFilename = 'cowgirl_gunslinger_by_mjranum_stock.png'
        #pos_x,pos_y=self.win_scroll.GetViewStart()
        pos_x,pos_y=(0,0)
 
        sizer = wx.BoxSizer()#Sizer pour le win_scroll
 
        self.win_scroll=wx.ScrolledWindow(self)
 
        sizer.Add(self.win_scroll, 1, wx.EXPAND|wx.ALL, 2)
        self.SetSizer(sizer)
 
        self.img = wx.Image( self.graphicFilename, wx.BITMAP_TYPE_ANY )
        #self.img_bmp =self.img.ConvertToBitmap()
        self.img_bmp=wx.EmptyBitmap(200, 500)
 
        self.win_scroll.SetVirtualSize(wx.Size(self.img_bmp.GetWidth(),self.img_bmp.GetHeight()))
 
        #self.Pnl = wx.Panel(self,size=(200,200))
 
        self.static_bmp = wx.StaticBitmap(self.win_scroll, 1 ,self.img_bmp)
        self.win_scroll.SetScrollRate(1,1)#a verifier
 
        self.win_scroll.Scroll(0,0)
        self.win_scroll.Refresh()
 
        wx.EVT_LEFT_DOWN(self.static_bmp,   self.OnLeftDown)
 
    def OnLeftDown(self, event):
            pt_pos = event.GetPosition()  # position tuple
            print ('position mouse dans l image : = ' + str(pt_pos))
            self.SetTitle(str(pt_pos))
 
 
class MonApp(wx.App):
    def OnInit(self):
        fen = Affichage("Exemple 1")
        fen.Show(True)
        self.SetTopWindow(fen)
        return True
 
app = MonApp()
app.MainLoop()
Jusque la pas de problème, mais je n'arrive pas a voir ou mettre "wx.EVT_LEFT_DOWN(self.static_bmp, self.OnLeftDown)" lorsque l'image n'est pas charger. Ca déclenche une erreur sinon comme le programme n'en détecte pas.

Sauriez vous la manière dont il faut le placer pour éviter qu'il ne se déclenche avant qu'une image soit chargé?

Bonne journée,