当前位置: 首页>>代码示例>>Python>>正文


Python Tkinter.Checkbutton类代码示例

本文整理汇总了Python中Tkinter.Checkbutton的典型用法代码示例。如果您正苦于以下问题:Python Checkbutton类的具体用法?Python Checkbutton怎么用?Python Checkbutton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Checkbutton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, app):
        self.app = app

        Toplevel.__init__(self, app)
        self.title("Reset Usage Counters")
        self.protocol("WM_DELETE_WINDOW", self.doCancel)

        f = Frame(self)
        f.pack()

        self.cbDL = {}
        for d in DLLIST:
            cbv = IntVar()
            t = "%s(%s)" % (DLNAMES[d], self.app.dataLoggers[d].getToNowStr())
            cb = Checkbutton(f, text=t, variable=cbv)
            self.cbDL[d] = cbv
            cb.pack(anchor=W, padx=10)

        f = Frame(self)
        f.pack()

        self.bOK = Button(f, text="OK", width=12, command=self.doOK)
        self.bOK.pack(side=LEFT, padx=2, pady=5)
        self.bCancel = Button(f, text="Cancel", width=12, command=self.doCancel)
        self.bCancel.pack(side=LEFT, padx=2, pady=5)
开发者ID:jbernardis,项目名称:repraphost,代码行数:25,代码来源:datalog.py

示例2: MeasureFrame

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))
开发者ID:speezepearson,项目名称:PyMMT,代码行数:60,代码来源:measureframe.py

示例3: create_other_buttons

    def create_other_buttons(self):
        f = self.make_frame()

        btn = Checkbutton(f, variable=self.recvar,
                text="Recurse down subdirectories")
        btn.pack(side="top", fill="both")
        btn.invoke()
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:7,代码来源:GrepDialog.py

示例4: redraw

 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)
开发者ID:Eyal87,项目名称:repository.eyal,代码行数:34,代码来源:tktasks.py

示例5: PasswordDialog

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)
开发者ID:Halfnhav4,项目名称:selfspy,代码行数:28,代码来源:password_dialog.py

示例6: makeCheckBoxes

	def makeCheckBoxes(self):
		#this creates a 'status' for the check box. So if it is on, it's status
		#is 1. If it is off, then it is 0. The status stores these values 
		self.derivativeStatus = IntVar() 
		self.derivativeToggle = Checkbutton(self.window, 
			                           bg = self.interfaceColor, 
			                           text = 'Derivative (Green)', 
			                           variable = self.derivativeStatus, 
			                           onvalue = 1, offvalue = 0, 
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.functionStatus = IntVar()
		self.functionToggle = Checkbutton(self.window, bg = self.interfaceColor, 
			                         text = 'Function (Yellow)',
			                         variable = self.functionStatus, 
			                         onvalue = 1, offvalue = 0,
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.integralStatus = IntVar()
		self.integralToggle = Checkbutton(self.window, bg = self.interfaceColor, 
			                              text = 'Integral (Red)', 
			                              variable = self.integralStatus, 
			                              onvalue = 1, offvalue = 0, 
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.derivativeToggle.place(x = 450, y = 560)
		self.functionToggle.place(x = 450, y = 590)
		self.integralToggle.place(x = 450, y = 620)
开发者ID:ijm329,项目名称:Numerical_Analysis_Calculator,代码行数:28,代码来源:Numerical_Analysis_Calculator.py

示例7: __init__

    def __init__(self, parent=None, width=800, height=800):
        """ initialisation

        parent : une application
        width,height : dimension de l'oscilloscpe
        """
        Frame.__init__(self)
        self.master.title("Oscilloscope")
        # Modelethreading.Thread(None, affiche, None, (200,), {'nom':'thread a'}) 
        self.time = 0
        self.signal = None
        # # Vues
        # self.menuBar         = MenuBar(parent=self)
        # self.screen          = Screen(parent=self)
        # self.frame = Frame(master=self)
        # # Controleurs
        # self.time_control = TimeBase(parent=self)
        # self.signal_controlX = Generator(parent=self, name="X", color="red")
        # self.signal_controlY = Generator(parent=self, name="Y", color="blue")
        # # Affichage Vues, Controleurs
        # self.menuBar.pack()
        # self.screen.pack()

        # self.signal_controlX.pack(side="left")
        # self.signal_controlY.pack(side="left")
        # self.time_control.pack()

        # Vues
        self.menuBar          = MenuBar(parent=self)
        self.screenT          = Screen(parent=self)
        self.screenXY         = Screen(parent=self)
        # Controleurs
        self.signal_controlX = Generator(parent=self, name="X", color="red")
        self.signal_controlY = Generator(parent=self, name="Y", color="blue")
        self.signal_controlXY = Generator(parent=self, name="XY", color="blue")
        self.time_control = TimeBase(parent=self)
        self.varX  = IntVar()
        self.varY  = IntVar()
        self.varXY = IntVar()
        self.showX = Checkbutton(parent, text="X", variable=self.varX, command=lambda: self.update_show("X"))
        self.showY = Checkbutton(parent, text="Y", variable=self.varY, command=lambda: self.update_show("Y"))
        self.showXY = Checkbutton(parent, text="XY", variable=self.varXY, command=lambda: self.update_show("XY"))
        self.varX.set(1)
        self.varY.set(1)
        self.varXY.set(1)

        # Affichage Vues, Controleurs
        self.menuBar.grid(column=0, row=0)
        self.screenT.grid(column=0,row=1)
        self.screenXY.grid(column=1,row=1)
        self.signal_controlX.grid(column=0, row=2)
        self.signal_controlY.grid(column=0, row=3)
        self.time_control.grid(column=0, row=4)

        self.showX.grid(column=1, row=2)
        self.showY.grid(column=1, row=3)
        self.showXY.grid(column=1, row=4)

        self.configure(width=width, height=height)
开发者ID:Akanoa,项目名称:CAI2014,代码行数:59,代码来源:oscilloscope.py

示例8: GpioSimulator

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})
开发者ID:9and3r,项目名称:mopidy-ttsgpio,代码行数:56,代码来源:gpio_simulator.py

示例9: initUI

 def initUI(self):
     self.parent.title("CheckButton")
     self.pack(fill=BOTH,expand=True)
     self.var = BooleanVar()
     self.var.set(False)
     
     chbt = Checkbutton(self,text="Show Title",
                        variable=self.var,command=self.onClick)
     #chbt.select()
     chbt.place(x=50,y=50)
开发者ID:belargej,项目名称:PythonProjects,代码行数:10,代码来源:CheckButton1.py

示例10: __init__

 def __init__(self, parent=None, picks=[], side=LEFT, anchor=W, default=[]):
     Frame.__init__(self, parent)
     self.vars = []
     for i,pick in enumerate(picks):
         var = IntVar()
         chk = Checkbutton(self, text=pick, variable=var)
         chk.pack(side=side, anchor=anchor, expand=YES)
         if i< len(default):
             var.set(default[i])
         self.vars.append(var)
开发者ID:andelf,项目名称:paopaoyu,代码行数:10,代码来源:utils.py

示例11: dimscheduler

    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)
