Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Label behavior's difference between tkinter and ttk Date: Tue, 5 Apr 2016 16:10:03 +0100 Lines: 75 Message-ID: References: <570361fd$0$648$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de nODjFA/bCPni+RwTb9QK3A39oQFfWnZuGIqdJJnYROMg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'root': 0.04; '"""': 0.05; 'from:addr:yahoo.co.uk': 0.05; '#define': 0.07; 'mouse': 0.07; 'ast': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'refresh': 0.09; 'python': 0.10; 'read.': 0.13; 'bug,': 0.16; 'color.': 0.16; 'expert,': 0.16; 'fly': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:between': 0.16; 'wrote:': 0.16; 'char': 0.18; 'gui': 0.18; 'shell': 0.18; 'language': 0.19; 'latter': 0.22; 'lawrence': 0.22; 'tkinter': 0.22; 'code,': 0.23; 'tried': 0.24; 'import': 0.24; 'url:edu': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'looks': 0.29; 'img': 0.29; "i'm": 0.30; 'comments': 0.30; 'language.': 0.32; 'changed': 0.33; 'problem': 0.33; 'label': 0.35; "isn't": 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'difference': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'called': 0.40; 'hope': 0.61; 'charset:windows-1252': 0.62; 'our': 0.64; 'between': 0.65; 'here': 0.66; 'worth': 0.67; 'url:help': 0.73; '3.5.1': 0.84; 'pythonistas,': 0.84; 'ttk': 0.84; 'url:tkinter': 0.84; 'url:tutorial': 0.91; 'hand,': 0.97 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.189.93 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: <570361fd$0$648$426a74cc@news.free.fr> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <570361fd$0$648$426a74cc@news.free.fr> Xref: csiph.com comp.lang.python:106524 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