Python tkinter.ttk 模块,Checkbutton() 实例源码

我们从Python开源项目中,提取了以下40个代码示例,用于说明如何使用tkinter.ttk.Checkbutton()

项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, expanded_text="Collapse <<", collapsed_text="Expand >>", *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self._expanded_text = expanded_text
        self._collapsed_text = collapsed_text

        self.columnconfigure(1, weight=1)

        self._variable = tk.IntVar()
        self._button = ttk.Checkbutton(self, variable=self._variable, command=self._activate, style="TButton")
        self._button.grid(row=0, column=0)

        self._separator = ttk.Separator(self, orient="horizontal")
        self._separator.grid(row=0, column=1, sticky="we")

        self.frame = ttk.Frame(self)

        self._activate()
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        cbtn = ttk.Checkbutton(self.root, command=cb_test)
        # the variable automatically created by ttk.Checkbutton is actually
        # undefined till we invoke the Checkbutton
        self.assertEqual(cbtn.state(), ('alternate', ))
        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
            cbtn['variable'])

        res = cbtn.invoke()
        self.assertEqual(res, "cb test called")
        self.assertEqual(cbtn['onvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
        self.assertTrue(success)

        cbtn['command'] = ''
        res = cbtn.invoke()
        self.assertFalse(str(res))
        self.assertLessEqual(len(success), 1)
        self.assertEqual(cbtn['offvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        cbtn = ttk.Checkbutton(self.root, command=cb_test)
        # the variable automatically created by ttk.Checkbutton is actually
        # undefined till we invoke the Checkbutton
        self.assertEqual(cbtn.state(), ('alternate', ))
        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
            cbtn['variable'])

        res = cbtn.invoke()
        self.assertEqual(res, "cb test called")
        self.assertEqual(cbtn['onvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
        self.assertTrue(success)

        cbtn['command'] = ''
        res = cbtn.invoke()
        self.assertFalse(str(res))
        self.assertLessEqual(len(success), 1)
        self.assertEqual(cbtn['offvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, on_text="Active", off_text="Inactive", default_state=False, state="enabled", *args):
        ttk.LabelFrame.__init__(self, parent, labelanchor="n", *args)
        self.parent = parent
        self._on_text = on_text
        self._off_text = off_text
        self._default_state = default_state
        self._state = state

        self._fill = tk.Frame(self, height=5)

        self._variable = tk.IntVar()
        self._variable.set(default_state)

        self._button = ttk.Checkbutton(self, width=11, state=self._state, variable=self._variable, command=self._activate, style="TButton")
        self.configure(labelwidget=self._button)

        self.frame = ttk.Frame(self)

        self._activate()
项目:skan    作者:jni    | 项目源码 | 文件源码
def create_parameters_frame(self, parent):
        parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        parameters.grid(sticky='nsew')

        heading = ttk.Label(parameters, text='Analysis parameters')
        heading.grid(column=0, row=0, sticky='n')

        for i, param in enumerate(self.parameters, start=1):
            param_label = ttk.Label(parameters, text=param._name)
            param_label.grid(row=i, column=0, sticky='nsew')
            if type(param) == tk.BooleanVar:
                param_entry = ttk.Checkbutton(parameters, variable=param)
            elif hasattr(param, '_choices'):
                param_entry = ttk.OptionMenu(parameters, param, param.get(),
                                             *param._choices.keys())
            else:
                param_entry = ttk.Entry(parameters, textvariable=param)
            param_entry.grid(row=i, column=1, sticky='nsew')
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        cbtn = ttk.Checkbutton(command=cb_test)
        # the variable automatically created by ttk.Checkbutton is actually
        # undefined till we invoke the Checkbutton
        self.assertEqual(cbtn.state(), ('alternate', ))
        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
            cbtn['variable'])

        res = cbtn.invoke()
        self.assertEqual(res, "cb test called")
        self.assertEqual(cbtn['onvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
        self.assertTrue(success)

        cbtn['command'] = ''
        res = cbtn.invoke()
        self.assertEqual(res, '')
        self.assertFalse(len(success) > 1)
        self.assertEqual(cbtn['offvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
项目:Colony    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, option, **kwargs):
        ttk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent
        self.option = option

        # TODO: Add more options.

        ttk.Checkbutton(self, text="Debugging Mode", variable=self.option.variable_debug).grid(row=0, column=0, sticky="we")
        ttk.Checkbutton(self, text="Scrollbars", variable=self.option.variable_scrollbars).grid(row=1, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid", variable=self.option.variable_grid).grid(row=2, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid Highlight", variable=self.option.variable_grid_highlight).grid(row=3, column=0, sticky="we")

        frame_colour = ttk.Frame(self)
        ttk.Label(frame_colour, text="Highlight Colour").grid(row=0, column=0)
        ttk.Combobox(frame_colour, textvariable=self.option.variable_highlight_colour, values=["white", "red", "blue", "yellow", "green", "purple", "orange", "pink"], state="readonly", width=7).grid(row=0, column=1)
        frame_colour.grid(row=4, column=0, sticky="we")

        ttk.Checkbutton(self, text="Extra Speed Arrows", variable=self.option.variable_extra_speed_arrows).grid(row=5, column=0, sticky="we")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        cbtn = ttk.Checkbutton(self.root, command=cb_test)
        # the variable automatically created by ttk.Checkbutton is actually
        # undefined till we invoke the Checkbutton
        self.assertEqual(cbtn.state(), ('alternate', ))
        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
            cbtn['variable'])

        res = cbtn.invoke()
        self.assertEqual(res, "cb test called")
        self.assertEqual(cbtn['onvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
        self.assertTrue(success)

        cbtn['command'] = ''
        res = cbtn.invoke()
        self.assertFalse(str(res))
        self.assertLessEqual(len(success), 1)
        self.assertEqual(cbtn['offvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        cbtn = ttk.Checkbutton(self.root, command=cb_test)
        # the variable automatically created by ttk.Checkbutton is actually
        # undefined till we invoke the Checkbutton
        self.assertEqual(cbtn.state(), ('alternate', ))
        self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
            cbtn['variable'])

        res = cbtn.invoke()
        self.assertEqual(res, "cb test called")
        self.assertEqual(cbtn['onvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
        self.assertTrue(success)

        cbtn['command'] = ''
        res = cbtn.invoke()
        self.assertFalse(str(res))
        self.assertLessEqual(len(success), 1)
        self.assertEqual(cbtn['offvalue'],
            cbtn.tk.globalgetvar(cbtn['variable']))
项目:Spectroscope    作者:magin67    | 项目源码 | 文件源码
def SetPlotWidgets(self, rowControl):
        ## ??? ???????
        def SetPlotType(val):
            self.shSpectr.PlotType = val
            self.shSpectr.ShowSp()

        def ChkShowTitle():
            self.shSpectr.ShowTitle = showTitle.get()
            self.shSpectr.ShowSp()

        rowControl = self.AddLabel(rowControl, "Plot type", colsp=1)

        vPlotTypes = SD.ShowSpectr.PlotTypes() #self.shSpectr
        sPlotType = tk.StringVar(self.frControl)
        self.omPlotType = ttk.OptionMenu(self.frControl, sPlotType, self.shSpectr.PlotType, *vPlotTypes, command=SetPlotType)  
        PlaceWidget(self.omPlotType, rowControl, col=1, stick='wn') 

        showTitle = tk.BooleanVar()
        showTitle.set(self.shSpectr.ShowTitle)
        self.chkshowTitle = ttk.Checkbutton(self.frControl, variable=showTitle, text="Titles", onvalue=True, offvalue=False, command=ChkShowTitle)
        rowControl = PlaceWidget(self.chkshowTitle, rowControl, col=1, stick='e') 

        return rowControl
        #return self.AddLabel(rowControl)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Checkbutton(self.root, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Checkbutton(self.root, **kwargs)
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def add_checkbutton(self, text="", image="", variable=None, command=None, side="left"):
        """Adds a CheckButton to the Toolbar."""
        widget = ttk.Checkbutton(self, text=text, image=image, variable=variable, command=command, style="Toolbutton")
        widget.pack(side=side)

        return widget
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, text_on="On", text_off="Off", *args):
        ttk.Checkbutton.__init__(self, parent, style="TButton", *args)
        self.parent = parent
        self._text_on = text_on
        self._text_off = text_off

        self._variable = tk.IntVar()
        self.configure(variable=self._variable, command=self._activate)

        self._activate()
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, lock_text="Lock", lock_image="", unlock_text="Unlock", unlock_image="", *args):
        ttk.Checkbutton.__init__(self, parent, compound="left", command=self._activate, style="TButton", *args)
        self.parent = parent
        self._lock_text = lock_text
        self._unlock_text = unlock_text

        self._lock_image = tk.PhotoImage(file=lock_image)
        self._unlock_image = tk.PhotoImage(file=unlock_image)

        self._variable = tk.IntVar()
        self._variable.set(True)

        self.configure(variable=self._variable)

        self._activate()
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def frame1_sync(self):
        if not self.frame1.first_run:
            self.frame1.sync.forget()
        self.frame1.sync = ttk.Frame(self.frame1, borderwidth = 0)
        self.frame1.sync.place(width = 170, height = 25, relx = 0.35, y = 55, anchor = "nw")
        if self.solver_name.get() in [ "CPSO", "PSO", "DE" ]:
            # sync
            sync_button = ttk.Checkbutton(self.frame1.sync, text = "Synchronize",
                                          variable = self.sync, takefocus = False)

            # Layout
            sync_button.place(relx = 0, x =0, y = 0, anchor = "nw")
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def init_widgets(self):
        # file selector
        self.btn_file_select=Button(self, text="Select file",command=self.on_select)
        self.btn_file_select.grid(column=0, row=0, columnspan=2)
        # filename
        self.filename, self.e_filename, self.l_filename = make_entry(self,"File name: ", 1)

        # delimiter
        self.delimiter, self.e_delimiter, self.l_delimiter = make_entry(self,"Delimiter: ", 2)

        # has_header
        self.l_has_header = ttk.Label(self, text="Has header: ")
        self.l_has_header.grid(column=0, row=3, sticky=W)
        self.has_header = BooleanVar()
        self.e_has_header = ttk.Checkbutton(self, variable=self.has_header)
        self.e_has_header.grid(column=1, row=3, sticky=W)

        # csv_dialect
        self.csv_dialect, self.e_csv_dialect, self.l_csv_dialect = make_entry(self,"CSV dialect: ", 4)

        # quoting
        self.quoting, self.e_quoting, self.l_quoting = make_entry(self, "Quoting: ", 5)

        # escapechar
        self.escapechar, self.e_escapechar, self.l_escapechar = make_entry(self, "Escape character: ", 6)

        # lineterminator
        self.lineterminator, self.e_lineterminator, self.l_lineterminator = make_entry(self, "Line terminator: ", 7)

        # quotechar
        self.quotechar, self.e_quotechar, self.l_quotechar = make_entry(self, "Quote character: ", 8)

        # skipinitialspace
        self.skipinitialspace, self.e_skipinitialspace, self.l_skipinitialspace = make_entry(self, "Skip initial space: ", 9)
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def init_widgets(self):

        """Init all widgets"""

        # Source reference
        self.cb_source_ref = ttk.Combobox(self, textvariable=self.src_reference, state='normal')
        self.cb_source_ref['values'] = self.get_source_references()
        self.cb_source_ref.pack(side=LEFT, fill=X, expand=1)


        # Data type label
        self.l_data_type = ttk.Label(self, textvariable=self.src_datatype, width=8)
        self.src_datatype.set("Not set")

        self.l_data_type.pack(side=LEFT)

        # Dest reference
        self.cb_dest_ref = ttk.Combobox(self, textvariable=self.dest_reference, state='normal')
        self.cb_dest_ref['values'] = self.get_destination_references()
        self.cb_dest_ref.pack(side=RIGHT, fill=X, expand=1)

        # Is key field
        self.cb_is_key = ttk.Checkbutton(self, variable=self.is_key)
        self.cb_is_key.pack(side=RIGHT)

        # Current data
        self.l_data = ttk.Label(self, textvariable=self.curr_data)
        self.curr_data.set("No data")
        self.l_data.pack(side=RIGHT, fill=X, padx=5)
项目:qal    作者:OptimalBPM    | 项目源码 | 文件源码
def init_widgets(self):
        # file selector
        self.btn_file_select = Button(self, text="Select file", command=self.on_select)
        self.btn_file_select.grid(column=0, row=0, columnspan=2)

        # filename
        self.filename, self.e_filename, self.l_filename = make_entry(self, "File name: ", 1)


        # delimiter
        self.delimiter, self.e_delimiter, self.l_delimiter = make_entry(self, "Delimiter: ", 2)

        # has_header
        self.l_has_header = ttk.Label(self, text="Has header: ")
        self.l_has_header.grid(column=0, row=3, sticky=W)
        self.has_header = BooleanVar()
        self.e_has_header = ttk.Checkbutton(self, variable=self.has_header)
        self.e_has_header.grid(column=1, row=3, sticky=W)

        # sheet_name
        self.sheet_name, self.e_sheet_name, self.l_sheet_name = make_entry(self, "Sheet name: ", 4)

        # x_offset
        self.x_offset, self.e_x_offset, self.l_x_offset = make_entry(self, "X offset: ", 5)


        # y_offset
        self.y_offset, self.e_y_offset, self.l_y_offset = make_entry(self, "Y offset: ", 6)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Checkbutton(self.root, **kwargs)
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_tk_checkbutton(self, index: int or str="end", *args, **kwargs):
        """Insert a tk.Checkbutton into the game."""
        widget = tk.Checkbutton(self.text, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_checkbutton(self, command=None, offvalue: int=0, onvalue: int=1, variable: tk.BooleanVar=None, index: int or str="end", *args, **kwargs):
        """Insert a ttk.Checkbutton into the game."""
        widget = ttk.Checkbutton(self.text, command=command, offvalue=offvalue, onvalue=onvalue, variable=variable, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def add_frame(self, triangle_key):
        """Add a ``ttk.Frame`` to the dialog and return it.

        The frame will contain a label that displays a |triangle| when
        the value of the variable from :meth:`get_var` is invalid. The
        triangle label is packed with ``side='right'``.

        For example, :meth:`add_checkbutton` works roughly like this::

            frame = section.add_frame(key)
            var = section.get_var(key, tkinter.BooleanVar)
            ttk.Checkbutton(frame, text=text, variable=var).pack(side='left')
        """
        frame = ttk.Frame(self.content_frame)
        frame.pack(fill='x')

        if triangle_key is not None:
            errorvar = self._infos[triangle_key].errorvar
            triangle_label = ttk.Label(frame)
            triangle_label.pack(side='right')

            def on_errorvar_changed(*junk):
                if errorvar.get():
                    triangle_label['image'] = 'img_triangle'
                else:
                    triangle_label['image'] = self._get_fake_triangle(frame)

            errorvar.trace('w', on_errorvar_changed)
            on_errorvar_changed()

        return frame
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def add_checkbutton(self, key, text):
        """Add a ``ttk.Checkbutton`` that sets an option to a bool."""
        var = self.get_var(key, tkinter.BooleanVar)
        ttk.Checkbutton(self.add_frame(key), text=text,
                        variable=var).pack(side='left')
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def __init__(self, parent, textwidget, **kwargs):
        super().__init__(parent, **kwargs)

        self._last_pattern = None
        self._matches = None

        self.grid_columnconfigure(1, weight=1)
        self._textwidget = textwidget

        entrygrid = ttk.Frame(self)
        entrygrid.grid(row=0, column=0)
        self._find_entry = self._add_entry(entrygrid, 0, "Find:", self.find)
        self._replace_entry = self._add_entry(entrygrid, 1, "Replace with:")

        buttonframe = ttk.Frame(self)
        buttonframe.grid(row=1, column=0, sticky='we')
        buttons = [
            ("Find", self.find),
            ("Replace", self.replace),
            ("Replace and find", self.replace_and_find),
            ("Replace all", self.replace_all),
        ]
        for text, command in buttons:
            button = ttk.Button(buttonframe, text=text, command=command)
            button.pack(side='left', fill='x', expand=True)

        self._full_words_var = tkinter.BooleanVar()
        checkbox = ttk.Checkbutton(self, text="Full words only",
                                   variable=self._full_words_var)
        checkbox.grid(row=0, column=1, sticky='nw')

        self._statuslabel = ttk.Label(self)
        self._statuslabel.grid(row=1, column=1, columnspan=2, sticky='nswe')

        closebutton = ttk.Label(self, image='img_closebutton')
        closebutton.grid(row=0, column=2, sticky='ne')
        closebutton.bind('<Button-1>', lambda event: self.pack_forget())
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Checkbutton(self.root, **kwargs)
项目:LadderiLogical    作者:mikadam    | 项目源码 | 文件源码
def __init__(self, *args):

        super().__init__(*args)


        self.dir_selector=DirectionSelector(self.frame,self.conector_checks)
        self.dir_selector.pack()

        for check in self.conector_checks:
            check.trace("w",self.dir_selector.variable_changed)

        self.invert=tk.IntVar()
        self.invert_cheack=ttk.Checkbutton(master=self.frame,text="Invert",variable=self.invert,onvalue='0',offvalue='1')

        self.invert.set(1)
        self.invert_cheack.pack()

        vcmd = (self.root.register(self.validate), '%S','%d')

        self.subscribe_name=ttk.Entry(master=self.frame,width=10,validate="key",validatecommand=vcmd)
        self.subscribe_name.pack()



        self.top_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y)*self.board.tile_size,fill="",outline="")
        self.bottom_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y+1)*self.board.tile_size,fill="",outline="")
        self.left_box=self.board.canvas.create_rectangle((self.x+0.7)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,fill="",outline="")
        self.right_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+1)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,fill="",outline="")

        self.gen_box=self.board.canvas.create_rectangle((self.x+0.2)*self.board.tile_size,(self.y+0.2)*self.board.tile_size,(self.x+0.8)*self.board.tile_size,(self.y+0.8)*self.board.tile_size,fill="#2e2e2e",outline="#EEEEEE") 
        self.on_box=self.board.canvas.create_rectangle((self.x+0.4)*self.board.tile_size,(self.y+0.4)*self.board.tile_size,(self.x+0.6)*self.board.tile_size,(self.y+0.6)*self.board.tile_size,fill="",outline="")
        self.missing_key=self.board.canvas.create_text((self.x+0.5)*self.board.tile_size,(self.y+0.5)*self.board.tile_size,text="?",fill="")

        self.graphic_conectors=[self.top_box,self.right_box,self.bottom_box,self.left_box]
        self.graphics=[self.on_box,self.gen_box,self.top_box,self.bottom_box,self.left_box,self.right_box,self.missing_key]
项目:LadderiLogical    作者:mikadam    | 项目源码 | 文件源码
def __init__(self, *args):

        super().__init__(*args)


        self.conector_checks[0].set(0)
        self.conector_checks[1].set(1)
        self.conector_checks[2].set(1)
        self.conector_checks[3].set(2)

        vcmd = (self.root.register(self.validate), '%P', '%s','%S', '%d')

        self.count_upto=ttk.Entry(master=self.frame,width=10,validate="key",validatecommand=vcmd)
        self.count_upto.pack()
        self.count_upto.insert(0,"1")

        self.upto=1
        self.counter=0
        self.edge=0

        self.auto_reset=tk.IntVar()
        self.auto_reset_cheack=ttk.Checkbutton(master=self.frame,text="Auto Reset",variable=self.auto_reset,onvalue='1',offvalue='0')

        self.auto_reset.set(1)
        self.auto_reset_cheack.pack()

        self.top_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y)*self.board.tile_size,fill="",outline="")
        self.bottom_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y+1)*self.board.tile_size,fill="#FF0000",outline="")
        self.left_box=self.board.canvas.create_rectangle((self.x+0.7)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,fill="#FF0000",outline="")
        self.right_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+1)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,fill="#FF0000",outline="")

        self.counter_box=self.board.canvas.create_rectangle((self.x+0.2)*self.board.tile_size,(self.y+0.2)*self.board.tile_size,(self.x+0.8)*self.board.tile_size,(self.y+0.8)*self.board.tile_size,fill="#DDDDDD",outline="#EEEEEE") 

        self.text_box=self.board.canvas.create_text((self.x+0.5)*self.board.tile_size,(self.y+0.5)*self.board.tile_size,text="00+")



        self.graphic_conectors=[self.top_box,self.right_box,self.bottom_box,self.left_box]

        self.graphics=[self.counter_box,self.top_box,self.bottom_box,self.left_box,self.right_box,self.text_box]
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def create_zip_button(self, gs):
        """Expand frame to reveal options when Create ZIP File is selected."""
        if self.zip_button_var.get() == 1:
            self.split_button_var = tk.IntVar()
            self.split_button = ttk.Checkbutton(self.zip_frame,
                                                text='Split ZIP File',
                                                variable=self.split_button_var)
            self.split_button.grid(row=2, column=0, sticky='w')
            self.split_button.grid_configure(padx=2, pady=5)
            self.split_entry_var = tk.IntVar()
            self.split_entry = ttk.Entry(self.zip_frame,
                                         width=3,
                                         justify='right',
                                         textvariable=self.split_entry_var)
            self.split_entry.grid(row=2, column=1, sticky='e')
            self.split_entry.grid_configure(pady=5)
            self.split_entry_var.set('2')
            self.split_combo = ttk.Combobox(self.zip_frame,
                                            width=4,
                                            justify='left',
                                            values='MB GB')
            self.split_combo.current(1)
            self.split_combo.grid(row=2, column=2, sticky='w')
            self.split_combo.grid_configure(pady=5)
        else:
            self.split_button.destroy()
            self.split_entry.destroy()
            self.split_combo.destroy()
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def create_zip_button(self, gs):
        """Expand frame to reveal options when Create ZIP File is selected."""
        if self.zip_button_var.get() == 1:
            self.split_button_var = tk.IntVar()
            self.split_button = ttk.Checkbutton(self.zip_frame,
                                                text='Split ZIP File',
                                                variable=self.split_button_var)
            self.split_button.grid(row=2, column=0, sticky='w')
            self.split_button.grid_configure(padx=2, pady=5)
            self.split_entry_var = tk.IntVar()
            self.split_entry = ttk.Entry(self.zip_frame,
                                         width=3,
                                         justify='right',
                                         textvariable=self.split_entry_var)
            self.split_entry.grid(row=2, column=1, sticky='e')
            self.split_entry.grid_configure(pady=5)
            self.split_entry_var.set('2')
            self.split_combo = ttk.Combobox(self.zip_frame,
                                            width=4,
                                            justify='left',
                                            values='MB GB')
            self.split_combo.current(1)
            self.split_combo.grid(row=2, column=2, sticky='w')
            self.split_combo.grid_configure(pady=5)
        else:
            self.split_button.destroy()
            self.split_entry.destroy()
            self.split_combo.destroy()
项目:cpsc415    作者:WheezePuppet    | 项目源码 | 文件源码
def _setup_graphics(self):
        self.root_window = tk.Tk()
        self.root_window.grid()
        self.root_window.title(self.title)
        self.root_window.config(background='white')

        self.progress = tk.StringVar() ; self.progress.set('')
        ttk.Label(self.root_window,background='white',foreground='red',
            anchor='center', textvariable=self.progress).grid(
            row=2,column=0,columnspan=4)

        self.score = tk.StringVar() ; self.score.set('')
        ttk.Label(self.root_window,background='white',foreground='blue',
            anchor='center', textvariable=self.score).grid(
            row=2,column=4,columnspan=1)

        ttk.Label(self.root_window,text='# iterations:',
            background='white').grid(row=1,column=0, sticky='e')

        num_iter_var = tk.IntVar() ; num_iter_var.set(200)

        ttk.Entry(self.root_window,textvariable=num_iter_var,width=5).grid(
            row=1,column=1,sticky='w')
        ttk.Button(self.root_window,text='Go',
            command=lambda : self.run_until(num_iter_var.get())).grid(
            row=1,column=2, sticky='W')
        self.continuous = tk.BooleanVar()
        ttk.Checkbutton(self.root_window,text='Continuous',
            variable=self.continuous).grid(row=1,column=3)

        ttk.Label(self.root_window,text='delay (ms):',
            background='white').grid(row=1,column=4, sticky='e')
        self.delay = tk.StringVar()
        tk.Spinbox(self.root_window,values=[10,50,100,500,1000],width=4,
            textvariable=self.delay).grid(row=1,column=5)
        self.delay.set(100)

        self.root_window.bind('<Return>',
            lambda x: self.run_until(num_iter_var.get()))
        self.canvas = tk.Canvas(self.root_window,
            width=self.CANVAS_WIDTH, height=self.CANVAS_HEIGHT, bg='black')

        self.canvas.grid(row=0,column=0,columnspan=6,sticky='we')
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, **kwargs):
        ttk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent

        # TODO: Change this to a pk.Toolbar.

        image = load_images.LoadImages()
        self.image_chessboard = image.image_chessboard
        self.image_grid = image.image_grid
        self.image_zoom_in = image.image_zoom_in
        self.image_zoom_out = image.image_zoom_out

        self.variable_chessboard = tk.BooleanVar()
        self.variable_chessboard.set(True)
        self.widget_check_chessboard = ttk.Checkbutton(self, text="Chessboard", image=self.image_chessboard,
                                                       variable=self.variable_chessboard,
                                                       command=self.parent.draw_background, style="Toolbutton")
        self.widget_check_chessboard.grid(row=0, column=0)

        self.variable_grid = tk.BooleanVar()
        self.variable_grid.set(False)
        self.widget_check_grid = ttk.Checkbutton(self, text="Grid", image=self.image_grid, variable=self.variable_grid,
                                                 command=self.parent.draw_background, style="Toolbutton")
        self.widget_check_grid.grid(row=0, column=1)

        ttk.Separator(self, orient="vertical").grid(row=0, column=2, sticky="ns")

        self.widget_button_zoom_in = ttk.Button(self, text="Zoom In", image=self.image_zoom_in,
                                                command=self.parent.zoom_in, style="Toolbutton")
        self.widget_button_zoom_in.grid(row=0, column=3)

        self.widget_button_zoom_out = ttk.Button(self, text="Zoom Out", image=self.image_zoom_out,
                                                 command=self.parent.zoom_out, style="Toolbutton")
        self.widget_button_zoom_out.grid(row=0, column=4)
        idlelib.ToolTip.ToolTip(self.widget_button_zoom_out, "Zoom the image out")

        ttk.Separator(self, orient="vertical").grid(row=0, column=5, sticky="ns")

        self.variable_tile = tk.BooleanVar()
        self.widget_button_tile = ttk.Checkbutton(self, text="Tile", variable=self.variable_tile,
                                                  command=self.parent.check_tile_buttons, style="Toolbutton")
        self.widget_button_tile.grid(row=0, column=6)

        self.variable_tile_sides = tk.BooleanVar()
        self.widget_button_tile_sides = ttk.Checkbutton(self, text="Tile Side", variable=self.variable_tile_sides, command=self.parent.draw_tiles, style="Toolbutton")
        self.widget_button_tile_sides.grid(row=0, column=7)

        self.variable_tile_corners = tk.BooleanVar()
        self.widget_button_tile_corners = ttk.Checkbutton(self, text="Tile Corners", variable=self.variable_tile_corners, command=self.parent.draw_tiles, style="Toolbutton")
        self.widget_button_tile_corners.grid(row=0, column=8)
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):
        ttk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        self.is_text_valid = False
        self.search_entry = SearchEntry(self)
        self.search_entry.pack(side="left")

        ttk.Separator(self, orient="vertical").pack(side="left", fill="y", padx=3, pady=1)

        self.button_previous = ttk.Button(self, text="Previous", image=self.parent.master.image_find_previous,
                                          command=lambda: self.parent.master.search(previous=True,
                                                                                    match_case=not self.variable_match_case.get(),
                                                                                    exact=not self.variable_exact.get(),
                                                                                    regular_expression=not self.variable_regular_expression.get()))
        self.button_previous.pack(side="left")

        self.button_next = ttk.Button(self, text="Next", image=self.parent.master.image_find_next,
                                      command=lambda: self.parent.master.search(next_=True,
                                                                                match_case=not self.variable_match_case.get(),
                                                                                exact=not self.variable_exact.get(),
                                                                                regular_expression=not self.variable_regular_expression.get()))
        self.button_next.pack(side="left")

        self.button_find_all = ttk.Button(self, text="Find All", command=self.parent.master.search_all)
        self.button_find_all.pack(side="left")

        ttk.Separator(self, orient="vertical").pack(side="left", fill="y", padx=3, pady=1)

        self.variable_match_case = tk.BooleanVar(value=0)
        self.checkbutton_match_case = ttk.Checkbutton(self, text="Match Case", variable=self.variable_match_case)
        self.checkbutton_match_case.pack(side="left")

        self.variable_exact = tk.BooleanVar(value=0)
        self.checkbutton_exact = ttk.Checkbutton(self, text="Exact", variable=self.variable_exact)
        self.checkbutton_exact.pack(side="left")

        self.variable_regular_expression = tk.BooleanVar(value=0)
        self.checkbutton_regular_expression = ttk.Checkbutton(self, text="Regular Expression",
                                                              variable=self.variable_regular_expression)
        self.checkbutton_regular_expression.pack(side="left")

        self.search_entry.check_search()
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def frame1(self):
        self.frame1 = ttk.LabelFrame(self.master, text = "Parameters", borderwidth = 2, relief = "groove")
        self.frame1.place(bordermode = "outside", relwidth = 0.99, relheight = 0.21, relx = 0, x = 5, y = 5, anchor = "nw")
        self.frame1.first_run = True

        # function
        function_label = ttk.Label(self.frame1, text = "Function")
        function_option_menu = ttk.OptionMenu(self.frame1, self.function, self.function.get(),
                                              *sorted(self.FUNCOPT))

        # max_iter
        max_iter_label = ttk.Label(self.frame1, text = "Maximum number of iterations")
        max_iter_spinbox = Spinbox(self.frame1, from_ = 2, to_ = 9999,
                                   increment = 1, textvariable = self.max_iter,
                                   width = 6, justify = "right", takefocus = True)

        # fps
        fps_label = ttk.Label(self.frame1, text = "Delay between frames (ms)")
        fps_spinbox = Spinbox(self.frame1, from_ = 1, to_ = 1000,
                              increment = 1, textvariable = self.interval,
                              width = 6, justify = "right", takefocus = True)

        # seed
        seed_button = ttk.Checkbutton(self.frame1, text = "Fix seed",
                                      variable = self.fix_seed, takefocus = False)
        seed_spinbox = Spinbox(self.frame1, from_ = 0, to_ = self.MAX_SEED,
                               increment = 1, textvariable = self.seed,
                               width = 6, justify = "right", takefocus = True)

        # solver
        solver_label = ttk.Label(self.frame1, text = "Solver")

        solver_option_menu = ttk.OptionMenu(self.frame1, self.solver_name, self.solver_name.get(),
                                            *(self.EAOPT + self.MCOPT), command = self.select_widget)

        # constrain
        constrain_button = ttk.Checkbutton(self.frame1, text = "Constrain",
                                      variable = self.constrain, takefocus = False)

        # Layout
        function_label.place(relx = 0., x = 5, y = 5, anchor = "nw")
        function_option_menu.place(relx = 0., x = 75, y = 3, anchor = "nw")
        max_iter_label.place(relx = 0., x = 5, y = 30, anchor = "nw")
        max_iter_spinbox.place(width = 80, relx = 0., x = 220, y = 30, anchor = "nw")
        fps_label.place(relx = 0., x = 5, y = 55, anchor = "nw")
        fps_spinbox.place(width = 80, relx = 0., x = 220, y = 55, anchor = "nw")
        seed_button.place(relx = 0., x = 5, y = 80, anchor = "nw")
        seed_spinbox.place(width = 80, relx = 0., x = 220, y = 80, anchor = "nw")
        solver_label.place(relx = 0.35, x = 0, y = 5, anchor = "nw")
        solver_option_menu.place(relx = 0.35, x = 50, y = 3, anchor = "nw")
        constrain_button.place(relx = 0.35, x = 0, y = 80, anchor = "nw")
