Guest user14912 Posted March 19, 2012 Report Share Posted March 19, 2012 Boas pessoal. É o seguinte, estou a tentar construir uma frame com uma imagem em python, com a biblioteca gráfica wx só que não estou conseguindo fazer o show da picture! =/ Estou a fazer algo de errado? import wx class testeFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,"biosignals - bioplux",size=(400,400),style=wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.MINIMIZE_BOX) #definir um painel de trabalho self.panel=wx.Panel(self) self.panel.SetBackgroundColour('light_grey') #nome inicial de login login_title="Efectue Login" font1 = wx.Font(15, wx.MODERN, wx.NORMAL, wx.BOLD) lyrics3 = wx.StaticText(self.panel, -1, login_title,(120,30), style=wx.ALIGN_CENTRE) lyrics3.SetFont(font1) self.bitmap = wx.Bitmap('img.png') wx.EVT_PAINT(self, self.OnPaint) self.Centre() def OnPaint(self, event): dc = wx.PaintDC(self) dc.DrawBitmap(self.bitmap, 60, 20) if __name__ == '__main__': app=wx.App() frame=testeFrame(parent=None,id=999) frame.Centre() frame.Show() app.MainLoop() Desculpem estas perguntas básicas, mas comecei agora a aprender python 😁 Obrigado desde já por esclarecimentos ! Link to comment Share on other sites More sharing options...
Pedro C. Posted March 20, 2012 Report Share Posted March 20, 2012 Sim há um problema no teu código. A partir do momento em que inseriste um painel deves desenhar a imagem no painel. def OnPaint(self, event): dc = wx.PaintDC(self.panel) dc.DrawBitmap(self.bitmap, 60, 20) A diferença para o teu código está na segunda linha no qual antes estava "self" e agora está "self.panel". Repara que provavelmente o teu programa estava a fazer a imagem no entanto ela aparecia por baixo do painel e evidentemente não é visivel ao utilizador. Link to comment Share on other sites More sharing options...
Guest user14912 Posted March 20, 2012 Report Share Posted March 20, 2012 Obrigado mesmo. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now