Please help me with this code. I want to display image in the frame :
import wx
import os
class frame(wx.Frame):
'''frame class that display an image'''
def __init__(self, image, parent=None, id=-1,
pos=wx.DefaultPosition, title='Hello, wxPyhton!'):
'''creat a frame instance and display image.'''
temp = image.ConvertToBitmap()
size = temp.GetWidth(), temp.GetHeight()
wx.Frame(parent, id, pos, title, size)
self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)
class App(wx.App):
'''Application class.'''
def OnInit(self):
image = wx.Image('clem.jpg', wx.BITMAP_TYPE_JPEG)
self.frame = frame(image)
self.frame.Show()
return True
if __name__ == '__main__':
app = App()
app.MainLoop()
But i got this error:
Traceback (most recent call last):
File "C:/PycharmProjects/WXPYHTON/hello.py", line 18, in OnInit
self.frame = frame(image)
File "C:/PycharmProjects/WXPYHTON/hello.py", line 11, in __init__
wx.Frame(parent, id, pos, title, size)
TypeError: Frame(): arguments did not match any overloaded call:
overload 1: too many arguments
overload 2: argument 3 has unexpected type 'Point'
OnInit returned false, exiting...
Process finished with exit code 1
please help this code. i don't know where i'm getting it wrong.
I've changed it but i'm still getting this error
Traceback (most recent call last):
File "C:/PycharmProjects/WXPYHTON/hello.py", line 18, in OnInit
self.frame = frame(image)
File "C:/PycharmProjects/WXPYHTON/hello.py", line 12, in __init__
self.bmp = wx.StaticBitmap(parent=None, bitmap=temp)
TypeError: StaticBitmap(): arguments did not match any overloaded call:
overload 1: 'parent' is not a valid keyword argument
overload 2: 'bitmap' is not a valid keyword argument
OnInit returned false, exiting...
please check my self.bmp, if it is correct. Thanks
You are not initialising the frame properly and you are using keywords as variable names.
Change:
wx.Frame(parent, id, pos, title, size)
To:
wx.Frame.__init__(self,parent,id,pos=pos,title=title,size=size)
and it should work.