项目:serialplot    作者:crxguy52    | 项目源码 | 文件源码
def AObutton(self, graphnum):
        toplvl = tk.Toplevel()
        toplvl.withdraw()
        frame = ttk.Frame(toplvl, padding=[2, 3, 3, 0])

        boxwidth = 15

        #Create the labels
        lbl = ttk.Label(frame, text='Label')
        CreateToolTip(lbl, \
        'This text will show up in the legend and the log file')
        lbl.grid(row=0, column=1)

        mult = ttk.Label(frame, text='Multiplier')
        CreateToolTip(mult, \
        'Multiply by this value')
        mult.grid(row=0, column=2)

        offset = ttk.Label(frame, text='Offset') 
        CreateToolTip(offset, \
        'Add this value. Happens AFTER the data is multiplied')
        offset.grid(row=0, column=3)  

        dashed = ttk.Label(frame, text='Dashed')
        CreateToolTip(dashed, \
        'If checked, the line will be dashed')
        dashed.grid(row=0, column=4)  

        ttk.Label(frame, text='Line 1').grid(row=1, column=0, padx=2)
        ttk.Label(frame, text='Line 2').grid(row=2, column=0, padx=2)
        ttk.Label(frame, text='Line 3').grid(row=3, column=0, padx=2) 

        for row in range(1,3+1):
            key = 'graph'+str(graphnum)+'line'+str(row)
            #Label
            ttk.Entry(frame, width=boxwidth, \
                textvariable=self.controller.TKvariables[key][0]).grid(row=row, column=1)
            #Multiplier
            ttk.Entry(frame, width=boxwidth, \
                textvariable=self.controller.TKvariables[key][4]).grid(row=row, column=2)
            #Offset
            ttk.Entry(frame, width=boxwidth, \
                textvariable=self.controller.TKvariables[key][5]).grid(row=row, column=3) 
            #Dashed
            ttk.Checkbutton(frame, onvalue='--', offvalue='-', \
                variable=self.controller.TKvariables[key][3]).grid(row=row, column=4)
        ttk.Button(frame, text='OK', command=toplvl.destroy).grid(row=5,\
            column=3, columnspan=2, sticky='ew', pady=4)

        #Center the window
        frame.grid()
        toplvl.update()
        scrwidth = toplvl.winfo_screenwidth()
        scrheight = toplvl.winfo_screenheight()
        winwidth = toplvl.winfo_reqwidth()
        winheight = toplvl.winfo_reqheight()
        winposx = int(round(scrwidth/2 - winwidth/2))
        winposy = int(round(scrheight/2 - winheight/2))
        toplvl.geometry('{}x{}+{}+{}'.format(winwidth, winheight, winposx, winposy))
        toplvl.deiconify()
