#!/usr/bin/env python #-*-coding:UTF-8-*- import wx class MyFrame(wx.Frame): def __init__(self,*args,**kwds): kwds["size"]=(400,647) kwds["title"]=u"南京顺成网络公司" kwds["pos"]=(10,10) wx.Frame.__init__(self,*args,**kwds) self.move_id=0 #跟跟随鼠标移动的控件id self.move_ok=0 #是移动还是解除移动绑定 self.button_1=wx.Button(self,10,u"第一个按钮",pos=(50,20)) self.button_2=wx.Button(self,11,u"第二个按钮",pos=(150,20)) self.label_1=wx.StaticText(self,20,u"小咪咪") self.Bind(wx.EVT_CLOSE,self.exit) self.Bind(wx.EVT_MOTION,self.On_Move_Mouse) #鼠标移动时 self.button_1.Bind(wx.EVT_RIGHT_DOWN,self.b_right_down) #在按钮上按左键 self.button_2.Bind(wx.EVT_RIGHT_DOWN,self.b_right_down) self.label_1.Bind(wx.EVT_RIGHT_DOWN,self.b_right_down) self.Center() self.Show(True) def On_Move_Mouse(self,evt): if self.move_id==0 or self.move_ok==0:return x=evt.GetX() y=evt.GetY() mm=self.FindWindowById(self.move_id) if not mm:return mm.MoveXY(x,y) def b_right_down(self,evt): if self.move_ok!=0: self.move_ok=0 self.move_id=0 return self.move_id=int(evt.GetId()) self.move_ok=1 def on_click(self,evt): pass def exit(self,evt): i=self.msg("确定要退出程序吗?") if i : self.Destroy() def msg(self,mstr): if not str:return None mstr=mstr.decode("utf8") dlg=wx.MessageDialog(self,mstr,u"友情提示",wx.YES_NO) dlg.Show(True) if dlg.ShowModal()==wx.ID_YES: dlg.Destroy() return True else: dlg.Destroy() return False app=wx.App() win=MyFrame(None) app.SetTopWindow(win) app.MainLoop()