Reputation: 1
I m getting "expected indented block" error in below code : i am new to python please help
#!/bin/env python
import wx
class MyFrame(wx.Frame):
def __init(self):
wx.Frame.__init__(self, None, -1,"My Frame", size=(300,300))
panel = wx.Panel(self, -1)
panel.Bind(wx.EVT_MOTION, self.OnMove)
wx.StaticText(panel,-1,"POS:",pos=(10, 12))
self.PosCtrl = wx.TextCtrl(panel, -1,"",pos=(40, 10))
def OnMove(self, event):
pos = event.GetPosition()
Self.PosCtrl.SetValue("%s, %s" % (pos.x,pos.y))
if __name__ == '__main__':
app = wx.PySimpleApp
frame = MyFrame()
frame.Show(True)
app.MainLoop
Upvotes: 0
Views: 2224
Reputation: 29912
Your error is in the "if" block :)
if __name__ == '__main__':
app = wx.PySimpleApp
frame = MyFrame()
frame.Show(True)
app.MainLoop
This is the indentation error :)
Edit: i posted you the solution :)
Upvotes: 0
Reputation: 34688
From what you pasted you need to de indent the OnMove and fix the if name
Upvotes: 0
Reputation: 117661
Your indenting is completely strange, this is my best guess. I would suggest to try and learn Python more from the basics up.
#!/bin/env python
import wx
class MyFrame(wx.Frame):
def __init(self):
wx.Frame.__init__(self, None, -1,"My Frame", size=(300,300))
panel = wx.Panel(self, -1)
panel.Bind(wx.EVT_MOTION, self.OnMove)
wx.StaticText(panel,-1,"POS:",pos=(10, 12))
self.PosCtrl = wx.TextCtrl(panel, -1,"",pos=(40, 10))
def OnMove(self, event):
pos = event.GetPosition()
Self.PosCtrl.SetValue("%s, %s" % (pos.x,pos.y))
if __name__ == '__main__':
app = wx.PySimpleApp
frame = MyFrame()
frame.Show(True)
app.MainLoop
Upvotes: 5
Reputation: 6584
You should probably indent the code below if __name__ == '__main__':
.
Upvotes: 0