Python Tkinter.BooleanVar() Examples

The following are 15 code examples of Tkinter.BooleanVar(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Tkinter , or try the search function .
Example #1
Source File: test_variables.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_default(self):
        v = BooleanVar(self.root)
        self.assertEqual(False, v.get()) 
Example #2
Source File: tkmktap.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def setupOptFlags(self):
        self.optFlags = []
        flags = []
        if hasattr(self.options, 'optFlags'):
            flags.extend(self.options.optFlags)

        d = {}
        soFar = {}
        for meth in reflect.prefixedMethodNames(self.options.__class__, 'opt_'):
            full = 'opt_' + meth
            func = getattr(self.options, full)

            if not usage.flagFunction(func) or meth in ('help', 'version'):
                continue
            
            if soFar.has_key(func):
                continue
            soFar[func] = 1
            
            existing = d.setdefault(func, meth)
            if existing != meth:
                if len(existing) < len(meth):
                    d[func] = meth
            
            for (func, name) in d.items():
                flags.append((name, None, func.__doc__))
            
            if len(flags):
                self.optFrame = f = Tkinter.Frame(self)
                for (flag, _, desc) in flags:
                    b = Tkinter.BooleanVar()
                    c = Tkinter.Checkbutton(f, text=desc, variable=b, wraplen=200)
                    c.pack(anchor=Tkinter.W)
                    self.optFlags.append((flag, b))
                f.grid(row=1, column=1) 
Example #3
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_entryconfigure_variable(self):
        m1 = self.create()
        v1 = tkinter.BooleanVar(self.root)
        v2 = tkinter.BooleanVar(self.root)
        m1.add_checkbutton(variable=v1, onvalue=True, offvalue=False,
                           label='Nonsense')
        self.assertEqual(str(m1.entrycget(1, 'variable')), str(v1))
        m1.entryconfigure(1, variable=v2)
        self.assertEqual(str(m1.entrycget(1, 'variable')), str(v2)) 
Example #4
Source File: test_variables.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_get(self):
        v = BooleanVar(self.root, True, "name")
        self.assertAlmostEqual(True, v.get())
        self.root.globalsetvar("name", "0")
        self.assertAlmostEqual(False, v.get()) 
Example #5
Source File: test_variables.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_invalid_value_domain(self):
        v = BooleanVar(self.root, name="name")
        self.root.globalsetvar("name", "value")
        with self.assertRaises(TclError):
            v.get()
        self.root.globalsetvar("name", "1.0")
        with self.assertRaises(TclError):
            v.get() 
Example #6
Source File: SearchEngine.py    From oss-ftp with MIT License 5 votes vote down vote up
def __init__(self, root):
        '''Initialize Variables that save search state.

        The dialogs bind these to the UI elements present in the dialogs.
        '''
        self.root = root  # need for report_error()
        self.patvar = StringVar(root, '')   # search pattern
        self.revar = BooleanVar(root, False)   # regular expression?
        self.casevar = BooleanVar(root, False)   # match case?
        self.wordvar = BooleanVar(root, False)   # match whole word?
        self.wrapvar = BooleanVar(root, True)   # wrap around buffer?
        self.backvar = BooleanVar(root, False)   # search backwards?

    # Access methods 
Example #7
Source File: cheetah_proxy_support.py    From cheetah-gui with GNU General Public License v3.0 5 votes vote down vote up
def set_tk_var():
    global address
    address = StringVar()
    address.set(read_config("Proxy", "Address", "str"))
    global port
    port = IntVar()
    port.set(read_config("Proxy", "Port", "int"))
    global protocol
    protocol = StringVar()
    protocol.set(read_config("Proxy", "Protocol", "str"))
    global username
    username = StringVar()
    username.set(read_config("Proxy", "Username", "str"))
    global password
    password = StringVar()
    password.set(read_config("Proxy", "Password", "str"))
    global proxy_path_var
    proxy_path_var = StringVar()
    proxy_path = read_config("Proxy", "Path", "str")
    if len(proxy_path) == 0:
        proxy_path = path.join(data_dir, 'proxy.txt')
    proxy_path_var.set(proxy_path)
    global proxy_api
    proxy_api = StringVar()
    proxy_api.set(read_config("Proxy", "API", "str"))
    global test_address
    test_address = StringVar()
    test_address.set(read_config("Proxy", "TestAddress", "str"))
    global use_proxy
    use_proxy = BooleanVar()
    use_proxy.set(read_config("Proxy", "Proxy", "boolean")) 
Example #8
Source File: cheetah_config_support.py    From cheetah-gui with GNU General Public License v3.0 5 votes vote down vote up
def set_tk_var():
    global method
    method = StringVar()
    method.set(read_config("Config", "Method", "str"))
    global server
    server = StringVar()
    server.set(read_config("Config", "Server", "str"))
    global shelltype
    shelltype = StringVar()
    shelltype.set(read_config("Config", "ShellType", "str"))
    global parameter
    parameter = StringVar()
    parameter.set(read_config("Config", "Parameter", "str"))
    global thread_num
    thread_num = IntVar()
    thread_num.set(read_config("Config", "ThreadNumber", "int"))
    global req_delay
    req_delay = DoubleVar()
    req_delay.set(read_config("Config", "RequestDelay", "float"))
    global time_out
    time_out = DoubleVar()
    time_out.set(read_config("Config", "RequestTimeout", "float"))
    global random_ua
    random_ua = BooleanVar()
    random_ua.set(read_config("Config", "RandomUserAgent", "boolean"))
    global con_close
    con_close = BooleanVar()
    con_close.set(read_config("Config", "ConnectionClose", "boolean"))
    global keep_alive
    keep_alive = BooleanVar()
    keep_alive.set(read_config("Config", "KeepAlive0", "boolean"))
    global custom_hdr
    custom_hdr = BooleanVar()
    custom_hdr.set(read_config("Config", "CustomRequestHeader", "boolean"))
    global custom_hdr_data
    custom_hdr_data = StringVar()
    custom_hdr_data.set(read_config("Config", "CustomRequestHeaderData", "str")) 
Example #9
Source File: gui.py    From stochopy with MIT License 5 votes vote down vote up
def define_variables(self):
        self.solver_name = tk.StringVar(self.master)
        self.function = tk.StringVar(self.master)
        self.popsize = tk.IntVar(self.master)
        self.max_iter = tk.IntVar(self.master)
        self.interval = tk.IntVar(self.master)
        self.mcmc_stepsize_x1 = tk.DoubleVar(self.master)
        self.mcmc_stepsize_x2 = tk.DoubleVar(self.master)
        self.hmc_stepsize = tk.DoubleVar(self.master)
        self.log_mcmc_stepsize_x1 = tk.DoubleVar(self.master)
        self.log_mcmc_stepsize_x2 = tk.DoubleVar(self.master)
        self.log_hmc_stepsize = tk.DoubleVar(self.master)
        self.n_leap = tk.IntVar(self.master)
        self.w = tk.DoubleVar(self.master)
        self.c1 = tk.DoubleVar(self.master)
        self.c2 = tk.DoubleVar(self.master)
        self.gamma = tk.DoubleVar(self.master)
        self.CR = tk.DoubleVar(self.master)
        self.F = tk.DoubleVar(self.master)
        self.strategy = tk.StringVar(self.master)
        self.sigma = tk.DoubleVar(self.master)
        self.mu_perc = tk.DoubleVar(self.master)
        self.seed = tk.IntVar(self.master)
        self.fix_seed = tk.BooleanVar(self.master)
        self.constrain = tk.BooleanVar(self.master)
        self.sync = tk.BooleanVar(self.master) 
Example #10
Source File: dialog_elements.py    From Enrich2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, text, cfg, key):
        self.checkbox = None
        self.enabled = True

        self.value = tk.BooleanVar()
        self.text = text
        self.cfg = cfg
        self.key = key
        try:
            if self.cfg[self.key] not in (True, False):
                self.value.set(False)
            else:
                self.value.set(self.cfg[self.key])
        except KeyError:
            self.value.set(False)  # default to False 