开发者ID:jakedm,项目名称:projectb,代码行数:10,代码来源:selection.py

示例12: AuthDialog

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)
开发者ID:braams,项目名称:shtoom,代码行数:55,代码来源:popups.py

示例13: initUI

    def initUI(self):
      
        self.parent.title("Checkbutton")

        self.pack(fill=BOTH, expand=1)
        self.var = IntVar()
        
        cb = Checkbutton(self, text="Show title",
            variable=self.var, command=self.onClick)
        cb.select()
        cb.place(x=50, y=50)
开发者ID:alistairwalsh,项目名称:samebright,代码行数:11,代码来源:check_box.py

示例14: addCheckButton

 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)
开发者ID:mgarsteck,项目名称:python,代码行数:11,代码来源:TodoList.py

示例15: __init_grid

    def __init_grid(self):

        # Road list
        self.__roads_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=27, exportselection=0)
        for road in self.__roads:
            self.__roads_list_box.insert('end', road)

        # Nature list
        self.__natures_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=6, width=22, exportselection=0)
        for nature in self.__natures:
            self.__natures_list_box.insert('end', nature)

        # Start with all natures selected
        self.__natures_list_box.select_set(0, END)\

        # Days list
        self.__days_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=8, width=22, exportselection=0)
        for day in ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']:
            self.__days_list_box.insert('end', day)

        # Hours list
        self.__hours_list_box = Listbox(self.__root, selectmode=MULTIPLE, height=24, width=7, exportselection=0)
        for hour in range(24):
            self.__hours_list_box.insert('end', hour)

        # Check button draw overall
        self.__draw_overall_var = IntVar()
        self.__draw_overall_check_box = \
            Checkbutton(self.__root, text = "Draw Overall Curve?",
                        variable = self.__draw_overall_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Check button draw nature
        self.__draw_nature_var = IntVar()
        self.__draw_nature_check_box = \
            Checkbutton(self.__root, text = "Draw Curve Per Nature?",
                        variable = self.__draw_nature_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Check button show data
        self.__show_data_var = IntVar()
        self.__show_data_var.set(1)
        self.__show_data_check_box = \
            Checkbutton(self.__root, text = "Show data?",
                        variable = self.__show_data_var, onvalue = 1,
                        offvalue = 0, height=2, width = 20)

        # Go button
        self.__go_button = Button(self.__root, text='GO', command = lambda: self.__generate_graph())

        # Errors text box
        self.__error_text_box = Text(self.__root, height=28, width=18, fg="red")
        self.__error_text_box.tag_config('justified', justify=CENTER)
开发者ID:ivandiazrios,项目名称:tfl_modelling,代码行数:53,代码来源:graphAnalyzer.py


注:本文中的Tkinter.Checkbutton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。