Having trouble understanding using wxPython....:?:
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,wx.ID_ANY, title='Hello wolrd')
self.buthello = wx.Button(self, wx.ID_ANY, label ='helo')
self.buthello.Bind(wx.EVT_LEFT_DOWN, self.helloevent)
self.Show()
def helloevent(self, event):
msg = 'hello'
msgbox = wx.MessageDialog (self, message = msg, style = wx.OK)
if msgbox.ShowModal() == wx.ID_OK:
msgbox.Destroy()
app = wx.App(redirect = False )
frame = MainFrame()
app.MainLoop()
Q1. in the line 'wx.Frame.__init__', what is wx.ID_ANY, what is the purpose of it?.
Q2. Also self.buthello isnt defined anywhere? (confused here)
Q3. Also...
def helloevent(self, event):
how does 'event' work in here. Shouldnt it work without 'event'?
Q4. How can ShowModal be used in other cases?
import wx
app = wx.App()
frame = wx.Frame(None, -1, 'simple.py')
frame.Show()
app.MainLoop()
Q5. This is another tutorial i was looking at and on this it has used '-1' instead of wx.ID_ANY. whys that?
import wx
class Dockable(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
menubar = wx.MenuBar(wx.MB_DOCKABLE)
file = wx.Menu()
edit = wx.Menu()
view = wx.Menu()
insr = wx.Menu()
form = wx.Menu()
tool = wx.Menu()
help = wx.Menu()
menubar.Append(file, '&File')
menubar.Append(edit, '&Edit')
menubar.Append(view, '&View')
menubar.Append(insr, '&Insert')
menubar.Append(form, '&Format')
menubar.Append(tool, '&Tools')
menubar.Append(help, '&Help')
self.SetMenuBar(menubar)
self.Centre()
self.Show(True)
app = wx.App()
Dockable(None, -1, 'Dockable menubar')
app.MainLoop()
Q6....how does lines 7-23 work. Also the use of '&'..??
Any tips and tricks will be much appreciated:D:X