Hi All,
I am new to wxPython.I have made a simple GUI that contains a button and by
pressing that button i am calling another .py file(top_block.py)...But i am
getting error using the command:

top_block.start()

The error is:

AttributeError: 'module' object has no attribute 'start'

The code is as attached.I am using python 2.7.3.Any improvements in the
code are also welcome.The same error is received when i
use'top_block.run()'.Is there any alternative to this commands?

Regards,
Ali
import wx




class MyApp(wx.App):
	def OnInit(self):
		self.frame = MyFrame(None, title="The Main Frame")
		self.SetTopWindow(self.frame)
		self.frame.Show()
		return True
class MyFrame(wx.Frame):
	def __init__(self, parent, id=wx.ID_ANY, title="",
	pos=wx.DefaultPosition, size=wx.DefaultSize,
	style=wx.DEFAULT_FRAME_STYLE,
	name="MyFrame"):
		super(MyFrame, self).__init__(parent, id, title,
		pos, size, style, name)
		# Attributes
		self.panel = wx.Panel(self)
		self.panel.SetBackgroundColour(wx.BLACK)
		self.button3=wx.Button(self, -1, ' Execute ', wx.Point(235, 90),
                 wx.DefaultSize)
        	self.Bind(wx.EVT_BUTTON, self.Execute,self.button3)
       		

    	def Execute(self,event):
		import top_block
		top_block.start()
        
	
	
if __name__ == "__main__":
	app = MyApp(False)
	app.MainLoop()
import os
import wx
class MyApp(wx.App):
	def OnInit(self):
		self.frame = MyFrame(None, title="Bitmaps")
		self.SetTopWindow(self.frame)
		self.frame.Show()
		return True
class MyFrame(wx.Frame):
	def __init__(self, parent, id=wx.ID_ANY, title="",
		pos=wx.DefaultPosition, size=wx.DefaultSize,
		style=wx.DEFAULT_FRAME_STYLE,
		name="MyFrame"):
		super(MyFrame, self).__init__(parent, id, title,
		pos, size, style, name)
		# Attributes
		self.panel = wx.Panel(self)
		img_path = os.path.abspath("a.png")
		bitmap = wx.Bitmap(img_path, type=wx.BITMAP_TYPE_ANY)
		self.bitmap = wx.StaticBitmap(self.panel,bitmap=bitmap)


	

if __name__ == "__main__":
	app = MyApp(False)
	app.MainLoop()

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to