本文整理汇总了Python中Tkinter.Spinbox.get方法的典型用法代码示例。如果您正苦于以下问题:Python Spinbox.get方法的具体用法?Python Spinbox.get怎么用?Python Spinbox.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Spinbox
的用法示例。
在下文中一共展示了Spinbox.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
def initUI(self):
self.parent.title("Buttons")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=GROOVE, borderwidth=5)
frame.pack(fill=BOTH, expand=1)
self.pack(fill = BOTH, expand = 1)
self.imageLabel = Label(frame, image = "")
self.imageLabel.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close")
closeButton.pack(side=RIGHT)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")]
option = OptionMenu(self, self.key, *options)
self.key.set(options[0])
option.pack(side="left")
spin = Spinbox(self, from_=0, to=1, increment=0.05)
self.val = spin.get()
spin.pack(side="left")
示例2: MoveControl
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [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:
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class PeakFinder:
def __init__(self, master):
self.master = master
master.title(u"Weiterreißwiderstand")
self.big_font = tkFont.Font(family='Helvetica',
size=36, weight='bold')
self.normal_font = tkFont.Font(family='Helvetica',
size=20, weight='normal')
self.X = None
self.Y = None
self.maxima = None
self.maxima_x = None
self.number_max = 0
self.number_max_string = StringVar()
self.max_max = 0.0
self.max_max_string = StringVar()
self.min_max = 0.0
self.min_max_string = StringVar()
self.median = 0.0
self.median_string = StringVar()
self.w_string = StringVar()
self.distance_string = StringVar()
self.method_string = StringVar()
self.sample_file = ''
self.project_file = ''
self.w = 0.0
self.distance = 0.0
#########################################################################
'''
Optionen für Dateidialoge
'''
self.file_opt = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('text files', '.txt')]
options['initialfile'] = ''
options['parent'] = master
options['title'] = 'Messung importieren'
self.file_opt2 = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('text files', '.txt')]
options['initialfile'] = ''
options['parent'] = master
options['title'] = 'Neues Projekt erstellen.'
self.file_opt3 = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('text files', '.txt')]
options['initialfile'] = ''
options['parent'] = master
options['title'] = 'Vorhandenes Projekt öffnen.'
#####################################################################################################
'''
GUI
'''
'''
MenueLeiste
'''
###############################################################################################
self.menubar = Menu(master)
# create a pulldown menu, and add it to the menu bar
self.filemenu = Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label="Neu", command=self.new_file, font = self.normal_font)
self.filemenu.add_command(label=u"Öffnen...", command=self.open_file, font = self.normal_font)
self.filemenu.add_separator()
self.filemenu.add_command(label="Messung importieren", command=self.get_filepath, font = self.normal_font)
self.filemenu.add_separator()
self.filemenu.add_command(label="Beenden", command=root.quit, font = self.normal_font)
self.menubar.add_cascade(label="Datei", menu=self.filemenu, font = self.normal_font)
self.helpmenu = Menu(self.menubar, tearoff=0)
self.helpmenu.add_command(label="Hilfe", command=self.help, font = self.normal_font)
self.helpmenu.add_command(label=u"Über", command=self.info, font = self.normal_font)
self.menubar.add_cascade(label="Hilfe", menu=self.helpmenu, font = self.normal_font)
master.config(menu=self.menubar)
##############################################################################################
'''
Parameter
'''
self.option_label = ttk.Label(master, text = "Parameter", font = self.big_font)
self.option_label.grid(row = 0, rowspan = 2, columnspan = 4, sticky=W)
self.delta_x_label = ttk.Label(master, text = "Delta X", font = self.normal_font)
self.delta_x_label.grid(row = 3, sticky=W)
self.delta_x_spinbox = Spinbox(master, from_=10, to=500, increment = 10, font = self.normal_font, width = 4, command = self.plot)
self.delta_x_spinbox.grid(row = 3, column = 1)
#.........这里部分代码省略.........
示例4: TkPictureFrame
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class TkPictureFrame(Frame):
def __init__(self, x, y, master=None):
Frame.__init__(self, master)
self.photo = None
self.resolution = (x, y)
#The center of the Canvas is 0, 0. Find the center so
#we can draw the image properly.
self.center = ( x/2, y/2)
#Setup the canvas
self.picture = Canvas(self, width=x, height=y)
#Place the canvas in the Grid.
self.picture.grid(row=0,column=0,columnspan=2)
#Camera check button control.
self.checkButton = Checkbutton(self, text='Camera?',\
command=self.toggleCamera)
#Place it on the grid.
self.checkButton.grid(row=1,column=0)
#Spinbox to set FPS
self.fpsSpin = Spinbox(self, text="FPS", from_=2, to=30,\
command=self.fpsSpinCallback)
self.fpsSpin.grid(row=1, column=1)
#Set framerate
self.fpsSpinCallback()
#To determine if the camera is running
self.capturing = False
def fpsSpinCallback(self):
self.fps = int(self.fpsSpin.get())
def changePic(self, photo):
#Make a reference to the old photo for removal
self.oldphoto = self.photo
#Setup the new photo
self.photo = photo
#Draw the new photo over the old photo
self.picture.create_image(self.center,image=self.photo)
#Remove the old photo
self.picture.delete(self.oldphoto)
#Enable the checkbox
self.checkButton.config(state="normal")
def timedDisable(self, widget):
#Disable a widget for 2 seconds.
widget.config(state="disabled")
time.sleep(2)
widget.config(state="normal")
def threadTimeDisable(self, widget):
#Run the timed disable in a thread to avoid lockups.
thread.start_new_thread(self.timedDisable, (widget,))
def startCamera(self):
#Disable the checkbox and fps spinner.
self.checkButton.config(state="disabled")
self.fpsSpin.config(state="disabled")
#Start the camera
thread.start_new_thread(self.setupCamera, self.resolution)
self.capturing = True
def stopCamera(self):
#Disable the checkbox for a duration.
self.threadTimeDisable(self.checkButton)
#Enable the spinner.
self.fpsSpin.config(state="normal")
#Clear the canvas.
self.capturing = False
self.picture.delete("all")
def toggleCamera(self):
if self.capturing:
self.stopCamera()
else:
self.startCamera()
def setupCamera(self, x, y):
with picamera.PiCamera() as camera:
camera.resolution = (x, y)
camera.framerate = self.fps
stream = io.BytesIO()
for each in camera.capture_continuous(stream, format='jpeg'):
# Truncate the stream to the current position (in case
# prior iterations output a longer image)
each.truncate()
#Rewind the stream
each.seek(0)
#Open the image stream
image = Image.open(each)
photo = ImageTk.PhotoImage(image)
#Break out of the loop if not capturing
if not self.capturing:
break
#Update the canvas
self.changePic(photo)
#Reset playback to the beginning for the next image.
each.seek(0)
示例5: ventanaImprimir
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
def ventanaImprimir(self):
t = Toplevel(self)
t.wm_title("Imprimir")
Label(t, text="Numero de Copias por etiqueta").pack()
w = Spinbox(t, from_=1, to=10)
w.pack()
buttonImprimir = Button(t, text="Imprimir", command=lambda:self.imprimir(int(w.get()),t))
buttonImprimir.pack()
示例6: SettingWindow
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
#.........这里部分代码省略.........
f13.grid(row=1, columnspan=2, pady=5, padx=5)
Label(f13, text=u" \N{GREEK SMALL LETTER SIGMA}").grid(row=1, column=0)
self.dots_distance_scale = Scale(f13, from_=1, to=20, resolution=1, orient=HORIZONTAL, length=90)
self.dots_distance_scale.set(6)
self.dots_distance_scale.grid(row=0, column=1, rowspan=2)
f14 = ttk.Labelframe(frame_other, text="Tracks")
f14.grid(row=0, column=3, pady=5, padx=5)
Label(f14, text="N").grid(row=1, column=0)
self.num_frames_tracks_spinbox = Spinbox(f14, from_=2, to=num_frames, width=10)
self.num_frames_tracks_spinbox.delete(0, END)
self.num_frames_tracks_spinbox.insert(END, num_frames)
self.num_frames_tracks_spinbox.grid(row=0, column=1, rowspan=2)
Label(f14, text=u"\N{GREEK SMALL LETTER TAU}").grid(row=3, column=0)
self.gaps_scale = Scale(f14, from_=1, to=10, resolution=1, orient=HORIZONTAL, length=90)
self.gaps_scale.set(2)
self.gaps_scale.grid(row=2, column=1, rowspan=2)
self.notebook.pack(padx=1, pady=1)
save_button = Button(self, text=" Save and Close window ", command=self.withdraw)
save_button.pack(pady=2)
def _select_all(self):
for i, var in enumerate(self.features_vars):
var.set(1)
def _clear_selection(self):
for i, var in enumerate(self.features_vars):
var.set(0)
def change_mser(self):
rand_row = random.randint(1, 512-200)
rand_col = random.randint(1, 512-110)
self.mser_area = self.mser_image[rand_row:rand_row+180, rand_col:rand_col+100]
self.update_mser_image(self.mser_area)
def try_mser(self):
delta = self.delta_scale.get()
min_area = self.min_area_scale.get()
max_area = self.max_area_scale.get()
image = self.mser_area
red_c = image[:,:,0]
red_c = cv2.equalizeHist(red_c)
det_img = image.copy()
mser = cv2.MSER(delta, _min_area=min_area, _max_area=max_area)
regions = mser.detect(red_c)
cp = list()
new_c = np.zeros(self.mser_area.shape, dtype=np.uint8)
for r in regions:
for point in r:
cp.append(point)
det_img[point[1], point[0], 0] = 0
det_img[point[1], point[0], 1] = 0
det_img[point[1], point[0], 2] = 204
#new_c[point[1], point[0]] = 255
self.update_mser_image(det_img)
def update_mser_image(self, new_image):
self.mser_img_array = Image.fromarray(new_image)
self.mser_img.paste(self.mser_img_array)
def get_patch_size(self):
patch_size = self.patch_size_spinbox.get()
return int(patch_size)
def get_num_frames_tracks(self):
num_frames_tracks = self.num_frames_tracks_spinbox.get()
return int(num_frames_tracks)
def get_mser_opts(self):
return [self.delta_scale.get(), self.min_area_scale.get(), self.max_area_scale.get()]
def get_forest_opts(self):
return [self.num_trees_scale.get(), self.depth_tree_scale.get(), self.percentage_feats_scale.get()]
def get_low_thresh(self):
return self.low_thresh_scale.get()
def get_high_thresh(self):
return self.high_thresh_scale.get()
def get_dots_distance(self):
return int(self.dots_distance_scale.get())
def get_selection_mask(self):
if self.selection is not None:
return self.selection
selection_mask = np.zeros((self.max_num_feats, ), dtype='bool')
for i, var in enumerate(self.features_vars):
selection_mask[i] = var.get()
self.selection = selection_mask
return selection_mask
示例7: Application
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class Application(Frame):
MAXWORDLEN = 20
DEFAULTWORDLEN = 3
MANDATORY1stCHAR=0
def __init__(self, master=None):
Frame.__init__(self, master, padx=3, pady=3)
self.dictionaryfile = None
self.menubar = Menu()
self.__createWidgets()
self.menubar.add_cascade(label='File', menu=self.__File)
self.menubar.add_cascade(label='Options', menu=self.__Options)
self.menubar.add_command(label='About', command=self.__about)
self.__params.grid(row=0, column=0, sticky=W)
self.__res_pane = Frame()
self.__res_pane.grid(row=2, column=0, sticky=E + W)
self.__status = Label(anchor=W, relief=SUNKEN)
self.__status.grid(row=3, column=0, sticky=E + W)
self.osDictFile()
self.matchobj = None
if self.dictionaryfile is None:
self.status('No dictionary defined!')
master.config(menu=self.menubar)
def __createWidgets(self):
self.__params = Frame(padx=5, pady=5)
Label(text='Letters: ', anchor=E).grid(row=0, column=0,
sticky=E, in_=self.__params)
self.__char_entry = Entry(width=10)
self.__chk1st = Checkbutton(variable=self.MANDATORY1stCHAR, command=self.__CB)
Label(text='First letter appears in every result ', anchor=W).grid(
row=0, column=4, sticky=E, in_=self.__params)
self.__char_entry.grid(row=0, column=1, columnspan=2,
sticky=W, in_=self.__params)
self.__chk1st.grid(row=0, column=3, sticky=W, in_=self.__params)
Label(text='Minimum length of result words: ', anchor=E).grid(
row=1, column=0, sticky=E, in_=self.__params)
self.__word_length_ctrl = Spinbox(from_=1, to=Application.MAXWORDLEN,
width=2)
self.__word_length_ctrl.delete(0, END)
self.__word_length_ctrl.insert(0, Application. DEFAULTWORDLEN)
self.__word_length_ctrl.grid(row=1, column=1, in_=self.__params,
sticky=W)
self.__go_button = Button(text='Go', command=self.__findWords)
self.__go_button.grid(row=1, column=2, sticky=E, in_=self.__params)
self.__Options = Menu()
self.__Options.add_command(label='Choose dictionary',
command=self.__choosedict)
self.__File = Menu()
self.__File.add_command(label='Export as ODT (Open document text)', command=self.__export)
self.__char_entry.focus_set()
self.__char_entry.bind("<Return>", self.__keyPressEnter)
def __CB(self):
self.MANDATORY1stCHAR = not self.MANDATORY1stCHAR
def __choosedict(self):
try:
self.dictionaryfile = tkFileDialog.askopenfile(mode='r').name
self.status('')
except AttributeError:
pass
def osDictFile(self):
if 'linux' in sys.platform:
self.dictionaryfile = '/usr/share/dict/words'
def __about(self):
AboutDialog(self)
def status(self, text):
self.__status.config(text=text)
self.__status.update_idletasks()
def __findWords(self):
self.__res_pane.grid_forget()
chars = self.__char_entry.get()
minlen = int(self.__word_length_ctrl.get())
if len(chars) < minlen:
tkMessageBox.showerror(title='Not enough letters',
message='''Not enough letters given\n
You must give at least as many letters as the minimum required word length''')
return
res = self.__getres(minlen, chars)
self.__res_pane = ResultPane(res)
self.__res_pane.grid(row=2, column=0, sticky=E + W)
def __getres(self, minlen, chars):
firstpass = True
while True:
try:
self.matchobj = None
if firstpass and self.dictionaryfile is None:
self.matchobj = Match(minlen=minlen, chars=chars,
statushandler=self.status, mand1st=self.MANDATORY1stCHAR)
firstpass = False
else:
self.matchobj = Match(minlen=minlen, chars=chars,
dict=self.dictionaryfile,
statushandler=self.status, mand1st=self.MANDATORY1stCHAR)
#.........这里部分代码省略.........
示例8: ScanDialog
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [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)
#.........这里部分代码省略.........
示例9: MacroEdit
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class MacroEdit(Toplevel):
def __init__(self, root, prtr, settings, log, fn, text, *arg):
Toplevel.__init__(self, root, *arg)
self.title("Macro Editor")
self.fn = fn
self.app = root
self.settings = settings
self.printer = prtr
self.log = log
self.macroList = self.settings.getMacroList()
self.macroEntry = None
if fn == None:
title = "New macro"
self.macroTitle = None
self.newMacro = True
else:
self.newMacro = False
self.macroTitle = title = os.path.basename(fn)
for m in self.macroList:
if self.macroTitle == m[MNAME]:
self.macroEntry = m
break
self.f = LabelFrame(self, text=title)
self.entry = Text(self.f, width=80, height=24, relief=RIDGE, bd=2)
self.entry.grid(row=1, column=1)
self.f.grid(row=1, column=1, columnspan=6)
self.bSave = Button(self, text="Save", width=20, command=self.doSave)
self.bSave.grid(row=2, column=1)
self.bExit = Button(self, text="Exit", width=20, command=self.doExit)
self.bExit.grid(row=2, column=2)
self.cbvAddButton = IntVar()
self.cbAddButton = Checkbutton(self, text="Add Button", variable=self.cbvAddButton, command=self.doAddButton)
self.cbAddButton.grid(row=2, column=3)
self.buttonText = Entry(self, width=12)
self.buttonText.grid(row=2, column=4)
l = Label(self, text="Column:", justify=RIGHT)
l.grid(row=2, column=5, sticky=E)
self.spCol = Spinbox(self, values=[1,2,3], width=12, justify=RIGHT)
self.spCol.grid(row=2, column=6)
l = Label(self, text="Row:", justify=RIGHT)
l.grid(row=3, column=5, sticky=E)
self.spRow = Spinbox(self, values=[1,2,3,4,5,6,7,8,9,10], width=12, justify=RIGHT)
self.spRow.grid(row=3, column=6)
if self.macroEntry != None:
self.cbvAddButton.set(1)
self.spRow.delete(0, END)
self.spRow.insert(0, self.macroEntry[MROW])
self.spCol.delete(0, END)
self.spCol.insert(0, self.macroEntry[MCOL])
self.buttonText.delete(0, END)
self.buttonText.insert(0, self.macroEntry[MTEXT])
self.initialButtonInfo = [1, self.macroEntry[MCOL], self.macroEntry[MROW], self.macroEntry[MTEXT]]
else:
self.cbvAddButton.set(0)
self.spRow.delete(0, END)
self.spRow.insert(0, 1)
self.spCol.delete(0, END)
self.spCol.insert(0, 1)
self.buttonText.delete(0, END)
self.initialButtonInfo = [0, 1, 1, ""]
self.doAddButton()
self.startText = text
self.entry.delete("1.0", END)
self.entry.insert(END, self.startText)
self.entry.edit_modified(False)
self.grab_set()
self.app.wait_window(self)
def doAddButton(self):
if self.cbvAddButton.get() == 1:
self.buttonText.config(state=NORMAL)
self.spRow.config(state=NORMAL)
self.spCol.config(state=NORMAL)
else:
self.buttonText.config(state=DISABLED)
self.spRow.config(state=DISABLED)
self.spCol.config(state=DISABLED)
def buttonInfoChanged(self):
if self.cbvAddButton.get() != self.initialButtonInfo[0]:
return True
if self.initialButtonInfo[1] != int(self.spCol.get()):
return True
#.........这里部分代码省略.........
示例10: Temperatures
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
#.........这里部分代码省略.........
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)
self.monTemp = IntVar()
self.monTemp.set(1)
self.monCheck()
self.cb = Checkbutton(self, text="Monitor temperatures", variable=self.monTemp, command=self.monCheck)
self.cb.grid(row=10, column=1, columnspan=3)
self.rptre = re.compile("ok *T:([0-9\.]+) *\/([0-9\.]+) *B:([0-9\.]+) *\/([0-9\.]+)")
def fanCheck(self):
self.settings.fanwithextruder = (self.extFan.get() == 1)
self.settings.setModified()
def forceBedTempCheck(self):
if self.forceBedTemp.get() == 1:
if not self.settings.forcebedtemp:
self.settings.forcebedtemp = True
self.settings.setModified()
else:
if self.settings.forcebedtemp:
self.settings.forcebedtemp = False
self.settings.setModified()
def forceExtTempCheck(self):
if self.forceExtTemp.get() == 1:
if not self.settings.forceexttemp:
self.settings.forceexttemp = True
self.settings.setModified()
else:
if self.settings.forceexttemp:
self.settings.forceexttemp = False
self.settings.setModified()
def monCheck(self):
if self.monTemp.get() == 1:
self.app.monitorTemp = True
self.printer.tempcb = self.tempcb
else:
self.app.monitorTemp = False
self.dataBed = []
self.canvasBed.delete("GRAPH")
self.canvasBed.delete("TARGET")
self.dataExt = []
示例11: Cockpit
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class Cockpit(ttkFrame):
'''
Remote device GUI
'''
#TODO: 20160415 DPM - Set these values from configuration file
#--- config
THROTTLE_BY_USER = True
THROTTLE_RESOLUTION = 0.1
# Joystick enabled or not, if any
JOYSTICK_ENABLED = True
DEFAULT_DRONE_IP = "192.168.1.130"
DEFAULT_DRONE_PORT = 2121
#--- end config
KEY_ANG_SPEED = "ang-speed"
KEY_ANGLES = "angles"
KEY_ACCEL = "accel"
PID_KEYS = ["P", "I", "D"]
DIR_NONE = 0
DIR_VERTICAL = 1
DIR_HORIZONTAL = 2
def __init__(self, parent, isDummy = False, droneIp = DEFAULT_DRONE_IP, dronePort = DEFAULT_DRONE_PORT):
'''
Constructor
'''
ttkFrame.__init__(self, parent)
self._target = [0.0] * 4
self._selectedPidConstats = "--"
self._pidConstants = {
Cockpit.KEY_ANG_SPEED:{
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Z":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
},
Cockpit.KEY_ANGLES: {
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
},
Cockpit.KEY_ACCEL:{
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Z":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
}
}
self.parent = parent
self.initUI()
self._controlKeysLocked = False
if not isDummy:
self._link = INetLink(droneIp, dronePort)
else:
self._link = ConsoleLink()
self._link.open()
self._updateInfoThread = Thread(target=self._updateInfo)
#.........这里部分代码省略.........
示例12: Cockpit
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class Cockpit(ttkFrame):
'''
Remote controller GUI
'''
KEY_ANG_SPEED = "ang-speed"
KEY_ANGLES = "angles"
KEY_ACCEL = "accel"
PID_KEYS = ["P", "I", "D"]
DEFAULT_DRONE_IP = "192.168.1.130"
DEFAULT_DRONE_PORT = 2121
DIR_NONE = 0
DIR_VERTICAL = 1
DIR_HORIZONTAL = 2
MAX_ACCEL = 10.0 #TODO angles. Replace by m/s²
MAX_ACCEL_Z = 0.1 #m/s²
MAX_ANGLE_SPEED = 50.0 #º/s
def __init__(self, parent, isDummy = False, droneIp = DEFAULT_DRONE_IP, dronePort = DEFAULT_DRONE_PORT):
'''
Constructor
'''
ttkFrame.__init__(self, parent)
self._started = IntVar()
self._integralsEnabled = IntVar()
self._target = [0.0] * 4
self._selectedPidConstats = "--"
self._pidConstants = {
Cockpit.KEY_ANG_SPEED:{
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Z":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
},
Cockpit.KEY_ANGLES: {
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
},
Cockpit.KEY_ACCEL:{
"X":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Y":{
"P": 0.0,
"I": 0.0,
"D": 0.0
},
"Z":{
"P": 0.0,
"I": 0.0,
"D": 0.0
}
}
}
self.parent = parent
self.initUI()
self._controlKeysLocked = False
if not isDummy:
self._link = INetLink(droneIp, dronePort)
else:
self._link = ConsoleLink()
self._link.open()
self._updateInfoThread = Thread(target=self._updateInfo)
self._updateInfoThreadRunning = False
self._readingState = False
self._start()
#.........这里部分代码省略.........
示例13: TTTUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
class TTTUI(object):
default_ply = 6
neither_color = '#%02x%02x%02x' % (255, 255, 255) # white
player_color = '#%02x%02x%02x' % (62, 188, 0) # green
computer_color = '#%02x%02x%02x' % (192, 35, 3) # red
win_color = '#%02x%02x%02x' % (25, 111, 254) # blue
def __init__(self):
# TTT related
self.ttt = Board(ply=9)
self.human_first = True
# UI related
self.root = Tk()
self.root.resizable(0, 0)
self.root.title("3D TTT")
# TTT frames
self.ttt_frames = [Frame(self.root) for x in range(3)]
for i in range(3):
self.ttt_frames[i].grid(row=0, column=i)
self.button_pos = dict()
self._init_board()
# control frame
self.control_frame = Frame(self.root, padx=5, pady=5)
self.control_frame.grid(row=1, column=1)
self.new_game_btn = Button(self.control_frame, text='New Game', \
command=lambda: self.reset())
self.new_game_btn.pack(side=LEFT, fill=BOTH, expand=True)
self.toggle_human_first_btn = Button(self.control_frame, \
text='Human First', command=lambda: self.toggle_human_first())
self.toggle_human_first_btn.pack(side=RIGHT, fill=BOTH, expand=True)
self.ply_box = Spinbox(self.control_frame, from_=1, to=20, \
textvariable=self.ttt.difficulty, command=lambda: self.reset())
self.ply_box.pack(side=RIGHT, fill=BOTH, expand=True)
# start UI
self.update_pieces()
self.start()
self.root.mainloop()
def toggle_human_first(self):
self.human_first = not self.human_first
self.toggle_human_first_btn.config(text='Human First' if \
self.human_first else 'Computer First')
self.reset()
def _find_button(self, frame, r, c):
for child in frame.children.values():
info = child.grid_info()
if info['row'] == r and info['column'] == c:
return child
return None
def update_pieces(self):
player_pieces = self.ttt.get_moves(self.ttt.human)
computer_pieces = self.ttt.get_moves(self.ttt.ai)
cnt = 0
for b, board in enumerate(self.ttt.board):
for r, row in enumerate(board):
for c, col in enumerate(row):
color = self.neither_color
text = '-'
occupied = False
if cnt in player_pieces:
color = self.player_color
text = self.ttt.human
if cnt in computer_pieces:
color = self.computer_color
text = self.ttt.ai
if self.ttt.complete and cnt in self.ttt.winning_combo:
color = self.win_color
btn = self.button_pos[cnt]
btn.config(text=text, bg=color, state=DISABLED if \
occupied else NORMAL)
cnt += 1
def place_human(self, position):
if position in self.ttt.allowed_moves and not self.ttt.complete:
self.ttt.move(position, self.ttt.human)
self.ttt.human_turn = False
self.update_pieces()
self.place_computer()
def place_computer(self):
if not self.ttt.complete:
self.ttt.computers_move()
self.update_pieces()
def reset(self):
self.ttt.reset()
self.ttt.difficulty = self.default_ply if not \
self.ply_box.get().isdigit() else int(self.ply_box.get())
self.ttt.human_turn = self.human_first
self.update_pieces()
self.start()
#.........这里部分代码省略.........
示例14: ToolBar
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [as 别名]
#.........这里部分代码省略.........
self.bSD = Button(bottomBar, text="SD", width=BWIDTH, command=self.doSD, state=DISABLED)
self.bSD.pack(side=LEFT, padx=2, pady=2)
self.bPrintMode = PR_PRINT
self.bPrint = Button(bottomBar, text=printText[PR_PRINT], width=BWIDTH, command=self.doPrint, state=DISABLED)
self.bPrint.pack(side=LEFT, padx=2, pady=2)
self.bPauseMode = PM_PAUSE
self.bPause = Button(bottomBar, text=pauseText[PM_PAUSE], width=BWIDTH, command=self.doPause, state=DISABLED)
self.bPause.pack(side=LEFT, padx=2, pady=2)
self.bAbandon = Button(bottomBar, text="Abandon SD Print", width=BWIDTH+8, command=self.doAbandon, state=DISABLED)
self.bAbandon.pack(side=LEFT, padx=2, pady=2)
self.cbvLiftOnPause = IntVar()
if self.settings.liftonpause:
self.cbvLiftOnPause.set(1)
else:
self.cbvLiftOnPause.set(0)
self.cbLiftOnPause = Checkbutton(bottomBar, text="Lift Head/Retract on Pause", variable=self.cbvLiftOnPause,
command=self.clickLiftOnPause)
self.cbLiftOnPause.pack(side=LEFT, padx=2)
self.cbvResumeAtPause = IntVar()
if self.settings.resumeatpausepoint:
self.cbvResumeAtPause.set(1)
else:
self.cbvResumeAtPause.set(0)
self.cbResumeAtPause = Checkbutton(bottomBar, text="Resume print at pause point", variable=self.cbvResumeAtPause,
command=self.clickResumeAtPause)
self.cbResumeAtPause.pack(side=LEFT, padx=2)
def clickAssertFan(self):
if self.cbvAssertFan.get() == 1:
self.settings.forcefanspeed = True
self.settings.setModified()
else:
self.settings.forcefanspeed = False
self.settings.setModified()
def clickLiftOnPause(self):
if self.cbvLiftOnPause.get() == 1:
self.settings.liftonpause = True
self.settings.setModified()
else:
self.settings.liftonpause = False
self.settings.setModified()
def clickResumeAtPause(self):
if self.cbvResumeAtPause.get() == 1:
self.settings.resumeatpausepoint = True
self.settings.setModified()
else:
self.settings.resumeatpausepoint = False
self.settings.setModified()
def setSliceText(self):
if self.settings.slicer == SLIC3R:
sl = "slic3r:%s" % self.app.slic3r.getProfile()
else:
sl = "skeinforge:%s" % self.app.skeinforge.getProfile()
sliceText[SM_SLICE] = "Slice (%s)" % sl
if self.bSliceMode == SM_SLICE:
self.bLoad.config(state=NORMAL)
self.app.allowLoadGCodeMenu(True)
lt = len(sliceText[SM_SLICE])+2
示例15: Extruder
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import get [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")