本文整理汇总了Python中tkinter.ttk.Button.after_cancel方法的典型用法代码示例。如果您正苦于以下问题:Python Button.after_cancel方法的具体用法?Python Button.after_cancel怎么用?Python Button.after_cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Button
的用法示例。
在下文中一共展示了Button.after_cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Aplicacion
# 需要导入模块: from tkinter.ttk import Button [as 别名]
# 或者: from tkinter.ttk.Button import after_cancel [as 别名]
class Aplicacion(Frame):
pi = pigpio.pi('192.168.15.4')
def __init__(self,parent):
Frame.__init__(self , parent)
self.enc1 = Encoder(21)
self.parent = parent
self.conexion = True#is_connected()
self.est_pinza = 1
self.est_subebaja = 1
self.initUI()
def initUI(self):
for i in range(4):
self.columnconfigure(i, pad=3)
for i in range(4):
self.rowconfigure(i, pad=3)
#self.listBox()
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
self.fischerpi()
self.parent.geometry('%dx%d' % (sw/4, sh/4))
self.pack()
def fischerpi(self):
self.botonPrueba = Button(self , text = 'Prueba Motores', command = self.prueba)
self.botonPrueba.grid()
self.botonGiro = Button(self , text = 'Giro PID', command = self.Giro)
self.botonGiro.grid(row = 1 , column = 0)
self.cant_posicion = Entry(self)
self.cant_posicion.grid(row = 1 , column = 1)
self.pinza = Button(self , text = 'Pinza', command = lambda estado = self.est_pinza :self.pinzac(estado))
self.pinza.grid(row = 2 , column = 0)
self.subeybaja = Button(self , text = 'sube', command = self.subebaja)
self.subeybaja.grid(row = 3 , column = 0)
def subebaja(self):
estado = self.est_subebaja
if estado:
self.pi.write(9,0)
self.pi.write(11,1)
self.id_sb = self.subeybaja.after(5000,self.sbcancel)
else:
self.pi.write(9,1)
self.pi.write(11,0)
print('bajando...')
print(estado)
self.id_sb = self.subeybaja.after(1000,self.sbcancel)
self.est_subebaja = not self.est_subebaja
def sbcancel(self):
self.subeybaja.after_cancel(self.id_sb)
self.pi.write(9,0)
self.pi.write(11,0)
def pinzacancel(self ):
self.pinza.after_cancel(self.id)
self.pi.write(27,0)
self.pi.write(17,0)
def pinzac(self , estado):
estado = self.est_pinza
if estado:
self.pi.write(27,0)
self.pi.write(17,1)
print('abriendo...')
print(estado)
else:
self.pi.write(27,1)
self.pi.write(17,0)
print('cerrando...')
print(estado)
self.est_pinza = not self.est_pinza
print (self.est_pinza)
self.id = self.pinza.after(1000,self.pinzacancel)
def Giro(self):
grados = self.cant_posicion.get()
pulsos = int(grados) * 12.222222222222221
self.enc1.setPoint(int(pulsos))
def prueba(self):
self.botonPrueba.config(state = DISABLED)
pines = [17,27,18,23,9,11,25,8]
for pin in pines:
#.........这里部分代码省略.........