本文整理汇总了Python中tkinter.ttk.Label.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Label.bind方法的具体用法?Python Label.bind怎么用?Python Label.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Label
的用法示例。
在下文中一共展示了Label.bind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: autoClicker
# 需要导入模块: from tkinter.ttk import Label [as 别名]
# 或者: from tkinter.ttk.Label import bind [as 别名]
class autoClicker(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.sliderTime=0
self.running = 0
self.leftclick = 0
self.middleclick = 0
self.rightclick = 0
self.parent.overrideredirect(True)
self.style = Style()
self.style.theme_use("default")
self.parent.wm_attributes("-topmost", 1)
self.parent.resizable(0,0)
self.gripBar = BitmapImage(data=GRIPBAR)
self.closeBox = BitmapImage(data=CLOSEBOX)
self.closeHover = BitmapImage(data=CLOSEHOVER)
self.leftClick = BitmapImage(data=LEFTCLICK)
self.leftClickDown = BitmapImage(data=LEFTCLICKDOWN)
self.middleClick = BitmapImage(data=MIDDLECLICK)
self.middleClickDown = BitmapImage(data=MIDDLECLICKDOWN)
self.rightClick = BitmapImage(data=RIGHTCLICK)
self.rightClickDown = BitmapImage(data=RIGHTCLICKDOWN)
self.barFrame = Frame(self)
self.barFrame.pack(side=TOP, fill=BOTH)
self.clickFrame = Frame(self, borderwidth=0)
self.clickFrame.pack(side=TOP, fill=BOTH, padx=12, expand=1)
self.sliderScale = Scale(self, from_=0, to=1, resolution=.01, orient=HORIZONTAL, borderwidth=0, showvalue=0)
self.sliderScale.pack(side=TOP, fill="x", expand=1)
self.buttonFrame = Frame(self, borderwidth=0)
self.buttonFrame.pack(side=TOP, fill=BOTH, expand=1)
self.grip = Label(self.barFrame, image=self.gripBar)
self.grip.image=self.gripBar
self.grip.pack(side=LEFT, fill="x")
self.grip.bind("<ButtonPress-1>", self.startMove)
self.grip.bind("<ButtonRelease-1>", self.stopMove)
self.grip.bind("<B1-Motion>", self.onMotion)
self.closeButton = Label(self.barFrame, image=self.closeBox)
self.closeButton.image=self.closeBox
self.closeButton.pack(side=RIGHT, fill="none")
self.closeButton.bind("<ButtonPress-1>", self.sysExit)
self.closeButton.bind("<Enter>", self.onHover)
self.closeButton.bind("<Leave>", self.onLeave)
self.leftClickToggle = Label(self.clickFrame, image=self.leftClick, borderwidth=0)
self.leftClickToggle.image=self.leftClick
self.leftClickToggle.pack(side=LEFT, expand=1)
self.leftClickToggle.bind("<Button-1>", self.leftToggle)
self.middleClickToggle = Label(self.clickFrame, image=self.middleClick, borderwidth=0)
self.middleClickToggle.image=self.middleClick
self.middleClickToggle.pack(side=LEFT, expand=1)
self.middleClickToggle.bind("<Button-1>", self.middleToggle)
self.rightClickToggle = Label(self.clickFrame, image=self.rightClick, borderwidth=0)
self.rightClickToggle.image=self.rightClick
self.rightClickToggle.pack(side=LEFT, expand=1)
self.rightClickToggle.bind("<Button-1>", self.rightToggle)
self.startButton = Button(self.buttonFrame, text="Start", relief=FLAT, activebackground="lightgrey", borderwidth=0)
self.startButton.pack(fill=BOTH, expand=1)
self.startButton.bind("<Button-1>", self.startClick)
self.startButton.bind("<space>", self.startClick)
w = 116
h = 74
ws = self.winfo_screenwidth() # width of the screen
hs = self.winfo_screenheight() # height of the screen
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.parent.config(bg="black")
self.pack(fill="both", padx=1, pady=1)
def leftToggle(self,event):
if self.running == 0:
if self.leftclick == 0:
event.widget.configure(image=self.leftClickDown)
self.leftclick = 1;
else:
event.widget.configure(image=self.leftClick)
self.leftclick = 0;
def middleToggle(self,event):
if self.running == 0:
if self.middleclick == 0:
#.........这里部分代码省略.........