Jul-02-2018, 02:35 PM
(Jul-02-2018, 05:49 AM)Barrowman Wrote: Okay. So as I am learning I need some explanations as to how this works. I could not see how to fit these into a working program. I still can't figure out how to use it.
Also the combobox part you posted originally is not the same as the one in your reply.
At least I can see how it would change things if I could understand how a value of 0 for selection would be how to trigger a change in the image. What would happen if it was some other value?
hi, hi:
for example,you have n images.
image1.png
image2.png
Be careful, it has to be of the same resolution.for example,you have n images.
image1.png
image2.png
in the code below it has no image, so pay attention in
def change_image( self, event ):
program.py
import wx import wx.xrc wx.ID_CHANGE = 1000 ########################################################################### ## Class MyFrame1 ########################################################################### class MyFrame1 ( wx.Frame ): def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer2 = wx.BoxSizer( wx.VERTICAL ) self.image = wx.BitmapButton( self, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW ) bSizer2.Add( self.image, 0, wx.ALIGN_CENTER|wx.ALL, 5 ) self.buton = wx.Button( self, wx.ID_CHANGE, u"Change", wx.DefaultPosition, wx.Size( 80,60 ), 0 ) bSizer2.Add( self.buton, 0, wx.ALIGN_CENTER|wx.ALL, 5 ) self.SetSizer( bSizer2 ) self.Layout() self.Centre( wx.BOTH ) # Connect Events self.buton.Bind( wx.EVT_BUTTON, self.change_image ) def __del__( self ): pass # Virtual event handlers, overide them in your derived class def change_image( self, event ): event.Skip() #change code for: a)a)
self.image.SetBitmap(wx.Bitmap('image1.jpg'))
I used selection== 1 , because I work with combobox and this offers a list for example.
in combobox the selection starts from 0 to n, n is the limit that you have given to the list, so my code works like this:
selection = 0
selection = 1
selection = 2
in combobox the selection starts from 0 to n, n is the limit that you have given to the list, so my code works like this:
selection = 0
selection = 1
selection = 2
you just need to add the
if __main__== '__init__': #code execute class MyFrame1