2014-07-06 24 views
0

我試圖編寫一個小函數,返回一個語句,如果雙擊事件發生,但我不知道這裏的正確語法和信息有點稀缺,我可以看到,明顯缺少的東西直覺可能是另一個參數。 double-button-1可以有人幫助/學校我真正快感謝!繼承人我得到了什麼:將按鈕單擊到事件陳述中的正確方法是什麼?

http://pastebin.com/VdQ39q2A(這裏是完整的代碼)

File "C:\Python27\lib\lib-tk\Tkinter.py", line 114, in _cnfmerge 
for c in _flatten(cnfs): 
TypeError: object of type 'instancemethod' has no len() 



self.label1 = Label(c, text="Blue Buff", fg="Blue",font=("",30)) 

def reset_timer(self): 
    if self.label1.event.type == ("<Double-Button-1>"): 
    return self.label1.configure(text="Blue Buff") 

def label_clicked_two(self,event): 
    self.label1.configure(self.reset_timer) 
    self.label1.update() 

self.label1.bind("<Double-Button-1>",self.label_clicked_two) 
+0

1)您在if語句末尾缺少冒號(:) – Chedy2149

+0

您使用的是什麼圖形ui庫? – Chedy2149

+1

這是Tkinter。我在前面的問題中看到了代碼。 – furas

回答

0

我做了一些例如與事件,但我們仍然不知道什麼是你的代碼的問題。

import Tkinter as tk 

def test(event): 
    print 'event:', event 
    print 'type:', event.type # 4 

master = tk.Tk() 

b1 = tk.Button(master, text="QUIT", command=master.destroy, width=20, heigh=5) 
b1.pack() 

b2 = tk.Button(master, text="OK", width=20, heigh=5) 
b2.pack() 

b2.bind('<Double-Button-1>', test) 

master.mainloop() 

event: <Tkinter.Event instance at 0x1c79128> 
type: 4 
+0

如果最好我的意思是我可以粘貼在整個程序中? – Achilles

+0

如果程序在一個文件中,請使用[pastebin.com](http://pastebin.com/)並粘貼鏈接。 – furas

+0

我在開幕式上張貼了鏈接。 – Achilles

相關問題