Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106069 > unrolled thread

Adding borders to ttk radiobuttons

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2016-03-30 14:14 +0100
Last post2016-03-31 00:41 +0100
Articles 8 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Adding borders to ttk radiobuttons Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-30 14:14 +0100
    Re: Adding borders to ttk radiobuttons "ast" <nomail@com.invalid> - 2016-03-30 16:45 +0200
      Re: Adding borders to ttk radiobuttons "ast" <nomail@com.invalid> - 2016-03-30 16:55 +0200
        Re: Adding borders to ttk radiobuttons Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-30 16:14 +0100
        Re: Adding borders to ttk radiobuttons Terry Reedy <tjreedy@udel.edu> - 2016-03-30 12:38 -0400
      Re: Adding borders to ttk radiobuttons Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-30 16:01 +0100
      Re: Adding borders to ttk radiobuttons Terry Reedy <tjreedy@udel.edu> - 2016-03-30 12:35 -0400
      Re: Adding borders to ttk radiobuttons Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-31 00:41 +0100

#106069 — Adding borders to ttk radiobuttons

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2016-03-30 14:14 +0100
SubjectAdding borders to ttk radiobuttons
Message-ID<mailman.204.1459343690.28225.python-list@python.org>
I believe something like this should suffice to display borders around 
the radiobuttons.

import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
style = ttk.Style()
style.configure('BW.TRadiobutton', borderwidth=5)
buttonVar = tk.IntVar()
rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
rb1.configure(style='BW.TRadiobutton')
rb1.grid(row=0, column=0)
rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
rb2.configure(style='BW.TRadiobutton')
rb2.grid(row=1, column=0)
root.mainloop()

Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [next] | [standalone]


#106079

From"ast" <nomail@com.invalid>
Date2016-03-30 16:45 +0200
Message-ID<56fbe699$0$4548$426a74cc@news.free.fr>
In reply to#106069
"Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de 
news:mailman.204.1459343690.28225.python-list@python.org...
>I believe something like this should suffice to display borders around the radiobuttons.
>
> import tkinter as tk
> import tkinter.ttk as ttk
> root = tk.Tk()
> style = ttk.Style()
> style.configure('BW.TRadiobutton', borderwidth=5)
> buttonVar = tk.IntVar()
> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
> rb1.configure(style='BW.TRadiobutton')
> rb1.grid(row=0, column=0)
> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
> rb2.configure(style='BW.TRadiobutton')
> rb2.grid(row=1, column=0)
> root.mainloop()
>
> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>

it seems there is no border on the radio button

> style.layout('BW.TRadiobutton')

[('Radiobutton.padding', {'children': [('Radiobutton.indicator', {'side': 'left', 'sticky': ''}), 
('Radiobutton.focus', {'side': 'left', 'sticky': '', 'children': [('Radiobutton.label', {'sticky': 
'nswe'})]})], 'sticky': 'nswe'})] 

[toc] | [prev] | [next] | [standalone]


#106080

From"ast" <nomail@com.invalid>
Date2016-03-30 16:55 +0200
Message-ID<56fbe905$0$4540$426a74cc@news.free.fr>
In reply to#106079
"ast" <nomail@com.invalid> a écrit dans le message de news:56fbe699$0$4548$426a74cc@news.free.fr...
>
> "Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de 
> news:mailman.204.1459343690.28225.python-list@python.org...
>>I believe something like this should suffice to display borders around the radiobuttons.
>>
>> import tkinter as tk
>> import tkinter.ttk as ttk
>> root = tk.Tk()
>> style = ttk.Style()
>> style.configure('BW.TRadiobutton', borderwidth=5)
>> buttonVar = tk.IntVar()
>> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
>> rb1.configure(style='BW.TRadiobutton')
>> rb1.grid(row=0, column=0)
>> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
>> rb2.configure(style='BW.TRadiobutton')
>> rb2.grid(row=1, column=0)
>> root.mainloop()
>>
>> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>>
>
> it seems there is no border on the radio button
>
>> style.layout('BW.TRadiobutton')
>
> [('Radiobutton.padding', {'children': [('Radiobutton.indicator', {'side': 'left', 'sticky': ''}), 
> ('Radiobutton.focus', {'side': 'left', 'sticky': '', 'children': [('Radiobutton.label', {'sticky': 
> 'nswe'})]})], 'sticky': 'nswe'})]

for more help:
http://www.tkdocs.com/tutorial/styles.html 

[toc] | [prev] | [next] | [standalone]


