本文整理汇总了Python中Tkinter.Checkbutton.grid方法的典型用法代码示例。如果您正苦于以下问题:Python Checkbutton.grid方法的具体用法?Python Checkbutton.grid怎么用?Python Checkbutton.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Checkbutton
的用法示例。
在下文中一共展示了Checkbutton.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MeasureFrame
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton 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))
示例2: PasswordDialog
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
class PasswordDialog(Dialog):
def __init__(self, title, prompt, parent):
self.prompt = prompt
Dialog.__init__(self, parent, title)
def body(self, master):
from Tkinter import Label
from Tkinter import Entry
from Tkinter import Checkbutton
from Tkinter import IntVar
from Tkinter import W
self.checkVar = IntVar()
Label(master, text=self.prompt).grid(row=0, sticky=W)
self.e1 = Entry(master)
self.e1.grid(row=0, column=1)
self.cb = Checkbutton(master, text="Save to keychain", variable=self.checkVar)
self.cb.pack()
self.cb.grid(row=1, columnspan=2, sticky=W)
self.configure(show='*')
def apply(self):
self.result = (self.e1.get(), self.checkVar.get() == 1)
示例3: MakeCB
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def MakeCB(self, cb_ptr, text, evt_type, arg, csp=1, stky=W):
cb_ptr = Checkbutton(self, text=text)
cb_ptr.bind(evt_type, lambda event, arg=arg: self.toggle_cb(event, arg))
if self.orig[arg]:
cb_ptr.select()
cb_ptr.grid(row=self.row, column=self.col, columnspan=csp, sticky=W)
self.row += 1
示例4: redraw
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def redraw(self):
# Even though there are never more than three widgets per row,
# we have four columns, to allow the taskname label and the
# input widget to stretch.
self.grid_columnconfigure(2, weight=1)
row = 0
# Add a new row of widgets for each task.
for rec in sorted(self.table.query(), key=lambda rec: rec.get('created')):
# Extract the fields we need.
completed = rec.get('completed')
taskname = rec.get('taskname')
# Create a button with an 'X' in it, to delete the task.
close_btn = Button(self, text='X',
command=lambda rec=rec: self.delete_rec(rec))
close_btn.grid(row=row, column=0)
# Create a checkbox, to mark it completed (or not).
var = BooleanVar(self, value=completed)
completed_btn = Checkbutton(self, variable=var,
command=lambda rec=rec, var=var:
self.toggle_rec(rec, var))
completed_btn.grid(row=row, column=1)
# Create a label showing the task name.
taskname_lbl = Label(self, text=taskname, anchor=W)
taskname_lbl.grid(row=row, column=2, columnspan=2, sticky=W)
row += 1 # Bump row index.
# Add a final row with the input and button to add new tasks.
self.input = Entry(self)
self.input.bind('<Return>', self.add_rec)
self.input.grid(row=row, column=0, columnspan=3, sticky=W+E)
add_btn = Button(self, text='Add Task', command=self.add_rec)
add_btn.grid(row=row, column=3)
# Add save button. (Auto-save is left as an exercise.)
save_btn = Button(self, text='Save local snapshot', command=self.save)
save_btn.grid(row=row+1, column=0, columnspan=3, sticky=W)
示例5: GpioSimulator
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
class GpioSimulator():
def __init__(self, frontend):
self.frontend = frontend
self.playing_led = None
thread = Thread(target=self.initial_simulator)
thread.start()
def initial_simulator(self):
root = Tk()
root.title("GPIO Simulator")
previous = Button(root, text="Previous", command=self.previous)
main = Button(root, text="Main button", command=self.main)
next = Button(root, text="Next", command=self.next)
vol_up = Button(root, text="Vol +", command=self.vol_up)
vol_up_long = Button(root, text="Vol + long", command=self.vol_up_long)
vol_down = Button(root, text="Vol -", command=self.vol_down)
vol_down_long = Button(root, text="Vol - long",
command=self.vol_down_long)
main_long = Button(root, text="Main long", command=self.main_long)
self.playing_led = Checkbutton(text="playing_led", state=DISABLED)
vol_up.grid(row=0, column=1)
vol_up_long.grid(row=0, column=2)
previous.grid(row=1, column=0)
main.grid(row=1, column=1)
main_long.grid(row=1, column=2)
next.grid(row=1, column=3)
vol_down.grid(row=2, column=1)
vol_down_long.grid(row=2, column=2)
self.playing_led.grid(row=3, column=1)
root.mainloop()
def previous(self):
self.frontend.input({'key': 'previous', 'long': False})
def main(self):
self.frontend.input({'key': 'main', 'long': False})
def main_long(self):
self.frontend.input({'key': 'main', 'long': True})
def next(self):
self.frontend.input({'key': 'next', 'long': False})
def vol_up(self):
self.frontend.input({'key': 'volume_up', 'long': False})
def vol_down(self):
self.frontend.input({'key': 'volume_down', 'long': False})
def vol_down_long(self):
self.frontend.input({'key': 'volume_down', 'long': True})
def vol_up_long(self):
self.frontend.input({'key': 'volume_up', 'long': True})
示例6: dimscheduler
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def dimscheduler(self):
mischeader = headersmall(self.frame, text="Dimension Scheduler")
f = Frame(self.frame)
f.config(bg=Styles.colours["grey"])
smallentryframetext(f, 0, 0, self.params["dims"], 7, "Set Size:")
checkdimschel = Checkbutton(self.frame, text="Enable", variable=self.params["dimscheudler"], bg=Styles.colours["grey"])
mischeader.grid(row=18, column=0, sticky=W, columnspan=2)
checkdimschel.grid(row=19, column=0, sticky=W, columnspan=1, padx=15)
f.grid(row=19, column=1, sticky=W + E, columnspan=1)
示例7: AuthDialog
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
class AuthDialog(Popup):
message = _('Enter username and password\nfor "%(method)s" at "%(realm)s"')
def __init__(self, parent, deferred, method, realm, addnl=None):
self.deferred = deferred
self.method = method
self.realm = realm
self._saveOK = False
Popup.__init__(self, parent, addnl)
def _saveBoolean(self, *value):
self._saveOK = not self._saveOK
def getResult(self):
return (self.uentry.get(), self.pentry.get(), self._saveOK)
def body(self):
print "auth body"
from Tkinter import NW, E, W, Frame, Label, Button, Entry, Checkbutton
defargs = { 'padx':5, 'pady':5, 'sticky':W }
self.top = Frame(self)
self.top.grid(row=1,column=1,sticky=NW)
msg = self.message % { 'realm':self.realm, 'method':self.method }
self.label = Label(self.top, text=msg, justify='center')
self.label.grid(row=1, column=1, columnspan=4, **defargs)
self.ulabel = Label(self.top, text=_('User Name')+':', justify='left')
self.ulabel.grid(row=2, column=1, columnspan=2, **defargs)
self.uentry = Entry(self.top)
self.uentry.grid(row=2, column=3, columnspan=2, **defargs)
self.uentry.focus_set()
self.plabel = Label(self.top, text=_('Password')+':', justify='left')
self.plabel.grid(row=3, column=1, columnspan=2, **defargs)
self.pentry = Entry(self.top, show="*")
self.pentry.grid(row=3, column=3, columnspan=2, **defargs)
self._saveOk = False
self.saveCheck = Checkbutton(self.top, command=self._saveBoolean)
self.saveCheck.grid(row=4, column=1, columnspan=1, **defargs)
self.savelabel = Label(self.top,
text=_('Save this username and password'))
self.savelabel.grid(row=4, column=2, columnspan=3, **defargs)
defargs['sticky'] = W
self.cancelb = Button(self.top, text=_('Cancel'), command=self.cancel)
self.cancelb.grid(row=5, column=3, columnspan=1, **defargs)
self.okb = Button(self.top, text=_('OK'), command=self.selected)
self.okb.grid(row=5, column=4, columnspan=1, **defargs)
示例8: addCheckButton
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def addCheckButton(self, item):
self.entryBox.delete(0, END)
self.label1.grid_forget()
self.todoList.append(item)
n = len(self.buttonList)
lx = Checkbutton(self.listFrame, text=self.todoList[n], variable=self.todoList[n], command=lambda ni=n: self.removeCheckButton(ni))
lx.grid(row=n, column=0, sticky='NW')
self.buttonList.append(lx)
#print self.buttonList
self.saveData(self.todoList)
示例9: IssueDialog
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
class IssueDialog(tkSimpleDialog.Dialog):
def body(self, top):
self.title("Issue Number")
Label(top, text="Enter issue number: ").grid(row=0, sticky=W)
Label(top, text="Chapter number to start with: ").grid(row=1, sticky=W)
Label(top, text="Enter password for " + user + ": ").grid(row=2, sticky=W)
self.e1 = Entry(top)
self.e1.insert(0, "000")
self.e1.grid(row=0, column=1)
self.e3 = Entry(top)
self.e3.insert(0, "2")
self.e3.grid(row=1, column=1)
self.e2 = Entry(top, show="*")
self.e2.grid(row=2, column=1)
self.var = IntVar()
self.b = Checkbutton(top, text="Debug?", variable= self.var, onvalue = 1, offvalue = 0)
self.b.grid(row=3, columnspan=2, sticky=W)
#def callConvert():
#essa_clipboardDateConvert.convert()
#self.convertButton = Button(top, text="Convert clipboard date", command=callConvert)
#self.convertButton.grid(row=4, columnspan=2, sticky=W)
def apply(self):
global issue
issue = self.e1.get()
global chapNum
chapNum = int(self.e3.get())
global password
password = self.e2.get()
global debug
debug = self.var.get()
示例10: openfile
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def openfile():
name = askopenfilename()
nam = name.split("/")
g = nam[-1].split(".")
grup = g[0]
print(nam, g)
print(grup)
fitxer = open(name, mode="r")
for linia in fitxer:
coordinates = linia.split("\t")
N, X, Y, Z, C = coordinates
N = coordinates[0]
X = coordinates[1]
Y = coordinates[2]
Z = coordinates[3]
C = [coordinates[4]]
if len(coordinates) > 5:
i = 5
for c in range(len(coordinates) - 5):
C.append(coordinates[i])
codis.add(c)
i = i + 1
codis.add(C[0])
i = 0
r = 2
c = 1
if askyesno("codis...", "Vols unir per codis?"):
codis_linia.clear()
tria = tk.Toplevel()
ok = tk.Button(tria, text="ok", width=25, command=tria.destroy)
ok.grid(column=0, row=0, columnspan=5)
for item in codis:
codis_linia[str(item)] = IntVar()
chb = Checkbutton(tria, text=str(item), variable=codis_linia[item], onvalue=True, offvalue=False, height=5)
if c > 5:
c = 1
r = r + 1
chb.grid(column=c, row=r)
c = c + 1
label2 = tk.Label(tria, text="Quins codis son linies")
label2.grid(row=1, columnspan=5)
示例11: __init__
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def __init__(self, master, mech):
self.mech = mech
frame = Frame(master)
frame.grid()
rct_label = Label(frame, text = 'Select Reactants')
rct_label.grid(column = 1, row = 1)
and_or = Label(frame, text = 'AND/OR')
and_or.grid(column = 3, row = 1)
prod_label = Label(frame, text = 'Select Products')
prod_label.grid(column = 4, row = 1)
what_to_do = Label(frame, text = 'Execute')
what_to_do.grid(column = 6, row = 1)
reactants_scrollbar = Scrollbar(frame, orient = VERTICAL)
self.reactants = Listbox(frame, selectmode = EXTENDED, exportselection = 0, yscrollcommand = reactants_scrollbar.set)
self.reactants.grid(column = 1, row = 2)
reactants_scrollbar.config(command = self.reactants.yview)
reactants_scrollbar.grid(column = 2, row = 2, sticky = N + S)
self.logical_and = IntVar()
self.logical_and.set(1)
c = Checkbutton(frame, text = "AND", variable = self.logical_and)
c.grid(column = 3, row = 2)
products_scrollbar = Scrollbar(frame, orient = VERTICAL)
self.products = Listbox(frame, selectmode = EXTENDED, exportselection = 0)
self.products.grid(column = 4, row = 2)
products_scrollbar.config(command = self.products.yview)
products_scrollbar.grid(column = 5, row = 2, sticky = N + S)
self.method_list = Listbox(frame, selectmode = EXTENDED, exportselection = 0)
self.method_list.grid(column = 6, row = 2)
#self.methods = [k for k in dir(self.mech) if k[:1] != '_' and isinstance(getattr(self.mech, k), MethodType)]
self.methods = ['plot_rxns', 'find_rxns', 'print_rxns', 'print_irrs', 'print_net_rxn', 'plot_proc']
method_labels= ['Plot Reactions', 'Show Rxn Ids', 'Print Rxns', 'Print IRRs', 'Print Net Rxn', 'Process Plot']
for method in method_labels:
self.method_list.insert(END, method)
species_keys = self.mech.species_dict.keys()
species_keys.sort()
self.species_objects = [self.mech.species_dict[spc] for spc in species_keys]
for spc in species_keys:
self.reactants.insert(END, spc)
self.products.insert(END, spc)
self.execute_button = Button(frame, text = "go", command = self.execute)
self.execute_button.grid(column = 6, row = 4)
示例12: addFile
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def addFile(self,filename,ibans):
if filename != u"" and len(ibans) > 0:
Label(self.tabFiles, text=filename,
borderwidth=3).grid(row=self.row,column=0,sticky=constants.W,padx=1)
ibanList = []
for iban in ibans:
ibanList.append( iban[:8] )
combo = ttk.Combobox(self.tabFiles,values=ibanList)
combo.current(0)
if len(ibanList) == 1:
combo.configure(state=constants.DISABLED)
combo.grid(row=self.row,column=1,sticky=constants.E,padx=1)
state = IntVar()
c = Checkbutton(self.tabFiles,variable=state)
c.grid(row=self.row,column=2)
self.row += 1
ttk.Separator(self.tabFiles).grid(row=self.row, sticky=u"ew", columnspan=3 )
self.row += 1
self.guiMap.append( [ filename, ibans, combo, c, state ] )
示例13: MethodCheckButton
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
class MethodCheckButton(Frame):
def __init__(self, master):
Frame.__init__(self, master, width = 15)
self.initComplete = False
self.getVar = IntVar()
self.postVar = IntVar()
self.getCheckButton = Checkbutton(self, \
text = "GET", width = 6, variable = self.getVar, \
command = self.__singleSelectCommandGet, onvalue = 1, offvalue = 0)
self.postCheckButton = Checkbutton(self, \
text = "POST", width = 6, variable = self.postVar, \
command = self.__singleSelectCommandPost, onvalue = 1, offvalue = 0)
self.label = Label(self, text = "Use Method:", padx = 3)
self.__boxComponents()
self.initComplete = True
def __boxComponents(self):
self.label.grid(row = 0, column = 0)
self.getCheckButton.grid(row = 0, column = 1)
self.postCheckButton.grid(row = 0, column = 2)
def __singleSelectCommandGet(self):
if self.initComplete == False:
return
self.postCheckButton.deselect()
def __singleSelectCommandPost(self):
if self.initComplete == False:
return
self.getCheckButton.deselect()
def getCurrentMethod(self):
if self.getVar.get() == 1:
return "get"
if self.postVar.get() == 1:
return "post"
return None
示例14: policy
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def policy(self):
policyheader = headersmall(self.frame, text="Policies:")
cei = Checkbutton(self.frame, text="Expected Improvement", variable=self.params["policies"][0], bg=Styles.colours["grey"])
cpi = Checkbutton(self.frame, text="Probability Improvement", variable=self.params["policies"][1], bg=Styles.colours["grey"])
cucb = Checkbutton(self.frame, text="Upper Confidence Bound", variable=self.params["policies"][2], bg=Styles.colours["grey"])
ctho = Checkbutton(self.frame, text="Thompson", variable=self.params["policies"][3], bg=Styles.colours["grey"])
self.isreadyR(cei)
self.isreadyR(cpi)
self.isreadyR(cucb)
self.isreadyR(ctho)
policyheader.grid(row=1, column=0, sticky=W, columnspan=1)
cei.grid(row=2, column=0, pady=0, sticky=W, padx=10, columnspan=1)
cpi.grid(row=3, column=0, pady=0, sticky=W, padx=10, columnspan=1)
cucb.grid(row=4, column=0, pady=0, sticky=W, padx=10, columnspan=1)
ctho.grid(row=5, column=0, pady=0, sticky=W, padx=10, columnspan=1)
示例15: __init__
# 需要导入模块: from Tkinter import Checkbutton [as 别名]
# 或者: from Tkinter.Checkbutton import grid [as 别名]
def __init__(self, master):
column0_padx = 24
row_pady = 36
#Label 1
lbl_testcase_exec = Label(master, text="Test case execution",
wraplength=100, anchor='w', justify='left')
lbl_results_cmp = Label(master, text="Results comparison",
wraplength=100, justify='left')
lbl_tolerance = Label(master, text="Tolerance (5%)", wraplength=100)
testcase_exec = Checkbutton(master)
results_cmp = Checkbutton(master)
tolerance = Entry(master, width=4)
lbl_analysis = Label(master, text="Analysis Library")
analysis_lib = Entry(master, width=30)
lbl_testcase_exec.grid(row=0, column=2, padx=20, pady=12, sticky='w')
lbl_results_cmp.grid(row=0, column=3, pady=12, sticky='w')
lbl_tolerance.grid(row=0, column=4, padx=20, pady=12, sticky='wn')
lbl_analysis.grid(row=1, column=0, sticky='w', padx=column0_padx)
analysis_lib.grid(row=1, column=1, sticky='w')
testcase_exec.grid(row=1, column=2, padx=20, sticky='w')
results_cmp.grid(row=1, column=3, sticky='w')
tolerance.grid(row=1, column=4, padx=20, sticky='w')
#Label 2
lbl_ref_analysis = Label(
master, text="Reference Analysis Libary Version",
wraplength=150, justify='left', pady=row_pady)
ref_analysis_lib = Entry(master, width=30)
lbl_ref_analysis.grid(row=2, column=0, sticky='w', padx=column0_padx)
ref_analysis_lib.grid(row=2, column=1, sticky='w')
# version
lbl_version = Label(master, text="Version under Test")
version = Label(master, text="vA.B.C.D")
lbl_version.grid(row=3, column=0, sticky='w', padx=column0_padx)
version.grid(row=3, column=1, sticky='w')
# test all
lbl_testall = Label(master, text="Test All")
testall = Checkbutton(master)
lbl_testall.grid(row=4, column=0, pady=row_pady, padx=column0_padx,
sticky='w')
testall.grid(row=4, column=1, sticky='w')
# buttons
bottom_frame = Frame(master)
bottom_frame.grid(row=5, column=1, columnspan=3, sticky='w')
btn_start = Button(bottom_frame, text = "Go", width=7)
btn_start.pack(side='left')
btn_commit = Button(bottom_frame, text="Commit", width=7)
btn_commit.pack(side='left', padx=80)
btn_exit = Button(bottom_frame, text="Exit", width=7)
btn_exit.pack(side='left')