import wx
class twobuttonevent(wx.pycommandevent): //定義事件類twobuttonevent
def __init__(self, evttype, id)://初始化
wx.pycommandevent.__init__(self, evttype, id)
self.clickcount =0 // 計數為「0」
def getclickcount(self): //定義函式getclickcount(),返回計數值
return self.clickcount
def setclickcount(self, count): // 定義函式setclickcount(),設定計數值
self.clickcount = count
myevt_two_button = wx.neweventtype() //事件
evt_two_button = wx.pyeventbinder(myevt_two_button, 1) //事件繫結
class twobuttonpanel(wx.panel): //定義按鈕介面
def __init__(self, parent, id=-1, lefttext="left", righttext="right"): //初始化按鈕名
wx.panel.__init__(self, parent, id)
self.leftbutton = wx.button(self, label=lefttext) //例項化左按鈕
self.rightbutton = wx.button(self, label=righttext,pos=(100,0)) //例項化右按鈕
self.leftclick =false
self.rightclick =false
self.clickcount =0
self.leftbutton.bind(wx.evt_left_down, self.onleftclick)//按鈕事件繫結
self.rightbutton.bind(wx.evt_left_down, self.onrightclick)//按鈕事件繫結
def onleftclick(self, event): //定義左鍵單擊事件
self.leftclick =true
self.onclick()
event.skip()
def onrightclick(self, event): //定義右鍵單擊事件
self.rightclick =true
self.onclick()
event.skip()
def onclick(self): //定義單擊事件
self.clickcount +=1
if self.leftclickand self.rightclick:
self.leftclick =false
self.rightclick =false
evt = twobuttonevent(myevt_two_button, self.getid())
evt.setclickcount(self.clickcount)
self.geteventhandler().processevent(evt)
class customeventframe(wx.frame): //建立事件窗體customeventframe()
def __init__(self, parent, id): //初始化
wx.frame.__init__(self, parent, id, 'click count: 0', size=(300, 100))
panel = twobuttonpanel(self) //例項化 twobuttonpanel()
self.bind(evt_two_button, self.ontwoclick, panel) //事件繫結
def ontwoclick(self, event): //定義事件
self.settitle("click count: %s" % event.getclickcount()) //標題顯示計數
if __name__ =='__main__':
frame = customeventframe(parent=none, id=-1) //例項化窗體customeventframe
frame.show() //窗體顯示
C dataGridView右鍵選單
private void datagridview1 cellmousedown object sender,datagridviewcellmouseeventargs e 在datagridview中的currentrow屬性為唯讀,且其index也不能動態設定,故只能在datagridview...
flex右鍵選單
引用http blog.csdn.net liyong1115 archive 2008 05 15 2447393.aspx 例子1 import flash.ui.contextmenu import flash.ui.contextmenuitem import flash.events.co...
增加右鍵選單
增加右鍵選單 作業系統 windows xp dos視窗用的比較多,但不希望每次都從開始 執行,然後一步步的找到指定的路徑,感覺比較麻煩,就自己將其加右鍵選單中,手工操作還得在登錄檔中,執行中鍵入 regedit 按如下展開 key classes root shell 的其下建立項 開啟 dos視...