Example #11
Source File: configurator.py    From Enrich2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, version):
        tk.Tk.__init__(self)
        self.title("Enrich 2 Configurator v{}".format(version))

        self.treeview = None
        self.treeview_popup_target_id = None

        self.cfg_file_name = tk.StringVar()

        self.element_dict = dict()
        self.root_element = None

        # analysis options
        self.scoring_method = tk.StringVar()
        self.logr_method = tk.StringVar()
        self.force_recalculate = tk.BooleanVar()
        self.component_outliers = tk.BooleanVar()
        self.plots_requested = tk.BooleanVar()
        self.tsv_requested = tk.BooleanVar()

        # allow resizing
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        # create UI elements
        self.create_main_frame()
        self.create_menubar()
        self.create_treeview_context_menu() 
Example #12
Source File: tkgui.py    From ATX with Apache License 2.0 5 votes vote down vote up
def __init__(self, title='AirtestX Basic GUI', ratio=0.5, device=None):
        self._device = device
        self._root = tk.Tk()
        self._root.title(title)
        self._queue = Queue()

        self._refresh_text = tk.StringVar()
        self._refresh_text.set("Refresh")
        self._gencode_text = tk.StringVar()
        self._genfile_name = tk.StringVar()
        self._fileext_text = tk.StringVar()
        self._auto_refresh_var = tk.BooleanVar()
        self._uiauto_detect_var = tk.BooleanVar()
        self._attachfile_text = tk.StringVar()
        self._running = False # if background is running

        self._init_items()
        self._init_thread()
        self._init_refresh()

        self._lastx = 0
        self._lasty = 0
        self._bounds = None # crop area
        self._center = (0, 0) # center point
        self._offset = (0, 0) # offset to image center
        self._poffset = (0, 0)
        self._size = (90, 90)
        self._moved = False # click or click and move
        self._color = 'red' # draw color
        self._tkimage = None # keep reference
        self._image = None
        self._ratio = ratio
        self._uinodes = [] # ui dump
        self._selected_node = None
        self._hovered_node = None
        self._save_parent_dir = None

        self._init_vars() 
