2、输入程序代败态橡码。
3、如果代码很少,比如只有一行的,可以在打开的编辑器中直接输入程序代码新建窗口。
4、如果程序代码较长的,点击File—NewFile新建程序窗口。
参考下面代码,OnClick里面可以获得button对象,然后取得其位置:'''
Created on 2011-10-13
@author: legendxx
'''
import wx
class ButtonFrame(wx.Frame):
btnno=0
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Button Example',
size=(200, 200))
self.panel = wx.Panel(self, -1)
for i in range(0,3):
text="Button"+str(i+1)
button = wx.Button(self.panel, -1, text, pos=(50, 20+i*50))
self.Bind(wx.EVT_BUTTON, self.OnClick, button)
#self.button.SetDefault()
def OnClick(self, event):
btn=event.GetEventObject()
print btn.GetPosition()
info="button postion:"+str(btn.GetPosition())
wx.MessageBox( info,'postion Info',
wx.OK | wx.ICON_INFORMATION)
#self.AddBtn()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = ButtonFrame()
frame.Show()
app.MainLoop()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)