项目:LadderiLogical    作者:mikadam    | 项目源码 | 文件源码
def __init__(self, *args):

        super().__init__(*args)


        self.dir_selector=BiDirectionSelector(self.frame,self.conector_checks)
        self.dir_selector.pack()

        for check in self.conector_checks:
            check.trace("w",self.dir_selector.variable_changed)


        self.invert=tk.IntVar()
        self.invert_cheack=ttk.Checkbutton(master=self.frame,text="Invert",variable=self.invert,onvalue='0',offvalue='1')

        self.invert.set(1)
        self.invert_cheack.pack()



        vcmd = (self.root.register(self.validate), '%S','%d')

        self.subscribe_name=ttk.Entry(master=self.frame,width=10,validate="key",validatecommand=vcmd)

        self.subscribe_name.pack()


        self.top_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y)*self.board.tile_size,fill="",outline="")
        self.bottom_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+0.7)*self.board.tile_size,(self.y+1)*self.board.tile_size,fill="",outline="")
        self.left_box=self.board.canvas.create_rectangle((self.x+0.7)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,(self.x)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,fill="",outline="")
        self.right_box=self.board.canvas.create_rectangle((self.x+0.3)*self.board.tile_size,(self.y+0.3)*self.board.tile_size,(self.x+1)*self.board.tile_size,(self.y+0.7)*self.board.tile_size,fill="",outline="")

        self.switch_box=self.board.canvas.create_rectangle((self.x+0.2)*self.board.tile_size,(self.y+0.2)*self.board.tile_size,(self.x+0.8)*self.board.tile_size,(self.y+0.8)*self.board.tile_size,fill="#AF20CF",outline="#EEEEEE") 

        self.on_box_top=self.board.canvas.create_rectangle((self.x+0.4)*self.board.tile_size,(self.y+0.6)*self.board.tile_size,(self.x+0.6)*self.board.tile_size,(self.y+0.2)*self.board.tile_size+1,fill="",outline="")
        self.on_box_bottom=self.board.canvas.create_rectangle((self.x+0.4)*self.board.tile_size,(self.y+0.4)*self.board.tile_size,(self.x+0.8)*self.board.tile_size,(self.y+0.6)*self.board.tile_size,fill="",outline="")
        self.on_box_rigth=self.board.canvas.create_rectangle((self.x+0.4)*self.board.tile_size,(self.y+0.4)*self.board.tile_size,(self.x+0.6)*self.board.tile_size,(self.y+0.8)*self.board.tile_size,fill="",outline="")
        self.on_box_left=self.board.canvas.create_rectangle((self.x+0.6)*self.board.tile_size,(self.y+0.4)*self.board.tile_size,(self.x+0.2)*self.board.tile_size+1,(self.y+0.6)*self.board.tile_size,fill="",outline="")

        self.missing_key=self.board.canvas.create_text((self.x+0.5)*self.board.tile_size,(self.y+0.5)*self.board.tile_size,text="?",fill="")

        self.on_conectors=[self.on_box_top,self.on_box_bottom,self.on_box_rigth,self.on_box_left]
        self.graphic_conectors=[self.top_box,self.right_box,self.bottom_box,self.left_box]


        self.graphics=[self.missing_key,self.switch_box,self.top_box,self.bottom_box,self.left_box,self.right_box,self.on_box_top,self.on_box_bottom,self.on_box_rigth,self.on_box_left]


        self.state=0