Example #13
Source File: SearchEngine.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, root):
        '''Initialize Variables that save search state.

        The dialogs bind these to the UI elements present in the dialogs.
        '''
        self.root = root  # need for report_error()
        self.patvar = StringVar(root, '')   # search pattern
        self.revar = BooleanVar(root, False)   # regular expression?
        self.casevar = BooleanVar(root, False)   # match case?
        self.wordvar = BooleanVar(root, False)   # match whole word?
        self.wrapvar = BooleanVar(root, True)   # wrap around buffer?
        self.backvar = BooleanVar(root, False)   # search backwards?

    # Access methods 
Example #14
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def test_entryconfigure_variable(self):
        m1 = self.create()
        v1 = tkinter.BooleanVar(self.root)
        v2 = tkinter.BooleanVar(self.root)
        m1.add_checkbutton(variable=v1, onvalue=True, offvalue=False,
                           label='Nonsense')
        self.assertEqual(str(m1.entrycget(1, 'variable')), str(v1))
        m1.entryconfigure(1, variable=v2)
        self.assertEqual(str(m1.entrycget(1, 'variable')), str(v2)) 
Example #15
Source File: chooser.py    From crazyswarm with MIT License 5 votes vote down vote up
def __init__(self, parent, name):
			Tkinter.Frame.__init__(self, parent)
			self.checked = Tkinter.BooleanVar()
			checkbox = Tkinter.Checkbutton(self, variable=self.checked, command=save,
				padx=0, pady=0)
			checkbox.grid(row=0, column=0, sticky='E')
			nameLabel = Tkinter.Label(self, text=name, padx=0, pady=0)
			nameLabel.grid(row=0, column=1, sticky='W')
			self.batteryLabel = Tkinter.Label(self, text="", fg="#999999", padx=0, pady=0)
			self.batteryLabel.grid(row=1, column=0, columnspan=2, sticky='E')
			self.versionLabel = Tkinter.Label(self, text="", fg="#999999", padx=0, pady=0)
			self.versionLabel.grid(row=2, column=0, columnspan=2, sticky='E')

	# construct all the checkboxes