Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106524
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Label behavior's difference between tkinter and ttk |
| Date | 2016-04-05 16:10 +0100 |
| Message-ID | <mailman.73.1459869026.32530.python-list@python.org> (permalink) |
| References | <570361fd$0$648$426a74cc@news.free.fr> <ne0kgh$i0o$1@ger.gmane.org> |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web