项目:LadderiLogical    作者:mikadam    | 项目源码 | 文件源码
def __init__(self,root,app):
        ttk.Frame.__init__(self, root)
        self.root=root
        self.app=app

        self.output_list=[]
        self.input_list=[]


        ttk.Label(master=self,text="Outputs").grid(column=1,row=0)
        ttk.Label(master=self,text="Inputs").grid(column=2,row=0)

        v2cmd = (self.root.register(self.validate_2),'%S','%d')

        for x in range(8):
            a=ttk.Entry(master=self,width=10,validate="key",validatecommand=v2cmd)
            a.grid(column=1,row=x+1)
            a.insert(0,'1')
            b=ttk.Label(master=self,text='0')
            b.grid(column=0,row=x+1)
            self.output_list.append([a,b])

        for x in range(8):

            vcmd = (self.root.register(self.validate), '%P','%S','%d',x)

            def temp(r):
                def invcmd():
                    self.input_list[r][0].delete(0,tk.END)
                    self.input_list[r][0].insert(0,self.input_list[r][2])
                    self.input_list[r][0].config(validate="key")
                return invcmd

            a=ttk.Entry(master=self,width=10,validate="none",validatecommand=vcmd,invalidcommand=temp(x))
            a.grid(column=2,row=x+1)
            name=str(x+1)+"io"
            a.delete(0,tk.END)
            a.insert(0,name)
            self.app.board.flags[name]=[None,0]
            c=tk.IntVar()
            b=ttk.Checkbutton(master=self,variable=c)
            b.grid(column=3,row=x+1)
            a.config(validate="key")
            self.input_list.append([a,c,name])
