Python ttk.Radiobutton() Examples

The following are 10 code examples of ttk.Radiobutton(). 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 ttk , or try the search function .
Example #1
Source File: edit_dialog.py    From Enrich2 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs):
        self.rb_fastq = ttk.Radiobutton(
            master,
            text="FASTQ File Mode",
            variable=self.mode,
            value="FASTQ",
            command=self.fastq_mode,
        )
        self.rb_fastq.grid(row=row, column=0, columnspan=columns, sticky="ew")
        self.rb_counts = ttk.Radiobutton(
            master,
            text="Count File Mode",
            variable=self.mode,
            value="Counts",
            command=self.counts_mode,
        )
        self.rb_counts.grid(row=row + 1, column=0, columnspan=columns, sticky="ew")
        return 2 
Example #2
Source File: myNotebook.py    From EDMarketConnector with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, master=None, **kw):
        if platform == 'darwin':
            kw['foreground'] = kw.pop('foreground', PAGEFG)
            kw['background'] = kw.pop('background', PAGEBG)
            tk.Radiobutton.__init__(self, master, **kw)
        elif platform == 'win32':
            ttk.Radiobutton.__init__(self, master, style='nb.TRadiobutton', **kw)
        else:
            ttk.Radiobutton.__init__(self, master, **kw) 
Example #3
Source File: test_widgets.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        myvar = Tkinter.IntVar()
        cbtn = ttk.Radiobutton(command=cb_test, variable=myvar, value=0)
        cbtn2 = ttk.Radiobutton(command=cb_test, variable=myvar, value=1)

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

        cbtn2['command'] = ''
        res = cbtn2.invoke()
        self.assertEqual(res, '')
        self.assertFalse(len(success) > 1)
        self.assertEqual(cbtn2['value'], myvar.get())
        self.assertEqual(myvar.get(),
            cbtn.tk.globalgetvar(cbtn['variable']))

        self.assertEqual(str(cbtn['variable']), str(cbtn2['variable'])) 
Example #4
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.Radiobutton(self.root, **kwargs) 
Example #5
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        myvar = tkinter.IntVar(self.root)
        cbtn = ttk.Radiobutton(self.root, command=cb_test,
                               variable=myvar, value=0)
        cbtn2 = ttk.Radiobutton(self.root, command=cb_test,
                                variable=myvar, value=1)

        if self.wantobjects:
            conv = lambda x: x
        else:
            conv = int

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

        cbtn2['command'] = ''
        res = cbtn2.invoke()
        self.assertEqual(str(res), '')
        self.assertLessEqual(len(success), 1)
        self.assertEqual(conv(cbtn2['value']), myvar.get())
        self.assertEqual(myvar.get(),
            conv(cbtn.tk.globalgetvar(cbtn['variable'])))

        self.assertEqual(str(cbtn['variable']), str(cbtn2['variable'])) 
Example #6
Source File: create_seqlib_dialog.py    From Enrich2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def body(self, master):
        message = ttk.Label(master, text="SeqLib type:")
        message.grid(column=0, row=0)

        for i, k in enumerate(SEQLIB_LABEL_TEXT.keys()):
            rb = ttk.Radiobutton(
                master,
                text=SEQLIB_LABEL_TEXT[k],
                variable=self.element_tkstring,
                value=k,
            )
            rb.grid(column=0, row=(i + 1), sticky="w")
            if i == 0:
                rb.invoke() 
Example #7
Source File: date_decoder.py    From Learning-Python-for-Forensics-Second-Edition with MIT License 5 votes vote down vote up
def build_input_frame(self):
        """
        The build_input_frame method builds the interface for
        the input frame
        """
        # Frame Init
        self.input_frame = ttk.Frame(self.root)
        self.input_frame.config(padding = (30,0))
        self.input_frame.pack()

        # Input Value
        ttk.Label(self.input_frame,
            text="Enter Time Value").grid(row=0, column=0)

        self.input_time = StringVar()
        ttk.Entry(self.input_frame, textvariable=self.input_time,
            width=25).grid(row=0, column=1, padx=5)

        # Radiobuttons
        self.time_type = StringVar()
        self.time_type.set('raw')

        ttk.Radiobutton(self.input_frame, text="Raw Value",
            variable=self.time_type, value="raw").grid(row=1,
                column=0, padx=5)

        ttk.Radiobutton(self.input_frame, text="Formatted Value",
            variable=self.time_type, value="formatted").grid(
                row=1, column=1, padx=5)

        # Button
        ttk.Button(self.input_frame, text="Run",
            command=self.convert).grid(
                row=2, columnspan=2, pady=5) 
Example #8
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.Radiobutton(self.root, **kwargs) 
Example #9
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def test_invoke(self):
        success = []
        def cb_test():
            success.append(1)
            return "cb test called"

        myvar = tkinter.IntVar(self.root)
        cbtn = ttk.Radiobutton(self.root, command=cb_test,
                               variable=myvar, value=0)
        cbtn2 = ttk.Radiobutton(self.root, command=cb_test,
                                variable=myvar, value=1)

        if self.wantobjects:
            conv = lambda x: x
        else:
            conv = int

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

        cbtn2['command'] = ''
        res = cbtn2.invoke()
        self.assertEqual(str(res), '')
        self.assertLessEqual(len(success), 1)
        self.assertEqual(conv(cbtn2['value']), myvar.get())
        self.assertEqual(myvar.get(),
            conv(cbtn.tk.globalgetvar(cbtn['variable'])))

        self.assertEqual(str(cbtn['variable']), str(cbtn2['variable'])) 
Example #10
Source File: create_root_dialog.py    From Enrich2 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def body(self, master):
        row_no = self.name_tk.body(master, 0)
        row_no += self.output_directory_tk.body(master, row_no)

        element_types = ttk.Frame(master, padding=(3, 3, 12, 12))
        element_types.grid(
            column=0, row=row_no, sticky="nsew", columnspan=DEFAULT_COLUMNS
        )

        message = ttk.Label(element_types, text="Root object type:")
        message.grid(column=0, row=0)

        label = ttk.Label(element_types, text="Experiment")
        label.grid(column=0, row=1, sticky="w")
        rb = ttk.Radiobutton(
            element_types,
            text="Experiment",
            variable=self.element_tkstring,
            value="Experiment",
        )
        rb.grid(column=0, row=2, sticky="w")
        rb.invoke()

        label = ttk.Label(element_types, text="Selection")
        label.grid(column=0, row=3, sticky="w")
        rb = ttk.Radiobutton(
            element_types,
            text="Selection",
            variable=self.element_tkstring,
            value="Selection",
        )
        rb.grid(column=0, row=4, sticky="w")

        label = ttk.Label(element_types, text="SeqLib")
        label.grid(column=0, row=5, sticky="w")
        for i, k in enumerate(SEQLIB_LABEL_TEXT.keys()):
            rb = ttk.Radiobutton(
                element_types,
                text=SEQLIB_LABEL_TEXT[k],
                variable=self.element_tkstring,
                value=k,
            )
            rb.grid(column=0, row=(i + 6), sticky="w")