#106082

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2016-03-30 16:14 +0100
Message-ID<mailman.211.1459350873.28225.python-list@python.org>
In reply to#106080
On 30/03/2016 15:55, ast wrote:
>
> "ast" <nomail@com.invalid> a écrit dans le message de
> news:56fbe699$0$4548$426a74cc@news.free.fr...
>>
>> "Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de
>> news:mailman.204.1459343690.28225.python-list@python.org...
>>> I believe something like this should suffice to display borders
>>> around the radiobuttons.
>>>
>>> import tkinter as tk
>>> import tkinter.ttk as ttk
>>> root = tk.Tk()
>>> style = ttk.Style()
>>> style.configure('BW.TRadiobutton', borderwidth=5)
>>> buttonVar = tk.IntVar()
>>> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
>>> rb1.configure(style='BW.TRadiobutton')
>>> rb1.grid(row=0, column=0)
>>> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
>>> rb2.configure(style='BW.TRadiobutton')
>>> rb2.grid(row=1, column=0)
>>> root.mainloop()
>>>
>>> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>>>
>>
>> it seems there is no border on the radio button
>>
>>> style.layout('BW.TRadiobutton')
>>
>> [('Radiobutton.padding', {'children': [('Radiobutton.indicator',
>> {'side': 'left', 'sticky': ''}), ('Radiobutton.focus', {'side':
>> 'left', 'sticky': '', 'children': [('Radiobutton.label', {'sticky':
>> 'nswe'})]})], 'sticky': 'nswe'})]
>
> for more help:
> http://www.tkdocs.com/tutorial/styles.html

For this particular problem not of much use, or I wouldn't be asking :(

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#106094

FromTerry Reedy <tjreedy@udel.edu>
Date2016-03-30 12:38 -0400
Message-ID<mailman.217.1459356008.28225.python-list@python.org>
In reply to#106080
On 3/30/2016 11:14 AM, Mark Lawrence via Python-list wrote:
> On 30/03/2016 15:55, ast wrote:
>>
>> "ast" <nomail@com.invalid> a écrit dans le message de
>> news:56fbe699$0$4548$426a74cc@news.free.fr...
>>>
>>> "Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de
>>> news:mailman.204.1459343690.28225.python-list@python.org...
>>>> I believe something like this should suffice to display borders
>>>> around the radiobuttons.
>>>>
>>>> import tkinter as tk
>>>> import tkinter.ttk as ttk
>>>> root = tk.Tk()
>>>> style = ttk.Style()
>>>> style.configure('BW.TRadiobutton', borderwidth=5)
>>>> buttonVar = tk.IntVar()
>>>> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
>>>> rb1.configure(style='BW.TRadiobutton')
>>>> rb1.grid(row=0, column=0)
>>>> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
>>>> rb2.configure(style='BW.TRadiobutton')
>>>> rb2.grid(row=1, column=0)
>>>> root.mainloop()
>>>>
>>>> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>>>>
>>>
>>> it seems there is no border on the radio button
>>>
>>>> style.layout('BW.TRadiobutton')
>>>
>>> [('Radiobutton.padding', {'children': [('Radiobutton.indicator',
>>> {'side': 'left', 'sticky': ''}), ('Radiobutton.focus', {'side':
>>> 'left', 'sticky': '', 'children': [('Radiobutton.label', {'sticky':
>>> 'nswe'})]})], 'sticky': 'nswe'})]
>>
>> for more help:
>> http://www.tkdocs.com/tutorial/styles.html
>
> For this particular problem not of much use, or I wouldn't be asking :(

This page has some of the info needed to get a radiobutton with a 
border, at least my machine.  See my answer to your other response.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#106081

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2016-03-30 16:01 +0100
Message-ID<mailman.210.1459350084.28225.python-list@python.org>
In reply to#106079
On 30/03/2016 15:45, ast wrote:
>
> "Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de
> news:mailman.204.1459343690.28225.python-list@python.org...
>> I believe something like this should suffice to display borders around
>> the radiobuttons.
>>
>> import tkinter as tk
>> import tkinter.ttk as ttk
>> root = tk.Tk()
>> style = ttk.Style()
>> style.configure('BW.TRadiobutton', borderwidth=5)
>> buttonVar = tk.IntVar()
>> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
>> rb1.configure(style='BW.TRadiobutton')
>> rb1.grid(row=0, column=0)
>> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
>> rb2.configure(style='BW.TRadiobutton')
>> rb2.grid(row=1, column=0)
>> root.mainloop()
>>
>> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>>
>
> it seems there is no border on the radio button
>
>> style.layout('BW.TRadiobutton')
>
> [('Radiobutton.padding', {'children': [('Radiobutton.indicator',
> {'side': 'left', 'sticky': ''}), ('Radiobutton.focus', {'side': 'left',
> 'sticky': '', 'children': [('Radiobutton.label', {'sticky':
> 'nswe'})]})], 'sticky': 'nswe'})]