项目:Spectroscope    作者:magin67    | 项目源码 | 文件源码
def SetColorWidgets(self, rowControl):
        ## ????
        def CheckVectorColor(): 
            self.shSpectr.useVectorColor = useVectorColor.get()
            self.shSpectr.ShowSp()

        def ChangeColorMap(val=0):
            cmap = SD.mColorMap()[int(float(val))]
            self.shSpectr.cmap = cmap
            self.lblCmap.configure(text='Map: ' + cmap)
            self.shSpectr.ShowSp()

        def SetVColor(val=0, ini=False):
            iColor = int(float(val))
            if not ini:
                self.shSpectr.SetColor(iColor)
                self.shSpectr.ShowSp()
            self.SetLabelVectorColor()

        def InverseColor():
            self.shSpectr.inverseColor = inverseColor.get()
            self.shSpectr.ShowSp()

        def SetAlpha(val=0, ini=False):
            normAlpha = Geo.Val2Val(float(val), [0, 100], [0, 1])
            if not ini:
                self.shSpectr.SetAlpha(normAlpha)
            self.lblAlpha.configure(text="Alpha: " + str(round(normAlpha, 2)))

        rowControl = self.AddLabel(rowControl, "Color", colsp=1)

        inverseColor = tk.BooleanVar()
        inverseColor.set(False)
        self.chkInverseColor = ttk.Checkbutton(self.frControl, text="Reverse", variable=inverseColor, onvalue=True, offvalue=False, command=InverseColor)
        rowControl = PlaceWidget(self.chkInverseColor, rowControl, col=1, stick='w') 

        cmap = self.shSpectr.cmap
        self.lblCmap = ttk.Label(self.frControl, text='Map: ' + cmap)
        PlaceWidget(self.lblCmap, rowControl)
        vColorMap = SD.mColorMap()
        indCMap = vColorMap.index(cmap) 
        self.scColorMap = ttk.Scale(self.frControl, orient='horizontal', length=self.colWidth2, from_=0, to=len(vColorMap)-1, value=indCMap, command=ChangeColorMap)
        rowControl = PlaceWidget(self.scColorMap, rowControl, col=1, stick='ne') 

        useVectorColor = tk.IntVar()
        useVectorColor.set(self.shSpectr.useVectorColor)
        self.chkVectorColor = ttk.Checkbutton(self.frControl, variable=useVectorColor, onvalue=True, offvalue=False, command=CheckVectorColor)
        rowControl = PlaceWidget(self.chkVectorColor, rowControl, col=0, stick='ew') 

        self.scColor = ttk.Scale(self.frControl, orient='horizontal', length=self.colWidth2, from_=0, to=self.shSpectr.numZ-1, value=self.shSpectr.iColor, command=SetVColor)
        rowControl = PlaceWidget(self.scColor, rowControl, col=1, stick='ne')
        SetVColor(val=self.shSpectr.iColor, ini=True) 

        iniAlpha = Geo.Val2Val(self.shSpectr.alpha, [0, 1], [0, 100])
        self.lblAlpha = ttk.Label(self.frControl)
        PlaceWidget(self.lblAlpha, rowControl)
        self.scAlpha = ttk.Scale(self.frControl, orient='horizontal', length=self.colWidth2, from_=0, to=100, value=iniAlpha, command=SetAlpha)
        rowControl = PlaceWidget(self.scAlpha, rowControl, col=1, stick='ne')
        SetAlpha(self.scAlpha.get(), True) 

        return self.AddLabel(rowControl)
