wxPython学習(4.マウスイベント処理)
1232 ワード
マウスイベント処理(一対のマルチイベント処理ではbuttonを使用してイベントをバインドし、buttonイベントソースとイベント処理者はそれぞれ2つのオブジェクトにあり、イベント処理者はウィンドウframeによって提供され、イベントソースはコンテンツパネルである)
イベントソースとイベント処理オブジェクトは同じです
(ウィンドウで左ボタンを押して、放して、マウスを動かして、左ボタンを押してマウスを引っ張って、マウスの状態を出力します)
イベントソースとイベント処理オブジェクトは同じです
(ウィンドウで左ボタンを押して、放して、マウスを動かして、左ボタンを押してマウスを引っ張って、マウスの状態を出力します)
#
import wx
# MyFrame
class MyFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None,title=" ",size=(400,300))
self.Centre()#
self.Bind(wx.EVT_LEFT_DOWN,self.on_left_down)
self.Bind(wx.EVT_LEFT_UP,self.on_left_up)
self.Bind(wx.EVT_MOTION,self.on_mouse_move)
def on_left_down(self,event):
print(' ')
def on_left_up(self,event):
print(' ')
def on_mouse_move(self,event):
print(' ')
if event.Dragging() and event.LeftIsDown():
# ,
pos = event.GetPosition()#
print(pos)
#
class App(wx.App):
def OnInit(self):
#
frame = MyFrame()
frame.Show()
return True
def OnExit(self):
print(' ')
return 0
if __name__ == '__main__':
app = App()#
app.MainLoop()#