That's as may be, but from Table 56 "ttk Radiobutton options not in 
ttk.Radiobutton" here 
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Radiobutton.html 
it says "borderwidth or bd - Configure this option using a style."

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#106092

FromTerry Reedy <tjreedy@udel.edu>
Date2016-03-30 12:35 -0400
Message-ID<mailman.215.1459355761.28225.python-list@python.org>
In reply to#106079
On 3/30/2016 11:01 AM, Mark Lawrence via Python-list wrote:
> On 30/03/2016 15:45, ast wrote:
>>
>> "Mark Lawrence" <breamoreboy@yahoo.co.uk> a écrit dans le message de
>> news:mailman.204.1459343690.28225.python-list@python.org...
>>> I believe something like this should suffice to display borders around
>>> the radiobuttons.
>>>
>>> import tkinter as tk
>>> import tkinter.ttk as ttk
>>> root = tk.Tk()
>>> style = ttk.Style()
>>> style.configure('BW.TRadiobutton', borderwidth=5)
>>> buttonVar = tk.IntVar()
>>> rb1 = ttk.Radiobutton(text='Hello mum', variable=buttonVar, value=1)
>>> rb1.configure(style='BW.TRadiobutton')
>>> rb1.grid(row=0, column=0)
>>> rb2 = ttk.Radiobutton(text='Hello dad', variable=buttonVar, value=2)
>>> rb2.configure(style='BW.TRadiobutton')
>>> rb2.grid(row=1, column=0)
>>> root.mainloop()
>>>
>>> Sadly no borders :(  What have I missed?  Python 3.5.1 on Windows 10.
>>>
>>
>> it seems there is no border on the radio button
>>
>>> style.layout('BW.TRadiobutton')
>>
>> [('Radiobutton.padding', {'children': [('Radiobutton.indicator',
>> {'side': 'left', 'sticky': ''}), ('Radiobutton.focus', {'side': 'left',
>> 'sticky': '', 'children': [('Radiobutton.label', {'sticky':
>> 'nswe'})]})], 'sticky': 'nswe'})]
>
> That's as may be, but from Table 56 "ttk Radiobutton options not in
> ttk.Radiobutton" here
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Radiobutton.html
> it says "borderwidth or bd - Configure this option using a style."

Components depend on the theme.  In some themes, Radiobutton does have a 
border.  On Windows 10, I ran

 >>> for s in style.theme_names():
	style.theme_use(s)
	style.theme_use()
	style.layout('TRadiobutton')

Theme names are ('winnative', 'clam', 'alt', 'default', 'classic', 
'vista', 'xpnative') with 'vista'the default. Outputs were the same as above

'vista'
[('Radiobutton.padding', {'sticky': 'nswe', 'children':
[('Radiobutton.indicator', {'sticky': '', 'side': 'left'}),
  ('Radiobutton.focus', {'sticky': '', 'children':
[('Radiobutton.label', {'sticky': 'nswe'})], 'side': 'left'})]})]

except for this

'classic'
[('Radiobutton.highlight', {'sticky': 'nswe', 'children': 
[('Radiobutton.border', {'sticky': 'nswe', 'children': 
[('Radiobutton.padding', {'sticky': 'nswe', 'children': 
[('Radiobutton.indicator', {'sticky': '', 'side': 'left'}), 
('Radiobutton.label', {'sticky': 'nswe', 'side': 'left'})]})]})]})]

.theme_names() only displays the themes for the OS.  I believe that 
there is a way to access themes for other OSes (unix, mac) but don't 
remember.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#106117

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2016-03-31 00:41 +0100
Message-ID<mailman.229.1459381298.28225.python-list@python.org>
In reply to#106079
On 30/03/2016 17:35, Terry Reedy wrote:
>
> .theme_names() only displays the themes for the OS.  I believe that
> there is a way to access themes for other OSes (unix, mac) but don't
> remember.
>

Possibly http://bugs.python.org/issue17397 which refers to 
http://code.activestate.com/lists/python-tkinter-discuss/3373/ ?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web