项目:Spectroscope    作者:magin67    | 项目源码 | 文件源码
def SetMarkerWidgets(self, rowControl):
        ## Markers
        def ChangeMarkform(val='o'):
            self.shSpectr.mark_style = SD.dicMarkStyle()[val]
            self.shSpectr.ShowSp()

        def SetMarksizeLabel():
            self.lblMarksize.configure(text="Size: " + str(round(self.scMarksize.get(), 1)))

        def SetMarksize(val=0):
            self.shSpectr.ChangeMarksize(float(val))
            SetMarksizeLabel()

        def SetVmarksize(val=0, ini=False):
            ms = float(val)
            if not ini:
                self.shSpectr.SetMarksize(ms)
            self.SetLabelMSVector()

        def CheckMarksize():
            self.shSpectr.useVectorMarksize = useVectorMarksize.get()
            self.shSpectr.ShowSp()

        def InverseMarksize():
            self.shSpectr.inverseMarksize = inverseMarksize.get()
            self.shSpectr.ShowSp()

        rowControl = self.AddLabel(rowControl, "Markers", colsp=1)

        vsMarkStyle = list(SD.dicMarkStyle().keys())
        sMarkStyle = tk.StringVar(self.frControl)
        self.omMarkStyle = ttk.OptionMenu(self.frControl, sMarkStyle, "circle", *vsMarkStyle, command=ChangeMarkform)  
        rowControl = PlaceWidget(self.omMarkStyle, rowControl, col=1, stick='wn') 

        self.lblMarksize = ttk.Label(self.frControl)
        PlaceWidget(self.lblMarksize, rowControl)

        self.scMarksize = ttk.Scale(self.frControl, orient='horizontal', length=self.colWidth2, 
                from_=self.shSpectr.MarksizeRange[0], to=self.shSpectr.MarksizeRange[1], value=self.shSpectr.msize, command=SetMarksize)
        rowControl = PlaceWidget(self.scMarksize, rowControl, col=1, stick='ne')
        SetMarksizeLabel() 

        useVectorMarksize = tk.BooleanVar()
        useVectorMarksize.set(self.shSpectr.useVectorMarksize)
        self.chkMarkSize = ttk.Checkbutton(self.frControl, variable=useVectorMarksize, onvalue=True, offvalue=False, command=CheckMarksize)
        rowControl = PlaceWidget(self.chkMarkSize, rowControl, col=0, stick='ew') 

        self.scVMarksize = ttk.Scale(self.frControl, orient='horizontal', length=100, from_=0, to=self.shSpectr.numZ-1, value=self.shSpectr.iMarksize, command=SetVmarksize)
        rowControl = PlaceWidget(self.scVMarksize, rowControl, col=1, stick='ew')
        SetVmarksize(val=self.shSpectr.iMarksize, ini=True)

        inverseMarksize = tk.BooleanVar()
        inverseMarksize.set(self.shSpectr.inverseMarksize)
        self.chkInverseMarksize = ttk.Checkbutton(self.frControl, text="Reverse", variable=inverseMarksize, onvalue=True, offvalue=False, command=InverseMarksize)
        rowControl = PlaceWidget(self.chkInverseMarksize, rowControl, col=0, colspan=2, stick='wn') 

        return self.AddLabel(rowControl)
