Am trying to display image in text control but it display only binary characters.
But is their any way I can archive this or its impossible dream to do it in wxpython
Please help I will need this agently. Thank you advance
Here are the source codes that I have so far
import wx
class MainFrame(wx.Frame):
def __init__(self,*args,**kwargs):
super(MainFrame,self).__init__(*args,**kwargs)
self.main_panel = MainPanel(self,-1)
class MainPanel(wx.Panel):
def __init__(self,*args,**kwargs):
super(MainPanel,self).__init__(*args,**kwargs)
img1 = wx.Image("coins.png", wx.BITMAP_TYPE_ANY)
w = img1.GetWidth()
h = img1.GetHeight()
img1 = img1.Scale(w/2, h/2)
sb1 = wx.StaticBitmap(self, -1, wx.BitmapFromImage(img1))
self.txtctrl = wx.TextCtrl(self,-1,"display image here",size=(500,300),pos=(20,10))
class App(wx.App):
def OnInit(self):
mainframe = MainFrame(None,-1,title="Display image in txt ctrl",size=(600,400))
mainframe.Show()
mainframe.Center()
return True
if __name__ == "__main__":
app = App();
app.MainLoop()
You cannot put an image directly inside a regular
wx.TextCtrl
widget. That is currently impossible as they just don't support that. However, you can put an image into aRichTextCtrl
widget. If you haven't downloaded it yet, be sure to get the wxPython demo from the project's website as it has a good example. Here are a couple links:If you just want to put an image in your application, then
wx.Image
is your friend (as John already mentioned).