本文整理汇总了Python中Tkinter.Spinbox.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Spinbox.bind方法的具体用法?Python Spinbox.bind怎么用?Python Spinbox.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Spinbox
的用法示例。
在下文中一共展示了Spinbox.bind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MoveControl
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import bind [as 别名]
class MoveControl(LabelFrame):
def __init__(self, root, prtr, settings, log, *arg):
fn = os.path.join(settings.cmdFolder, "images", "control_xyz.png")
self.image = Image.open(fn)
self.photo = ImageTk.PhotoImage(self.image)
LabelFrame.__init__(self, root, *arg, text="Movement")
self.app = root
self.hilite = None
self.hilitemask = None
self.settings = settings
self.printer = prtr
self.log = log
l = Label(self, text="mm/min")
l.grid(row=1, column=2)
l = Label(self, text="X/Y Feed Rate:")
l.grid(row=2, column=1, sticky=E)
self.xyfeed = Spinbox(self, width=10, justify=RIGHT, from_=0, to=MAXFEED)
self.xyfeed.grid(row=2, column=2)
self.xyfeed.delete(0, END)
self.xyfeed.insert(0, settings.xyfeed)
self.xyfeed.bind("<FocusOut>", self.valxyFeed)
self.xyfeed.bind("<Leave>", self.valxyFeed)
l = Label(self, text="Z Feed Rate:")
l.grid(row=3, column=1, sticky=E)
self.zfeed = Spinbox(self, width=10, justify=RIGHT, from_=0, to=MAXFEED)
self.zfeed.grid(row=3, column=2)
self.zfeed.delete(0, END)
self.zfeed.insert(0, settings.zfeed)
self.zfeed.bind("<FocusOut>", self.valzFeed)
self.zfeed.bind("<Leave>", self.valzFeed)
self.canvas = Canvas(self, width=self.image.size[0], height=self.image.size[1], *arg)
self.canvas.create_image((0, 0), image=self.photo, anchor=N+W)
self.canvas.grid(row=4, column=1, columnspan=2)
for m in imageMasks:
self.canvas.create_oval((m[0][0]-mask_rad, m[0][1]-mask_rad, m[0][0]+mask_rad, m[0][1]+mask_rad),
outline="#FF0000", width=4, tags=m[1], state=HIDDEN)
self.canvas.bind("<Button-1>", self.OnLeftDown)
self.canvas.bind("<Motion>", self.OnMotion)
self.canvas.bind("<Enter>", self.OnEnter)
self.canvas.bind("<Leave>", self.OnLeave)
self.bAllOff = Button(self, text="Release Motors", command=self.allMotorsOff)
self.bAllOff.grid(row=5, column=1, columnspan=2)
def valxyFeed(self, *arg):
x = self.validFeed(self.xyfeed.get(), 'XY')
if x == None:
self.xyfeed.delete(0, END)
self.xyfeed.insert(0, "%d" % self.settings.xyfeed)
return True
if self.settings.xyfeed != x:
self.settings.xyfeed = x
self.settings.setModified()
return True
def valzFeed(self, *arg):
x = self.validFeed(self.zfeed.get(), 'Z')
if x == None:
self.zfeed.delete(0, END)
self.zfeed.insert(0, "%d" % self.settings.zfeed)
return True
if self.settings.zfeed != x:
self.settings.zfeed = x
self.settings.setModified()
return True
def validFeed(self, fv, axis):
try:
x = int(fv)
except:
self.log.logMsg("Value for %s feed rate not a valid integer" % axis)
return None
if x <=0 or x >MAXFEED:
self.log.logMsg("Value for %s feed rate out of range(0-5000)" % axis)
return None
return x
def allMotorsOff(self):
if self.app.printerAvailable(cmd="M84"):
self.printer.send_now("M84")
def OnMotion(self, e):
for i in range(len(imageGeometry)):
if boundBy((e.x, e.y), imageGeometry[i][0]):
self.setHilite(i)
return
if self.hilite != None:
#.........这里部分代码省略.........
示例2: Extruder
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import bind [as 别名]
class Extruder(LabelFrame):
def __init__(self, root, prtr, settings, log, *arg):
LabelFrame.__init__(self, root, *arg, text="Extruder")
self.app = root
self.printer = prtr
self.settings = settings
self.log = log
self.bExtrude = Button(self, text="Extrude", width=10, command=self.doExtrude)
self.bExtrude.grid(row=1, column=1, padx=2)
self.spDistance = Spinbox(self, from_=1, to=MAXDIST, width=6, justify=RIGHT)
self.spDistance.grid(row=1, column=2)
self.spDistance.delete(0, END)
self.spDistance.insert(0, STARTDIST)
self.spDistance.bind("<FocusOut>", self.valDistance)
self.spDistance.bind("<Leave>", self.valDistance)
l = Label(self, text="mm", justify=LEFT)
l.grid(row=1, column=3, sticky=W)
self.bReverse = Button(self, text="Reverse", width=10, command=self.doReverse)
self.bReverse.grid(row=2, column=1, padx=2)
self.spSpeed = Spinbox(self, from_=1, to=MAXFEED, width=6, justify=RIGHT)
self.spSpeed.grid(row=2, column=2)
self.spSpeed.delete(0, END)
self.spSpeed.insert(0, self.settings.efeed)
self.spSpeed.bind("<FocusOut>", self.valSpeed)
self.spSpeed.bind("<Leave>", self.valSpeed)
l = Label(self, text="mm/min", justify=LEFT)
l.grid(row=2, column=3, sticky=W)
def valDistance(self, *arg):
invalid = False
try:
y = float(self.spDistance.get())
except:
self.log.logMsg("Value for distance not a valid number")
invalid = True
else:
if y <=0 or y >MAXDIST:
self.log.logMsg("Value for Distance out of range (0-%d)" % MAXDIST)
invalid = True
if invalid:
self.spDistance.delete(0, END)
self.spDistance.insert(0, STARTDIST)
return True
def valSpeed(self, *arg):
invalid = False
try:
x = int(self.spSpeed.get())
except:
self.log.logMsg("Value for E feed rate not a valid integer")
invalid = True
else:
if x <=0 or x >MAXFEED:
self.log.logMsg("Value for E feed rate out of range(0-%d)" % MAXFEED)
invalid = True
if invalid:
self.spSpeed.delete(0, END)
self.spSpeed.insert(0, "%d" % self.settings.efeed)
else:
if self.settings.efeed != x:
self.settings.efeed = x
self.settings.setModified()
return True
def doExtrude(self):
if self.app.printerAvailable(cmd="G91"):
dist = self.spDistance.get()
self.printer.send_now("G91")
self.printer.send_now("G1 E%s F%s" % (dist, self.settings.efeed))
self.printer.send_now("G90")
def doReverse(self):
if self.app.printerAvailable(cmd="G91"):
dist = self.spDistance.get()
self.printer.send_now("G91")
self.printer.send_now("G1 E-%s F%s" % (dist, self.settings.efeed))
self.printer.send_now("G90")
示例3: Temperatures
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import bind [as 别名]
class Temperatures(LabelFrame):
def __init__(self, root, prtr, settings, log, *arg):
LabelFrame.__init__(self, root, *arg, text="Temperatures")
self.app = root
self.printer = prtr
self.settings = settings
self.log = log
l = Label(self, text="Extruder:", justify=LEFT)
l.grid(row=1, column=1, sticky=W)
self.statExt = Canvas(self, width=150, height=STAT_HEIGHT, bd=2, bg="white", relief=RIDGE)
self.statExt.grid(row=1, column=2, columnspan=2)
self.setStatus(self.statExt, UNKNOWN)
self.bSetExt = Button(self, text="Set", width=4, command=self.doSetExt)
self.bSetExt.grid(row=2, column=1, padx=2)
self.spExtTemp = Spinbox(self, values=self.formatTemps(self.settings.extemps), width=12, justify=RIGHT)
self.spExtTemp.grid(row=2, column=2)
if self.settings.lastexttemp != None:
self.spExtTemp.delete(0, END)
self.spExtTemp.insert(0, self.settings.lastexttemp)
self.spExtTemp.bind("<FocusOut>", self.valExtTemp)
self.spExtTemp.bind("<Leave>", self.valExtTemp)
self.bOffExt = Button(self, text="Off", width=4, command=self.doOffExt)
self.bOffExt.grid(row=2, column=3, padx=2)
self.frameExt = Frame(self)
self.frameExt.grid(row=3, column=1, columnspan=3)
self.legendExt = Canvas(self.frameExt, width=LEGEND_WIDTH, height=100, bd=2, bg="white", relief=RIDGE)
self.legendExt.pack(side=LEFT, padx=0, pady=2)
self.canvasExt = Canvas(self.frameExt, width=200, height=100, bd=2, bg="white", relief=RIDGE)
self.canvasExt.pack(side=LEFT, padx=0, pady=2)
self.drawExtAxes()
self.extFan = IntVar()
if self.settings.fanwithextruder:
self.extFan.set(1)
else:
self.extFan.set(0)
self.cb = Checkbutton(self, text="Fan on with extruder", variable=self.extFan, command=self.fanCheck)
self.cb.grid(row=4, column=1, columnspan=3)
self.forceExtTemp = IntVar()
if self.settings.forceexttemp:
self.forceExtTemp.set(1)
else:
self.forceExtTemp.set(0)
self.forceExtTempCheck()
self.bForceExt = Checkbutton(self, text="Force Ext Temp", variable=self.forceExtTemp, command=self.forceExtTempCheck)
self.bForceExt.grid(row=5, column=1, columnspan=3)
l = Label(self, text="Bed:", justify=LEFT)
l.grid(row=6, column=1, sticky=W)
self.statBed = Canvas(self, width=150, height=STAT_HEIGHT, bd=2, bg="white", relief=RIDGE)
self.statBed.grid(row=6, column=2, columnspan=2)
self.setStatus(self.statBed, UNKNOWN)
self.bSetBed = Button(self, text="Set", width=4, command=self.doSetBed)
self.bSetBed.grid(row=7, column=1, padx=2)
self.spBedTemp = Spinbox(self, values=self.formatTemps(self.settings.bedtemps), width=12, justify=RIGHT)
self.spBedTemp.grid(row=7, column=2)
if self.settings.lastbedtemp != None:
self.spBedTemp.delete(0, END)
self.spBedTemp.insert(0, self.settings.lastbedtemp)
self.spBedTemp.bind("<FocusOut>", self.valBedTemp)
self.spBedTemp.bind("<Leave>", self.valBedTemp)
self.bOffBed = Button(self, text="Off", width=4, command=self.doOffBed)
self.bOffBed.grid(row=7, column=3, padx=2)
self.frameBed = Frame(self)
self.frameBed.grid(row=8, column=1, columnspan=3)
self.legendBed = Canvas(self.frameBed, width=LEGEND_WIDTH, height=100, bd=2, bg="white", relief=RIDGE)
self.legendBed.pack(side=LEFT, padx=0, pady=2)
self.canvasBed = Canvas(self.frameBed, width=200, height=100, bd=2, bg="white", relief=RIDGE)
self.canvasBed.pack(side=LEFT, padx=0, pady=2)
self.drawBedAxes()
self.dataBed = []
self.dataExt = []
self.forceBedTemp = IntVar()
if self.settings.forcebedtemp:
self.forceBedTemp.set(1)
else:
self.forceBedTemp.set(0)
self.forceBedTempCheck()
self.bForceBed = Checkbutton(self, text="Force Bed Temp", variable=self.forceBedTemp, command=self.forceBedTempCheck)
self.bForceBed.grid(row=9, column=1, columnspan=3)
#.........这里部分代码省略.........
示例4: ScanDialog
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import bind [as 别名]
class ScanDialog(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.worker = None
self.elapsed = 0
self.settings = Settings(self)
# self.initUI() follows
self.parent.title("Scan Images")
self.pack(fill=BOTH, expand=1)
r = 0 # current grid row
Label(self, text="Name prefix:").grid(row=r, column=0)
Label(self, text="Number suffix:").grid(row=r, column=1)
r += 1
self.newName = StringVar()
self.newName.set('Scan_')
newName = Entry(self, textvariable=self.newName, width=60)
newName.grid(row=1, column=0)
newName.bind("<Return>", lambda event: self.scan())
newName.bind("<KP_Enter>", lambda event: self.scan())
newName.bind("<Escape>", lambda event: self.parent.destroy())
newName.focus_set()
self.newNameEntry = newName
self.numberSuffix = Spinbox(self, from_=1, to=999)
self.numberSuffix.bind("<Return>", lambda event: self.scan())
self.numberSuffix.bind("<KP_Enter>", lambda event: self.scan())
self.numberSuffix.grid(row=r, column=1)
r += 1
self.okButton = Button(self, text="Scan", command=self.scan, width=60, height=5)
self.okButton.grid(row=r, column=0)
cancelButton = Button(self, text="Cancel", command=self.parent.destroy)
cancelButton.grid(row=r, column=1)
r += 1
settings_panel = tk.Frame(self)
panel = tk.Frame(settings_panel)
tk.Label(panel, text="Paper Format").pack()
tk.Radiobutton(panel, text="A4", value=1.0, variable=self.settings.scale).pack(anchor=tk.W)
tk.Radiobutton(panel, text="A5", value=2 ** (-0.5), variable=self.settings.scale).pack(anchor=tk.W)
tk.Radiobutton(panel, text="A6", value=0.5, variable=self.settings.scale).pack(anchor=tk.W)
panel.pack(side=tk.LEFT, anchor=tk.N)
panel = tk.Frame(settings_panel)
tk.Label(panel, text="File Format").pack()
tk.Radiobutton(panel, text="PNG", value='.png', variable=self.settings.extension).pack(anchor=tk.W)
tk.Radiobutton(panel, text="JPG", value='.jpg', variable=self.settings.extension).pack(anchor=tk.W)
panel.pack(side=tk.LEFT, anchor=tk.N)
panel = tk.Frame(settings_panel)
tk.Label(panel, text="Scan Mode").pack()
tk.Radiobutton(panel, text="Color", value='color', variable=self.settings.scan_mode).pack(anchor=tk.W)
tk.Radiobutton(panel, text="Gray", value='gray', variable=self.settings.scan_mode).pack(anchor=tk.W)
tk.Radiobutton(panel, text="Lineart", value='lineart', variable=self.settings.scan_mode).pack(anchor=tk.W)
panel.pack(side=tk.LEFT, anchor=tk.N)
settings_panel.grid(row=r, column=0, columnspan=2)
r += 1
self.statusLabel = Label(self, text="Idle")
self.statusLabel.grid(row=r, column=0, columnspan=2)
def _checkAlive(self):
if self.worker is None:
return
if self.worker.is_alive():
self.after(100, self._checkAlive)
self.elapsed += 1
self.statusLabel.config(text='Scanning, please wait... (%.1f s)' % (self.elapsed/10.0))
else:
self.worker = None
self.okButton.config(state=NORMAL)
self.numberSuffix.invoke('buttonup')
self.newNameEntry.focus_set()
self.statusLabel.config(text='Idle (last scan: %.1f s)' % (self.elapsed/10.0))
def _ext(self):
return self.settings.ext()
def scan(self):
target = '%s%03d%s' % (self.newName.get(), int(self.numberSuffix.get()), self._ext(), )
if os.path.exists(target):
if not tkMessageBox.askokcancel(title='Scan Images', message='File exists. Overwrite?'):
print 'Not scanning: %s - file exists!' % target
new_name = self.newName.get()
for i in xrange(int(self.numberSuffix.get()), 1000):
new_target = '%s%03d.%s' % (new_name, int(self.numberSuffix.get()), self._ext(), )
if not os.path.exists(new_target):
print 'Next available filename: %s' % (new_target, )
self.numberSuffix.delete(0, 'end')
self.numberSuffix.insert(0, i)
#.........这里部分代码省略.........
示例5: AntroidGUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import bind [as 别名]
#.........这里部分代码省略.........
self.updateGui(turn)
def validateTurn(self, event):
try:
turn = int(self.Spin_T.get())
except ValueError:
turn = self.selectTurn
if turn in self.turns.keys():
if turn != self.selectTurn:
self.updateT = False
self.updateGui(turn)
else:
turn = self.selectTurn
def choiceAnt(self,event):
i = self.listbox.curselection()
id_a = self.listbox.get(i)
self.frameAnt.destroy()
self.printInfoAnt(int(id_a))
def printInfo(self):
self.FrameInfo=Frame(self.RFrame)
self.printTurn()
self.printAnts()
self.FrameInfo.pack()
def printTurn(self):
frameS = PanedWindow(self.FrameInfo, orient=HORIZONTAL)
turns = Label(frameS, text="Tour :")
self.var.set(str(self.selectTurn))
self.Spin_T = Spinbox(frameS, values=self.turns.keys(), command =
self.updateSpin_turn ,textvariable=self.var)
self.Spin_T.bind('<Return>', self.validateTurn)
turns.pack()
self.Spin_T.pack()
frameS.add(turns)
frameS.add(self.Spin_T)
frameS.pack()
self.frameT = frameS
def printAnts(self):
frameAnts = Frame(self.FrameInfo)
Text_A = Label(frameAnts, text="Fourmie :")
s1 = Scrollbar(frameAnts)
l1 = Listbox(frameAnts)
id_ants = self.checkAnts()
for i in id_ants: l1.insert(i, str(i))
s1.config(command = l1.yview)
l1.config(yscrollcommand = s1.set)
l1.bind('<ButtonRelease-1>',self.choiceAnt)
self.listbox = l1
Text_A.pack(side = TOP)
l1.pack(side = LEFT)
s1.pack(side = RIGHT)
frameAnts.pack()
self.printInfoAnt(id_ants[0])
self.frameAnts = frameAnts
def printInfoAnt(self, i):
self.frameAnt = PanedWindow(self.FrameInfo, orient=VERTICAL)
t_Ant = Label(self.frameAnt, text="Information Ant : %d" %(i))
(t_brain,t_energie,t_acide) = self.getInfoAnt(i)
a_b = Label(self.frameAnt, text=t_brain)