项目:Spectroscope    作者:magin67    | 项目源码 | 文件源码
def SetMaskWidgets(self, rowControl):
        ## ????? ????????????
        def ChangeMaskFunction(val='Var'):
            self.shSpectr.MaskFunction = val
            self.shSpectr.ShowSp()

        def SetMask(val=0, ini=False):
            self.shSpectr.iMask = int(float(val))
            self.chkMask.configure(text='Use: ' + str(int(self.shSpectr.iMask)))
            if not ini:
                self.shSpectr.ShowSp()

        def CheckMask():
            self.shSpectr.useMask = useMask.get()
            self.shSpectr.ShowSp()

        def InverseMask():
            self.shSpectr.inverseMask = inverseMask.get()
            self.shSpectr.ShowSp()

        rowControl = self.AddLabel(rowControl, "Mask", colsp=1)

        vsMaskFunction = ['Std', 'Mean']
        sMaskFunction = tk.StringVar(self.frControl)
        self.omMaskFunction = ttk.OptionMenu(self.frControl, sMaskFunction, "Std", *vsMaskFunction, command=ChangeMaskFunction)  
        rowControl = PlaceWidget(self.omMaskFunction, rowControl, col=1, stick='w') 

        useMask = tk.IntVar()
        useMask.set(False)
        self.chkMask = ttk.Checkbutton(self.frControl, variable=useMask, onvalue=True, offvalue=False, command=CheckMask)
        rowControl = PlaceWidget(self.chkMask, rowControl, col=0, stick='ew') 

        self.scMask = ttk.Scale(self.frControl, orient='horizontal', length=self.colWidth2, from_=0, to=100, value=self.shSpectr.iMask, command=SetMask)
        rowControl = PlaceWidget(self.scMask, rowControl, col=1, stick='ne')
        SetMask(val=self.shSpectr.iMask, ini=True) 

        inverseMask = tk.BooleanVar()
        inverseMask.set(self.shSpectr.inverseMask)
        self.chkInverseMask = ttk.Checkbutton(self.frControl, text="Inverse", variable=inverseMask, onvalue=True, offvalue=False, command=InverseMask)
        rowControl = PlaceWidget(self.chkInverseMask, rowControl, col=0, colspan=2, stick='wn') 

        return self.AddLabel(rowControl)