本文整理汇总了Python中Tkinter.Spinbox.grid方法的典型用法代码示例。如果您正苦于以下问题:Python Spinbox.grid方法的具体用法?Python Spinbox.grid怎么用?Python Spinbox.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Spinbox
的用法示例。
在下文中一共展示了Spinbox.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LabeledSpin
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
class LabeledSpin(Frame):
def __init__(self, **kwargs):
master = None if 'master' not in kwargs else kwargs['master']
title = '' if 'title' not in kwargs else kwargs['title']
Frame.__init__(self, master)
self.val = IntVar()
self.lbl = Label(text=title)
self.lbl.grid(row=0, column=0, sticky=W, in_=self)
self.Spin = Spinbox(textvariable=self.val)
self.Spin.grid(row=0, column=1, sticky=W, in_=self)
示例2: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def initUI(self):
# Main Window
self.parent.title("gBot")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
# Debug Window
Toplevel1 = Toplevel(self)
Toplevel1.title("gBot Debug Console")
self.pack(fill=BOTH, expand=1)
TL_T1 = Text(Toplevel1, width=50)
TL_T1.pack()
Toplevel1.state("withdrawn")
Toplevel1.protocol('WM_DELETE_WINDOW', lambda:Toplevel1.state("withdrawn"))
Toplevel1.attributes("-topmost", True)
# Username Input
L1 = Label(self, text="G+ User Name")
L1.grid(row=0, column=0, sticky=E, ipady=1)
E1 = Entry(self, width=30)
E1.grid(row=0, column=1, ipady=1, sticky=E)
# Password Input
L2 = Label(self, text="G+ Password")
L2.grid(row=1, column=0, sticky=E, ipady=1)
E2 = Entry(self, width=30)
E2.grid(row=1, column=1, ipady=1, sticky=E)
# Output Path Input
L3 = Label(self, text="Output Path")
L3.grid(row=2, column=0, sticky=E, pady=1)
E3 = Entry(self, width=30)
E3.grid(row=2, column=1, ipady=1, sticky=E)
E3.insert(0, "%s\links.txt" % (os.getcwd()))
# Num Posts
L4 = Label(self, text="# Of Posts")
L4.grid(row=3, column=0, sticky=E, pady=1)
S1 = Spinbox(self, from_=1, to=9999999, width=28)
S1.grid(row=3, column=1, ipady=1, sticky=E)
# Post Input
T1 = Text(self, width=30)
T1.grid(row=5, columnspan=2, sticky=W+E, pady=1)
# Start button
B1 = Button(self, text="Start Posting", command=lambda:self.doPosting(B1,TL_T1,E1.get(),E2.get(),T1.get(1.0,END),E3.get(),S1.get()))
B1.grid(row=6,columnspan=2, sticky=W+E)
# Debug button
B2 = Button(self, text="Debug log", command=lambda:Toplevel1.state("normal"))
B2.grid(row=7, columnspan=2, sticky=W+E)
self.addDebug(TL_T1,"Started successfully")
示例3: YearSelector
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
class YearSelector():
def __init__(self, parent=None, text='Year:', min_value=1950, max_value=2100, **kwargs):
# NOTE: This class used to be a subclass of Frame, but it did not grid properly
#Frame.__init__(self, parent)
self.label = Label(parent, text=text)
self.year = StringVar()
self.year_selector = Spinbox(parent, from_=min_value, to=max_value, textvariable=self.year, command=self.on_change, width=5)
self.set_args()
def set_args(self, **kwargs):
self.check_other_func = kwargs['check_other_func'] if 'check_other_func' in kwargs else None
def get_value(self):
value = int(self.year.get())
return value
def set_value(self, value):
self.year.set(value)
def set_grid(self, row=0, padx=0, pady=0):
#self.grid(row=row)
self.label.grid(row=row, column=0, sticky='e')
self.year_selector.grid(row=row, column=1, padx=padx, pady=pady, sticky='w')
def on_change(self):
if self.check_other_func != None:
value = int(self.year.get())
new_value = self.check_other_func(value)
if value != new_value:
self.set_value(new_value)
else:
pass
def get_less_than(self, compare_value):
value = int(self.year.get())
compare_value = int(compare_value)
if value <= compare_value:
return value
return compare_value
def get_greater_than(self, compare_value):
value = int(self.year.get())
compare_value = int(compare_value)
if value >= compare_value:
return value
return compare_value
示例4: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def initUI(self):
self.parent.title("LINEARITY TEST FOR PMT BASES")
self.pack(fill=BOTH, expand=True)
self.columnconfigure(0, weight=1)
#self.rowconfigure(0, weight=1)
# weight attibute is used to make them growable
# self.graph_cb = BooleanVar()
self.init_point = IntVar()
self.base_path = StringVar()
self.end_point = IntVar()
self.step = IntVar()
self.n_meas = IntVar()
self.inc_point = IntVar()
self.coef = DoubleVar()
self.noise = DoubleVar()
self.thr_sigma = DoubleVar()
self.SPE_DAQ = DoubleVar()
search = Image.open("next_logo.jpg")
search_temp = search.resize((170, 200), Image.ANTIALIAS)
search_aux = ImageTk.PhotoImage(search_temp)
label1 = Label(self, image=search_aux)
label1.image = search_aux
label1.grid(row=0, column=0,
columnspan=10, rowspan=10, sticky=E+W+S+N)
#Text Box
self.base_path.set("F:/DATOS_DAC/2052/pmt_0_trace_evt_")
e1 = Entry(self, textvariable=self.base_path, width=40)
e1.grid(row=1,column=2, sticky=W, columnspan=5, pady=5)
e1_label = Label(self, text="DataSet path (including name file)")
e1_label.grid(row=0,column=2,sticky=W, columnspan=5, pady=5)
#Spin Boxes
self.n_meas.set("20")
sb1 = Spinbox(self, from_=1, to=1000,
width=6, textvariable=self.n_meas)
sb1.grid(row=3,column=3, sticky=W)
sb1_label = Label(self, text="Measurements")
sb1_label.grid(row=2,column=3, padx=0, sticky=W)
self.step.set("10")
sb2 = Spinbox(self, from_=10, to=200,
width=6, textvariable=self.step)
sb2.grid(row=3,column=4, sticky=W)
sb2_label = Label(self, text="Pulse Width Step")
sb2_label.grid(row=2,column=4, padx=0, sticky=W)
# INTEGRATION LIMITS
Integration_label = Label(self, text="INTEGRATION LIMITS",
font = "Verdana 12 bold")
Integration_label.grid(row=4,column=3,
padx=5,
columnspan = 3, pady=10)
self.init_point.set("30")
sb3 = Spinbox(self, from_=1, to=10000,
width=6, textvariable=self.init_point)
sb3.grid(row=7,column=3, sticky=W)
sb3_label = Label(self, text="Start (usec)")
sb3_label.grid(row=6,column=3, padx=0, sticky=W)
self.end_point.set("160")
sb4 = Spinbox(self, from_=1, to=10000,
width=6, textvariable=self.end_point)
sb4.grid(row=7,column=4, sticky=W)
sb4_label = Label(self, text="End (usec)")
sb4_label.grid(row=6,column=4, padx=0, sticky=W)
# PARAMETERS
Integration_label = Label(self, text="PARAMETERS",
font = "Verdana 12 bold")
Integration_label.grid(row=8,column=3,
padx=5,
columnspan = 3, pady=10)
self.inc_point.set("3")
sb5 = Spinbox(self, from_=1, to=100,
width=6, textvariable=self.inc_point)
sb5.grid(row=11,column=3, sticky=W)
sb5_label = Label(self, text="First point")
sb5_label.grid(row=10,column=3, padx=0, sticky=W)
self.coef.set("1.636E-3")
e6 = Entry(self, width=10, textvariable=self.coef)
e6.grid(row=11,column=4, sticky=W)
e6_label = Label(self, text="DBLR Coef")
e6_label.grid(row=10,column=4, sticky=W)
self.noise.set("0.75")
e7 = Entry(self, width=10, textvariable=self.noise)
e7.grid(row=11,column=5, sticky=W)
e7_label = Label(self, text="Noise (LSB)")
e7_label.grid(row=10,column=5, sticky=W)
self.thr_sigma.set("40")
e8 = Entry(self, width=10, textvariable=self.thr_sigma)
e8.grid(row=13,column=3, sticky=W)
#.........这里部分代码省略.........
示例5: UIFrame
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
class UIFrame(Frame):
'''
This class is responsible for creating configuring and laying out all controls on the main GUI window. It returns UIFrame
object (based on Frame) representing the populated window for the application to interact with.
'''
def __init__(self, parent):
'''
Creates and returns a new UIFrame object.
_Parameters_
parent (required) - The parent widget object under which this console is to be created.
_Return_
UIFrame Object
'''
Frame.__init__(self, parent)
self.parent = parent
#Main window frames
self._optionsFrame = Frame(self.parent)
self._runFrame = Frame(self.parent)
self._consoleFrame = Frame(self.parent)
#Member widget creation and configuration - widgets configured in their constructors
self._lblLoopCount = Label(self._optionsFrame,
text = "Loop Count")
self.LoopSpinner = Spinbox(self._optionsFrame,
from_ = 1,
to = 5000,
repeatdelay = 500,
repeatinterval = 50)
self._lblOptions = Label(self._optionsFrame,
text="Options String")
self.OptionsEntry = Entry(self._optionsFrame,
exportselection = False)
self.ClearButton = Button(self._runFrame,
text="Clear")
self.RunButton = Button(self._runFrame,
text="Run!!!")
self.Console = ConsoleFrame(self._consoleFrame)
#Geometry control
#First pack the main window frames
self._optionsFrame.pack(fill = "x")
self._runFrame.pack()
self._consoleFrame.pack(fill = "both",
expand = True,
padx = 2,
pady = 2)
#This line is needed to allow the options column to have the correct width
self._optionsFrame.columnconfigure(1, weight = 1)
#widgets in options frame
self._lblLoopCount.grid(row = 0, column = 0,
sticky = "w",
padx = 2,
pady = 2)
self.LoopSpinner.grid(row = 1, column = 0,
sticky = "w",
padx = 2,
pady = 2)
self._lblOptions.grid(row = 0, column = 1,
sticky = "w",
padx = 2,
pady = 2)
self.OptionsEntry.grid(row = 1, column = 1,
sticky = "e"+"w",
padx = 2,
pady = 2)
#widgets in run frame
self.RunButton.pack(side = "left",
padx = 2,
pady = 2)
self.ClearButton.pack(side = "left",
padx = 2,
pady = 2)
#note - Console frame packed in constructor for console object
#set minimum window size
self.master.update_idletasks()
self.master.minsize(self.master.winfo_width(), self.master.winfo_height())
示例6: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def initUI(self):
self.parent.title("DBLR for Dummies")
self.pack(fill=BOTH, expand=True)
#self.columnconfigure(0, weight=1)
#self.rowconfigure(0, weight=1)
# weight attibute is used to make them growable
self.meas = IntVar()
self.point = IntVar()
self.base_path = StringVar()
self.coef = DoubleVar()
self.noise = DoubleVar()
self.n_sigma = DoubleVar()
self.thr1 = DoubleVar()
self.thr2 = DoubleVar()
self.thr3 = DoubleVar()
self.graph_sw = BooleanVar()
#Image
factor=0.65
search = Image.open("NEXT_official_logo.jpg")
width_org, height_org = search.size
search_temp = search.resize((int(width_org*factor),
int(height_org*factor)), Image.ANTIALIAS)
search_aux = ImageTk.PhotoImage(search_temp)
label1 = Label(self, image=search_aux)
label1.image = search_aux
label1.grid(row=0, column=4,
columnspan=2, rowspan=3, padx=5)
#self.base_path.set("F:/DATOS_DAC/2052/pmt_0_trace_evt_")
self.base_path.set("Argon.h5.z")
e1 = Entry(self, textvariable=self.base_path, width=40)
e1.grid(row=0,column=1, sticky=W, columnspan=3, pady=5, padx=5)
e1_label = Label(self, text="Path & Name")
e1_label.grid(row=0,column=0, columnspan=1, sticky=E, pady=5, padx=5)
self.point.set("0")
sb1 = Spinbox(self, from_=0, to=100,
width=4, textvariable=self.point)
sb1.grid(row=2,column=1, sticky=W, pady=5, padx=5)
sb1_label = Label(self, text="PMT")
sb1_label.grid(row=2,column=0, padx=5, sticky=E)
self.meas.set("0")
sb1 = Spinbox(self, from_=0, to=100,
width=4, textvariable=self.meas)
sb1.grid(row=2,column=3, sticky=W, pady=5, padx=5)
sb1_label = Label(self, text="Event")
sb1_label.grid(row=2,column=2, padx=5, sticky=E)
#Check buttons
# cb1 = Checkbutton(self, text="New Graph", variable=self.graph_sw)
# cb1.select()
# cb1.grid(row=2,column=2, sticky=W)
#PARAMETERS
Integration_label = Label(self, text="PARAMETERS",
font = "Verdana 12 bold")
Integration_label.grid(row=3,column=1,
padx=5,
columnspan = 2, pady=10, sticky=E)
self.coef.set("1.65E-3")
e2 = Entry(self, width=12, textvariable=self.coef)
e2.grid(row=4,column=1, sticky=W, pady=5, padx=5)
e2_label = Label(self, text="DBLR Coef")
e2_label.grid(row=4,column=0, sticky=E, pady=5, padx=5)
self.noise.set("0.75")
e3 = Entry(self, width=12, textvariable=self.noise)
e3.grid(row=4,column=3, sticky=W, pady=5, padx=5)
e3_label = Label(self, text="Noise (LSB)")
e3_label.grid(row=4,column=2, sticky=E, pady=5, padx=5)
self.n_sigma.set("4")
e4 = Entry(self, width=12, textvariable=self.n_sigma)
e4.grid(row=4,column=5, sticky=W, pady=5, padx=5)
e4_label = Label(self, text="Noise Threshold")
e4_label.grid(row=4,column=4, sticky=E, pady=5, padx=5)
self.thr1.set("0")
e5 = Entry(self, width=12, textvariable=self.thr1)
e5.grid(row=5,column=1, sticky=W, pady=5, padx=5)
e5_label = Label(self, text="Threshold 1")
e5_label.grid(row=5,column=0, sticky=E, pady=5, padx=5)
self.thr2.set("0")
e6 = Entry(self, width=12, textvariable=self.thr2)
e6.grid(row=5,column=3, sticky=W, pady=5, padx=5)
e6_label = Label(self, text="Threshold 2")
e6_label.grid(row=5,column=2, sticky=E, pady=5, padx=5)
self.thr3.set("0")
e7 = Entry(self, width=12, textvariable=self.thr3)
e7.grid(row=5,column=5, sticky=W, pady=5, padx=5)
#.........这里部分代码省略.........
示例7: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def initUI(self):
self.parent.title("FIND SPE VALUE")
self.pack(fill=BOTH, expand=True)
self.columnconfigure(0, weight=1)
#self.rowconfigure(0, weight=1)
# weight attibute is used to make them growable
self.graph_cb = BooleanVar()
self.bins = IntVar()
self.path = StringVar()
self.n_files = IntVar()
self.start_s = IntVar()
self.end_s = IntVar()
self.guess = IntVar()
search = Image.open("next_logo.jpg")
search_temp = search.resize((160, 200), Image.ANTIALIAS)
search_aux = ImageTk.PhotoImage(search_temp)
label1 = Label(self, image=search_aux)
label1.image = search_aux
label1.grid(row=0, column=0,
columnspan=10, rowspan=10, sticky=E+W+S+N)
#Number of Files and Bins. Spin Box
self.n_files.set("2000")
sb1 = Spinbox(self, from_=1, to=10000,
width=6, textvariable=self.n_files)
sb1.grid(row=1,column=4, sticky=W)
sb1_label = Label(self, text="Files")
sb1_label.grid(row=1,column=3, padx=5, sticky=E)
self.bins.set("50")
sb2 = Spinbox(self, from_=10, to=200,
width=6, textvariable=self.bins)
sb2.grid(row=1,column=6, sticky=W)
sb2_label = Label(self, text="Hist. Bins")
sb2_label.grid(row=1,column=5, padx=5, sticky=E)
# INTEGRATION LIMITS
Integration_label = Label(self, text="INTEGRATION",
font = "Verdana 12 bold")
Integration_label.grid(row=3,column=4,
padx=5,
columnspan = 2)
self.start_s.set("1732")
sb3 = Spinbox(self, from_=1, to=10000,
width=6, textvariable=self.start_s)
sb3.grid(row=4,column=4, sticky=W)
sb3_label = Label(self, text="StartPoint")
sb3_label.grid(row=4,column=3, padx=5, sticky=E)
self.end_s.set("1752")
sb4 = Spinbox(self, from_=1, to=10000,
width=6, textvariable=self.end_s)
sb4.grid(row=4,column=6, sticky=W)
sb4_label = Label(self, text="EndPoint")
sb4_label.grid(row=4,column=5, padx=5, sticky=E)
sb4_label = Label(self, text="")
sb4_label.grid(row=4,column=7, padx=5, sticky=E)
# FITTING PARAMETERS
Integration_label = Label(self, text="FITTING",
font = "Verdana 12 bold")
Integration_label.grid(row=6,column=4,
padx=5,
columnspan = 2)
self.guess.set("-20")
sb5 = Spinbox(self, from_=-50, to=-1,
width=6, textvariable=self.guess)
sb5.grid(row=7,column=4, sticky=W)
sb5_label = Label(self, text="SPE guess")
sb5_label.grid(row=7,column=5, padx=5, sticky=W)
#Check buttons
cb1 = Checkbutton(self, text="MultiGraph Output", variable=self.graph_cb )
cb1.select()
cb1.grid(row=7,column=6, sticky=W)
#Text Box
#self.path.set("F:/DATOS_DAC/spe_1230/2046/pmt_0_trace_evt_")
self.path.set("spe_1230_2046.h5.z")
e1 = Entry(self, textvariable=self.path, width=45)
e1.grid(row=10,column=3, sticky=W, columnspan=10, padx=10, pady=5)
e1_label = Label(self, text="DataSet path (including name file)")
e1_label.grid(row=9,column=3,sticky=W, columnspan=10, padx=10)
# Main buttons
obtn = Button(self, text="GO!!", command=self.SPE_f)
obtn.grid(row=14, column=5, sticky=E, pady=5)
cbtn = Button(self, text="Quit", command=self.quit)
cbtn.grid(row=14, column=6, sticky=E, pady=5)
hbtn = Button(self, text="Help")
#.........这里部分代码省略.........
示例8: MoveControl
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [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:
#.........这里部分代码省略.........
示例9: MacroEdit
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [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: __init__
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [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)
#.........这里部分代码省略.........
示例11: initUI
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def initUI(self):
self.parent.title("FIND BLR COEFFICIENT VALUE")
self.pack(fill=BOTH, expand=True)
self.columnconfigure(0, weight=1)
# self.rowconfigure(0, weight=1)
# weight attibute is used to make them growable
###### GUI Control Variables ######
self.LIMIT_L = IntVar()
self.LIMIT_H = IntVar()
self.PULSE_R = IntVar()
self.PULSE_L = IntVar()
self.pulse_height = DoubleVar()
self.hdf5_file = StringVar()
self.PMT = IntVar()
self.EVENT = IntVar()
self.amplitude_range = DoubleVar()
self.delta = DoubleVar()
self.noise_sigma = DoubleVar()
self.coeff = DoubleVar()
#self.DRAW = BooleanVar()
search = Image.open("next_logo.jpg")
search_temp = search.resize((170, 200), Image.ANTIALIAS)
search_aux = ImageTk.PhotoImage(search_temp)
label1 = Label(self, image=search_aux)
label1.image = search_aux
label1.grid(row=0, column=0,
columnspan=10, rowspan=10, sticky=E+W+S+N)
self.hdf5_file.set("2052.h5.z")
e1 = Entry(self, textvariable=self.hdf5_file, width=30)
e1.grid(row=1,column=1, sticky=W, columnspan=5, pady=5)
e1_label = Label(self, text="HDF5 file")
e1_label.grid(row=0,column=1,sticky=W, columnspan=5, pady=5)
self.PMT.set("0")
sb1 = Spinbox(self, from_=0, to=12,
width=3, textvariable=self.PMT)
sb1.grid(row=3,column=2, sticky=W)
sb1_label = Label(self, text="PMT")
sb1_label.grid(row=2,column=2, padx=0, sticky=W)
self.EVENT.set("0")
sb1 = Spinbox(self, from_=0, to=1000,
width=5, textvariable=self.EVENT)
sb1.grid(row=3,column=3, sticky=W)
sb1_label = Label(self, text="EVENT")
sb1_label.grid(row=2,column=3, padx=0, sticky=W)
self.LIMIT_L.set("19000")
sb1 = Spinbox(self, from_=0, to=100000,
width=5, textvariable=self.LIMIT_L)
sb1.grid(row=5,column=2, sticky=W)
sb1_label = Label(self, text="ROI Start ")
sb1_label.grid(row=4,column=2, padx=0, sticky=W)
self.LIMIT_H.set("22500")
sb1 = Spinbox(self, from_=0, to=100000,
width=5, textvariable=self.LIMIT_H)
sb1.grid(row=5,column=3, sticky=W)
sb1_label = Label(self, text="ROI End ")
sb1_label.grid(row=4,column=3, padx=0, sticky=W)
self.PULSE_R.set("20142")
sb1 = Spinbox(self, from_=0, to=100000,
width=8, textvariable=self.PULSE_R)
sb1.grid(row=5,column=4, sticky=E)
sb1_label = Label(self, text=" Pulse Rise")
sb1_label.grid(row=4,column=4, padx=0, sticky=E)
self.PULSE_L.set("1200")
sb1 = Spinbox(self, from_=0, to=5000,
width=8, textvariable=self.PULSE_L)
sb1.grid(row=5,column=5, sticky=E)
sb1_label = Label(self, text=" Pulse Length")
sb1_label.grid(row=4,column=5, padx=0, sticky=E)
sb1_label = Label(self, text=" ")
sb1_label.grid(row=2,column=7, padx=0, sticky=W)
sb1_label = Label(self, text=" ")
sb1_label.grid(row=6,column=7, padx=0, sticky=W)
self.pulse_height.set("545.5")
sb1 = Entry(self, width=8, textvariable=self.pulse_height)
sb1.grid(row=7,column=3, sticky=E)
sb1_label = Label(self, text=" Amplitude")
sb1_label.grid(row=6,column=3, padx=0, sticky=E)
#.........这里部分代码省略.........
示例12: ScanDialog
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [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)
#.........这里部分代码省略.........
示例13: Interface
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
class Interface(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.controller = Controller(TKRenderer())
self.initUI()
def initUI(self):
self.parent.title("Kinect Human Finder")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1, minsize=100, pad=10)
self.rowconfigure(1, weight=1, minsize=100, pad=10)
self.initHistoryFrame()
self.initImageFrame()
self.initMenuFrame()
def initHistoryFrame(self):
self.historyFrame = Frame(self, height=100, width=200, borderwidth=2)
self.backButton = Button(self.historyFrame, text="Back", command=lambda: self.showImage(self.controller.goBack()))
self.backButton.pack(side=LEFT, padx=5, pady=5)
self.nextButton = Button(self.historyFrame, text="Next", command=lambda: self.showImage(self.controller.goNext()))
self.nextButton.pack(side=LEFT, padx=5, pady=5)
self.openButton = Button(self.historyFrame, text="Open", command=self.openFile)
self.openButton.pack(side=LEFT, padx=(490,0), ipadx = 10, pady=5)
self.historyFrame.grid(row=0, column=0, columnspan=2, sticky=W)
def initImageFrame(self):
self.imageFrame = Frame(self, borderwidth=2)
if not os.path.exists(WELCOME_IMAGE_PATH):
print "Welcome image not found at:" + WELCOME_IMAGE_PATH
else:
if not os.path.exists(SECOND_WELCOME_IMAGE_PATH):
print "Second welcome image not found at:" + SECOND_WELCOME_IMAGE_PATH
else:
self.showImage(self.controller.loadImage(WELCOME_IMAGE_PATH))
self.showImage(self.controller.loadImage(SECOND_WELCOME_IMAGE_PATH))
def initMenuFrame(self):
self.menuFrame = Frame(self, width=400)
self.menuFrame.grid(row=1, column=1, sticky=N + E + S + W)
self.menuFrame.columnconfigure(0, weight=0, minsize=100, pad=10)
binaryText = Label(self.menuFrame, text="Mapa binarna")
preprocessingText = Label(self.menuFrame, text="Preprocessing")
cogText = Label(self.menuFrame, text="Środek ciężkości")
snakeText = Label(self.menuFrame, text="Metoda aktywnych konturów")
# Parameters
self.binarySpinFrame = self.createBinarySpinBoxes()
self.binarySpinFrame.grid(row=1, column=0, padx=36, pady=(5,15), stick=N + W)
self.preprocessFrame = self.createPreprocessBoxes()
self.preprocessFrame.grid(row=3, column=0, padx=36, pady=(0,15), stick=N + W)
self.cogSpinFrame = self.createCogSpinBoxes()
self.cogSpinFrame.grid(row=5, column=0, padx=36, pady=(0,15), stick=N + W)
self.snakeSpinFrame = self.createSnakeSpinBoxes()
self.snakeSpinFrame.grid(row=7, column=0, padx=36, pady=(0,15), stick=N + W)
binaryText.grid(row=0, padx=15, stick=N + W)
preprocessingText.grid(row=2, padx=15, stick=N + W)
cogText.grid(row=4, padx=15, stick=N + W)
snakeText.grid(row=6, padx=15, stick=N + W)
# Buttons
self.binaryButton = Button(self.menuFrame, text="Generuj mapą binarną",
command=lambda: self.showImage(self.controller.generateBinaryMotionBitmap(
int(self.binaryThreshold.get())
)))
self.preprocessButton = Button(self.menuFrame, text="Preprocessing",
command=lambda: self.showImage(self.controller.getPreprocessedBitmap(
int(self.binaryThreshold.get()),
int(self.erosion.get()), int(self.densityCoefficient.get())
)))
self.massCenterButton = Button(self.menuFrame, text="Pokaż centrum masy",
command=lambda: self.showImage(self.controller.getBitmapWithMassCenter(
int(self.binaryThreshold.get()),
int(self.erosion.get()), int(self.densityCoefficient.get()),
int(self.distanceFromCenterCoefficient.get())
)))
self.snakeButton = Button(self.menuFrame, text="Wyznacz kontur",
command=lambda: self.showImage(self.controller.getTheSnake(
#.........这里部分代码省略.........
示例14: Extruder
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [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")
示例15: main
# 需要导入模块: from Tkinter import Spinbox [as 别名]
# 或者: from Tkinter.Spinbox import grid [as 别名]
def main():
root = Tk()
root.title("Day Calculator")
Birthdate = Label(root, text="Birth Day").grid(row=0, column=0)
Today = Label(root, text="Today").grid(row=0, column=2)
monthLabel = Label(root, text="Month(MM)").grid(row=1, column=1)
dayLabel = Label(root, text="Day(DD)").grid(row=2, column=1)
yearLabel = Label(root, text="Year(YYYY)").grid(row=3, column=1)
# want to make a switch thingy
# is a spinbox, but still funky though.
# the birth info
birthMonth = Spinbox(root, from_=1, to=12, bd=5)
birthDay = Spinbox(root, from_=1, to=31, bd=5)
birthYear = Spinbox(root, from_=1900, to=3000, bd=5)
birthMonth.delete(0, END)
birthMonth.insert(10, 12)
birthDay.delete(0, END)
birthDay.insert(10, 5)
birthYear.delete(0, END)
birthYear.insert(10, 1994)
# today info
todayMonth = Spinbox(root, from_=1, to=12, bd=5)
todayDay = Spinbox(root, from_=1, to=31, bd=5)
todayYear = Spinbox(root, from_=1900, to=3000, bd=5)
today = getTodayInfo()
todayMonth.delete(0, END)
todayMonth.insert(10, today[0])
todayDay.delete(0, END)
todayDay.insert(10, today[1])
todayYear.delete(0, END)
todayYear.insert(10, today[2])
# grid it!
birthMonth.grid(row=1, column=0)
birthDay.grid(row=2, column=0)
birthYear.grid(row=3, column=0)
todayMonth.grid(row=1, column=2)
todayDay.grid(row=2, column=2)
todayYear.grid(row=3, column=2)
text = Entry(root, bd=5)
text.insert(END, "Press Submit")
text.grid(row=4, column=2)
# functions
def calculate():
text.delete(0, END)
days = differenceManual(
int(birthMonth.get()),
int(birthDay.get()),
int(birthYear.get()),
int(todayMonth.get()),
int(todayDay.get()),
int(todayYear.get())
)
if days == -1:
string = "Incorrect Date"
else:
string = str(days) + " Days Old!"
text.insert(END, string)
submit = Button(root, text="Submit", command=calculate)
quit = Button(root, text='Quit', command=root.quit)
submit.grid(row=4, column=1)
quit.grid(row=4, column=0)
# run!!!
root.mainloop()