Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106495 > unrolled thread
| Started by | "ast" <nomail@com.invalid> |
|---|---|
| First post | 2016-04-05 08:57 +0200 |
| Last post | 2016-04-06 06:35 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Label behavior's difference between tkinter and ttk "ast" <nomail@com.invalid> - 2016-04-05 08:57 +0200
Re: Label behavior's difference between tkinter and ttk Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-05 16:10 +0100
Re: Label behavior's difference between tkinter and ttk Kevin Walzer <kw@codebykevin.com> - 2016-04-05 22:03 -0400
Re: Label behavior's difference between tkinter and ttk "ast" <nomail@com.invalid> - 2016-04-06 06:35 +0200
| From | "ast" <nomail@com.invalid> |
|---|---|
| Date | 2016-04-05 08:57 +0200 |
| Subject | Label behavior's difference between tkinter and ttk |
| Message-ID | <570361fd$0$648$426a74cc@news.free.fr> |
Hello
I currently migrate a GUI from tkinter to ttk and I found a problem
Here is a piece of code, with comments which explain what is
wrong.
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
BITMAP0 = """
#define zero_width 24
#define zero_height 32
static char zero_bits[] = {
0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f,
0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00,
0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00,
0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f,
0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00
};
"""
img = tk.BitmapImage(data=BITMAP0, foreground='white', background='black')
# This Label comes from ttk
label = ttk.Label(root, image=img)
# This Label comes from tk. To be uncommented to test behavior'difference
# label = tk.Label(root, image=img)
label.pack()
# The graphic is not refreshed after entering following commands
# when Label comes from ttk. You have to fly over the label with
# the mouse to get the right color.
# The graphic is immediately updated when Label comes from tk
# Enter these commands by hand, in a shell
img.config(foreground='red')
img.config(foreground='lime')
img.config(foreground='yellow')
It looks like a ttk bug, isn't it ?
I am using python 3.5.1
I tried a root.update_idletasks() to refresh the graphic
but it changed nothings.
[toc] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2016-04-05 16:10 +0100 |
| Message-ID | <mailman.73.1459869026.32530.python-list@python.org> |
| In reply to | #106495 |
On 05/04/2016 07:57, ast wrote:
> Hello
>
> I currently migrate a GUI from tkinter to ttk and I found a problem
>
> Here is a piece of code, with comments which explain what is wrong.
>
> import tkinter as tk
> import tkinter.ttk as ttk
>
> root = tk.Tk()
>
> BITMAP0 = """
> #define zero_width 24
> #define zero_height 32
> static char zero_bits[] = {
> 0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f,
> 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00,
> 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
> 0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
> 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00,
> 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f, 0xf0,0x00,0x0f,
> 0x00,0x00,0x00, 0x00,0x00,0x00, 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f,
> 0xf0,0x3c,0x0f, 0xf0,0x3c,0x0f, 0x00,0x00,0x00, 0x00,0x00,0x00
> };
> """
>
> img = tk.BitmapImage(data=BITMAP0, foreground='white', background='black')
>
> # This Label comes from ttk
>
> label = ttk.Label(root, image=img)
>
> # This Label comes from tk. To be uncommented to test behavior'difference
> # label = tk.Label(root, image=img)
>
> label.pack()
>
> # The graphic is not refreshed after entering following commands
> # when Label comes from ttk. You have to fly over the label with # the
> mouse to get the right color.
> # The graphic is immediately updated when Label comes from tk
>
> # Enter these commands by hand, in a shell
>
> img.config(foreground='red')
> img.config(foreground='lime')
> img.config(foreground='yellow')
>
>
> It looks like a ttk bug, isn't it ?
> I am using python 3.5.1
>
> I tried a root.update_idletasks() to refresh the graphic
> but it changed nothings.
>
I'm no tkinter expert, but I do know that there is a huge difference
between the way that tk and ttk widgets are configured. Here are a few
links that I hope will give you an idea.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Label.html
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-layouts.html
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-map.html
http://www.tkdocs.com/tutorial/styles.html
In the latter you might like to note that there is a section called
"Sound Difficult to you?". It's well worth the read.
--
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]
| From | Kevin Walzer <kw@codebykevin.com> |
|---|---|
| Date | 2016-04-05 22:03 -0400 |
| Message-ID | <ne1qin$7po$1@dont-email.me> |
| In reply to | #106495 |
In general, the "img.config" syntax is suitable for the classic Tk widgets, not the themed ttk widgets. They have a very different (and very gnarly) syntax for indicating changed state. I am not inclined to see a bug here. -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com
[toc] | [prev] | [next] | [standalone]
| From | "ast" <nomail@com.invalid> |
|---|---|
| Date | 2016-04-06 06:35 +0200 |
| Message-ID | <57049202$0$7121$426a74cc@news.free.fr> |
| In reply to | #106556 |
"Kevin Walzer" <kw@codebykevin.com> a écrit dans le message de news:ne1qin$7po$1@dont-email.me... > In general, the "img.config" syntax is suitable for the classic Tk widgets, not the themed ttk > widgets. They have a very different (and very gnarly) syntax for indicating changed state. I am > not inclined to see a bug here. > > -- > Kevin Walzer > Code by Kevin/Mobile Code by Kevin > http://www.codebykevin.com > http://www.wtmobilesoftware.com BitmapImage comes from tkinter. It doesn't rxist in ttk
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web