本文整理汇总了Python中Tkinter.LabelFrame.grid方法的典型用法代码示例。如果您正苦于以下问题:Python LabelFrame.grid方法的具体用法?Python LabelFrame.grid怎么用?Python LabelFrame.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.LabelFrame
的用法示例。
在下文中一共展示了LabelFrame.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def __init__(self, tracker, board, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
self.tracker = tracker
self.board = board
tracker_subframe = LabelFrame(self, text="Tracker stuff")
self.tracker_button = Button(tracker_subframe, text="Tracker",
command=self.open_tracker_frame)
self.tracker_button.grid()
self.joystick_button = Button(tracker_subframe, text="Joystick",
command=self.open_joystick_frame)
self.joystick_button.grid()
self.reposn_button = Button(tracker_subframe, text="Repositioning",
command=self.open_repositioning_frame)
self.reposn_button.grid()
self.measure_button = Button(tracker_subframe, text="Measure",
command=self.open_measure_frame)
self.measure_button.grid()
self.plotting_button = Button(tracker_subframe, text="Plotting",
command=self.open_plotting_frame)
self.plotting_button.grid()
tracker_subframe.grid()
self.actuator_button = Button(self, text="Actuators",
command=self.open_actuator_frame)
self.actuator_button.grid()
示例2: MeasureFrame
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
class MeasureFrame(LabelFrame):
def __init__(self, master, tracker, text="Measuring", *args, **kwargs):
LabelFrame.__init__(self, master, text=text, *args, **kwargs)
self.tracker = tracker
self.config_frame = NamedEntryFrame(self, (OBS_INTERVAL,
NUM_SAMPLES,
NUM_OBSS),
parsers={OBS_INTERVAL: float,
NUM_SAMPLES: int,
NUM_OBSS: int})
self.config_frame.grid()
self.save_frame = LabelFrame(self, text="Saving")
self.dest_selector = FileSelectionFrame(self.save_frame,
ask_mode="save")
self.dest_selector.grid(row=0, column=0, columnspan=2)
self.save_button = Button(self.save_frame, text="Save",
command=bg_caller(self.save))
self.save_button.grid(row=1, column=0)
self.appending_var = BooleanVar()
self.append_checkbutton = Checkbutton(self.save_frame, text="Append",
variable=self.appending_var)
self.append_checkbutton.grid(row=1, column=1)
self.save_frame.grid()
def measure(self, only_accurate=True):
try:
interval = self.config_frame.get(OBS_INTERVAL)
samples = self.config_frame.get(NUM_SAMPLES)
num_obss = self.config_frame.get(NUM_OBSS)
except ValueError:
logger.error("Could not parse input fields.")
data = self.tracker.measure(observation_interval=interval,
samples_per_observation=samples,
number_of_observations=num_obss)
if only_accurate:
accurate_data = [point for point in data
if point.status == point.DATA_ACCURATE]
num_invalid = len(data) - len(accurate_data)
if num_invalid > 0:
logger.warning("Hiding {} inaccurate data points."
.format(num_invalid))
return accurate_data
else:
return data
def save(self, only_accurate=True):
dest = self.dest_selector.path_var.get()
if not dest:
logger.error("Must select a destination file.")
return
data = self.measure(only_accurate=only_accurate)
w = csv.writer(open(dest, 'a' if self.appending_var.get() else 'w'))
for point in data:
w.writerow((point.time, point.position.r,
point.position.theta, point.position.phi))
logger.info("Saved measurements into {!r}".format(dest))
示例3: __init__
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def __init__(self, master, tracker, text="Joystick", **options):
LabelFrame.__init__(self, master, text=text, **options)
self.tracker = tracker
self.width = 400
self.height = 400
self.canvas = Canvas(self, height=self.height, width=self.width)
self.canvas.grid()
self.canvas.create_oval((self.width/2 - 3, self.height/2 - 3,
self.width/2 + 3, self.height/2 + 3))
self.canvas.bind("<Button-1>",
bg_caller(lambda event: self.move_tracker(event)))
self.canvas.bind("<Motion>", self.update_label)
self.motion_label = Label(self, text="",
font=tkFont.Font(family="Courier"))
self.motion_label.grid()
f = LabelFrame(self, text="Sensitivity")
self.sensitivity_scale = Scale(f, from_=0, to=10,
resolution=0.01,
orient=HORIZONTAL,
length=self.width)
self.sensitivity_scale.set(5)
self.sensitivity_scale.grid()
f.grid()
示例4: site
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def site(self):
from Tkinter import LabelFrame
site_frame = LabelFrame(self.root, height = 100, width = 150, text = "Site settings")
site_frame.grid(column = 0, row = 0, columnspan = 1, rowspan = 1)
from scrolledlist import ScrolledList
site = ScrolledList(site_frame, width = 20, height = 3)
site.grid(column = 0, row = 0, columnspan = 1, rowspan = 1)
示例5: time
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def time(self):
from Tkinter import LabelFrame
time_frame = LabelFrame(self.root, height = 100, width = 150, text = "Time settings")
time_frame.grid(column = 1, row = 0, columnspan = 1, rowspan = 1)
from Tkinter import Radiobutton
time_now = Radiobutton(time_frame, text = "Now", variable = time, value = 1)
time_now.grid(column = 0, row = 0, columnspan = 1, rowspan = 1)
time_selection = Radiobutton(time_frame, text = "Select", variable = time, value = 2)
time_selection.grid(column = 0, row = 1, columnspan = 1, rowspan = 1)
示例6: __init__
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def __init__(self, master, names, parsers={}, **kwargs):
LabelFrame.__init__(self, master, **kwargs)
entries = {}
for name in names:
f = LabelFrame(self, text=name)
entries[name] = Entry(f)
entries[name].grid()
f.grid()
NamedEntryContainer.__init__(self, entries=entries, parsers=parsers)
示例7: show
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def show(self):
self.__root.title(CONST.APP_NAME)
mainFrame = Frame(self.__root)
# Configure main frame and make Dialog stretchable (to EAST and WEST)
top = mainFrame.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
mainFrame.rowconfigure(0, weight=1)
mainFrame.columnconfigure(0, weight=1)
mainFrame.grid(sticky='ew')
# Configure the frames to hold the controls
# - Frame with input settings
inputFrame = LabelFrame(mainFrame, text='Input Settings')
inputFrame.columnconfigure(1, weight=1)
inputFrame.grid(column=0, row=0, padx=5, pady=5, sticky='ew')
# - Frame with output settings
outputFrame = LabelFrame(mainFrame, text='Output Settings')
outputFrame.columnconfigure(1, weight=1)
outputFrame.grid(column=0, row=1, padx=5, pady=5, sticky='ew')
# - Frame with buttons at the bottom of the dialog
buttonFrame = Frame(mainFrame)
buttonFrame.grid(column=0, row=2, padx=5, pady=5, sticky='e')
# Controls for input
dataSourceFileLabel = Label(inputFrame, text='Data File:', width=15, anchor='w')
dataSourceFileLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
dataSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getDataSourceFileEntryVariable())
dataSourceFileEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')
dataSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.dataSourceFileEntryVariableHandler)
dataSourceFileButton.grid(column=2, row=1, padx=5, pady=5, sticky='e')
# Controls for output
numberOfDataLinesToMergeLabel = Label(outputFrame, text='Number of rows to merge into this document:', width=35, anchor='w')
numberOfDataLinesToMergeLabel.grid(column=0, row=2, padx=5, pady=5, sticky='w')
# numberOfDataLinesToMergeListBox = OptionMenu(outputFrame, self.__ctrl.getSelectedNumberOfLines(), tuple(self.__ctrl.getNumerOfLinesList())) # TODO: implement these two functions in the controller
numberOfDataLinesToMergeListBox = apply(OptionMenu, (outputFrame, self.__ctrl.getSelectedNumberOfLines()) + tuple(self.__ctrl.getNumerOfLinesList()))
numberOfDataLinesToMergeListBox.grid(column=1, row=2, padx=5, pady=5, sticky='w')
# Buttons
cancelButton = Button(buttonFrame, text='Cancel', width=10, command=self.__ctrl.buttonCancelHandler)
cancelButton.grid(column=1, row=0, padx=5, pady=5, sticky='e')
runButton = Button(buttonFrame, text='Run', width=10, command=self.__ctrl.buttonOkHandler)
runButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')
# Show the dialog
mainFrame.grid()
self.__root.grid()
self.__root.mainloop()
示例8: families
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def families(self):
from Tkinter import LabelFrame
families_frame = LabelFrame(self.root, height = 100, width = 150, text = "Family selection")
families_frame.grid(column = 1, row = 1, columnspan = 1, rowspan = 1)
import scrolledlist
family = scrolledlist.ScrolledList(families_frame, width = 20, height = 4)
from os import listdir
families = listdir('/home/case/TLEs')
for i in range(len(families)):
family.append(families[i])
family.grid(column = 0, row = 0, columnspan = 1, rowspan = 1)
示例9: __init__
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def __init__(self, master, tracker, text="Repositioning", **kwargs):
LabelFrame.__init__(self, master, text=text, **kwargs)
self.tracker = tracker
self.source_selector = FileSelectionFrame(self, initial_dir=nodes_dir,
ask_mode="open",
text="Source")
self.source_selector.grid(row=0, column=0)
self.dest_selector = FileSelectionFrame(self, initial_dir=nodes_dir,
ask_mode="save", text="Dest")
self.dest_selector.grid(row=0, column=1)
# The names and positions we gather:
self.name_fields = []
self.posn_labels = []
self.training_info = []
for i in range(3):
# Why three? Well, we need three training points to figure
# out where all the other points are. Proof: take your
# fist and move it around (it's a rigid structure, like
# the arrangement of retroreflectors), and think about how
# many points (e.g. knuckles) you'd need to know the
# positions of to figure out the positions of all your
# other knuckles. (It's three. If you disagree, please
# think about it more until you agree, because I am
# absolutely confident.)
f = LabelFrame(self, text="(Name/position) ({})".format(i))
self.name_fields.append(Entry(f))
self.name_fields[-1].grid(row=0, column=0)
self.posn_labels.append(Label(f, text="<None>"))
self.posn_labels[-1].grid(row=0, column=1)
b = Button(f, text="Set",
command=bg_caller(deglobalize_args(self.set_position,
i)))
b.grid(row=0, column=2)
f.grid(row=1+i, column=0, columnspan=2)
self.training_info.append(None)
Button(self, text="Compute/Save", command=self.save).grid(row=4,
column=0)
示例10: setup_im_proc_section
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def setup_im_proc_section(self):
im_proc = LabelFrame(self.parent, width=col_w, height=row_h, text="Image Processing Status")
im_proc.grid(row=2, column=0)
self.im_proc_txt = Text(im_proc, height=18, width=65)
self.im_proc_txt.pack(fill=BOTH, expand=1)
示例11: setup_controller_section
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def setup_controller_section(self):
controller = LabelFrame(self.parent, width=col_w * 2, height=row_h, text="Controller Status")
controller.grid(row=0, column=1, columnspan=2)
self.ctrl_txt = Text(controller, height=18, width=130)
self.ctrl_txt.pack(fill=BOTH, expand=1)
示例12: RigRemote
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
class RigRemote(ttk.Frame): #pragma: no cover
"""Remote application that interacts with the rig using rigctl protocol.
Gqrx partially implements rigctl since version 2.3.
:raises: none
:returns: none
"""
def __init__(self, root, ac): #pragma: no cover
ttk.Frame.__init__(self, root)
self.bookmarks_file = BOOKMARKS_FILE
self.log_file = None
self.build(ac)
self.cbb_mode.current(0)
# bookmarks loading on start
self.bookmark("load", ",")
def build(self, ac): #pragma: no cover
"""Build and initialize the GUI widgets.
:param: none
:raises: none
:returns: none
"""
self.master.title("Rig Remote")
self.master.minsize(800, 244)
self.pack(fill=tk.BOTH, expand=1, padx=5, pady=5)
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
# bookmarks list
self.tree = ttk.Treeview(self,
columns=("frequency",
"mode",
"description"),
show="headings")
self.tree.heading('frequency',
text='Frequency',
anchor=tk.CENTER)
self.tree.column('frequency',
#minwidth=100,
width=100,
stretch=True,
anchor=tk.CENTER)
self.tree.heading('mode',
text='Mode',
anchor=tk.CENTER)
self.tree.column('mode',
#minwidth=80,
width=70,
stretch=True,
anchor=tk.CENTER)
self.tree.heading('description',
text='Description',
)
self.tree.column('description',
stretch=True,
#width=70
)
ysb = ttk.Scrollbar(self,
orient=tk.VERTICAL,
command=self.tree.yview)
ysb.grid(row=0,
column=2,
rowspan=5,
sticky=tk.NS)
xsb = ttk.Scrollbar(self,
orient=tk.HORIZONTAL,
command=self.tree.xview)
xsb.grid(row=5,
column=0,
sticky=tk.NSEW
)
self.tree.configure(
yscroll=ysb.set,
#xscroll=xsb.set
)
self.tree.grid(row=0,
column=0,
rowspan=5,
sticky=tk.NSEW
)
self.tree.bind('<<TreeviewSelect>>',
self.cb_autofill_form)
self.tree.bind('<Double-Button-1>',
self.cb_set_frequency)
# vertical separator between bookmarks and comands
ttk.Frame(self).grid(row=0,
column=2,
rowspan=5,
padx=5)
# # right-side container
self.rig_config_menu = LabelFrame(self,
text="Rig configuration")
self.rig_config_menu.grid(row=0,
column=3,
stick=tk.NSEW)
ttk.Label(self.rig_config_menu,
text="Hostname:").grid(row=1,
#.........这里部分代码省略.........
示例13: TKEA_win
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
class TKEA_win(object):
def __init__(self,ea,p,rec,varlist):
self.vl=varlist # list of EA attributes which you wanna make accessible via window
self.ea=ea # the EA instance
self.ea.generation_callbacks.append(self.update_solu_canvas)
self.ea.generation_callbacks.append(self.update_mstep_bar)
self.ea.generation_callbacks.append(self.rec_save_status)
self.ea.generation_callbacks.append(self.acp_update)
self.acp_type='linear' # also allowed up to date: 'semilogy'
self.acp_ylim=False
self.acp_freq=1
self.update_freq=1
self.p=p # main population
self.rec=rec
tmppop=population_like(p,size=1)
self.frontman=tmppop[0] # an extra individual, the one bein plotted
def appear(self):
self.mwin=Tk() # root or main window
self.mwin.title('EA progress visualisation')
self.setupFig()
self.setupWindow()
def setupFig(self):
self.fig=plt.figure(figsize=(8,7), dpi=80)
self.sp1=self.fig.add_subplot(211) # additional colorbar might be created under the name self.sp1_cb
self.sp2=self.fig.add_subplot(212) # additional colorbar might be created under the name self.sp2_cb
self.sp1t=self.sp1.set_title('ini')
self.sp2t=self.sp2.set_title('ini')
def setupWindow(self):
self.f_inp=Frame(self.mwin); self.f_inp.pack(side='left')
self.f_plot=Frame(self.mwin); self.f_plot.pack(side='right')
self.c=FigureCanvasTkAgg(self.fig, master=self.f_plot); self.c.show()
self.c.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
# setup the input area
self.f_actn=LabelFrame(self.f_inp,text='action'); self.f_actn.grid(row=0,column=0)
self.f_gg=Frame(self.f_actn); self.f_gg.pack()
l_gg=Label(self.f_gg,text='generations'); l_gg.pack()
self.e_gg = Entry(self.f_gg); self.e_gg.pack(); self.e_gg.insert(0,'40') # number of generations
self.b_rini=Button(self.f_actn,text='randini',command=self.randini); self.b_rini.pack()
self.b_run1=Button(self.f_actn,text='update & run',command=self.run_with_readout); self.b_run1.pack()
self.b_run2=Button(self.f_actn,text='run (continue)',command=self.run_no_readout); self.b_run2.pack()
if len(self.vl): self.add_entries(self.vl)
# draw initial plot
self.draw_ini_solu() # sort of setting up instructive initial geometry plot of non-optimised geometry
self.acp_ini()
self.f_tb=Frame(self.f_plot); self.f_tb.pack()
self.tb=NavigationToolbar2TkAgg(self.c,self.f_tb)
self.c2=Canvas(self.f_inp,width=80,height=140); self.c2.grid(row=4,column=0)
self.ini_mstep_bar()
def add_entries(self,vl):
for el in vl:
if not hasattr(self.ea,el['name']):
raise TypeError('you try to set up an entry for a name which is no attribute of the chosen EA')
fr=Frame(self.f_actn); fr.pack()
lab=Label(fr,text=el['name']); lab.pack()
e = Entry(fr); e.pack(); e.insert(0,str(el['inival'])) # number of generations
el['Entry']=e
def draw_ini_solu(self):
self.frontman.plot_into_axes(self.sp1)
txt='initial DNA'.format(self.frontman.DNA)
self.sp1t.set_text(txt)
def draw_solu(self,dude):
self.frontman.copy_DNA_of(dude,copyscore=True,copyparents=True,copyancestcode=True)
self.frontman.evaluate()
self.frontman.update_plot(self.sp1)
txt='generation {}: score is {:.3f} after {} function calls'.format(self.p.gg,self.ea.bestdude.score,self.ea.tell_neval())
#self.sp1t.set_text(txt)
self.sp1.set_title(txt)
self.c.draw()
def mainloop(self):
self.mwin.mainloop()
def randini(self):
self.p.reset()
self.rec.clear()
self.ea.bestdude=None
self.ea.zeroth_generation(random_ini=True)
self.draw_solu(self.ea.bestdude)
self.c.draw()
def run_with_readout(self):
for el in self.vl:
if el['type'] is float:
val=float(el['Entry'].get())
exec('self.ea.'+el['name']+'='+str(val))
elif el['type'] is int:
val=int(float(el['Entry'].get()))
exec('self.ea.'+el['name']+'='+str(val))
elif el['type'] is str:
val=el['Entry'].get()
exec('self.ea.'+el['name']+"='"+val+"'")
elif el['type'] is list:
val=el['Entry'].get()
#.........这里部分代码省略.........
示例14: setup_depositing_section
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def setup_depositing_section(self):
depositing = LabelFrame(self.parent, width=col_w, height=row_h, text="Depositing Status")
depositing.grid(row=1, column=1)
self.dep_txt = Text(depositing, height=18, width=65)
self.dep_txt.pack(fill=BOTH, expand=1)
示例15: setup_move_section
# 需要导入模块: from Tkinter import LabelFrame [as 别名]
# 或者: from Tkinter.LabelFrame import grid [as 别名]
def setup_move_section(self):
mv = LabelFrame(self.parent, width=col_w, height=row_h, text="Moving Status")
mv.grid(row=2, column=1)
self.mv_txt = Text(mv, height=18, width=65)
self.mv_txt.pack(fill=BOTH, expand=1)