3

On my computer with Win8.1 when I use following code

   from tkinter import *
   from tkinter.ttk import *

   Tk().mainloop()

I see only the old looking tkinter. Any idea how to fix it?

enter image description here

I tried to use different theme with no result.

For some reason following code:

from tkinter import *
from tkinter.ttk import *

Style().theme_use("alt")
Tk().mainloop()

results with two identical tkinter old-fashioned windows which seems not to be correct.

PS: It seems to be issue related with Win8.1, see here: Python 2.7 - ttk module seemingly not working in Windows 8.1

But I found no information how to fix it. Any news would be welcome. :)

EDIT1: After trying following snippet:

from tkinter import *
from tkinter.ttk import *
from functools import partial

root = Tk()
style = Style(root)

def change(name, style):
    style.theme_use(name)

for s in style.theme_names():
    lb = Button(root, text=s, command=partial(change, s, style))
    lb.pack()

I could say the themes are changing not only for color but completely. What is still puzzling me is I cannot see the nice fancy graphic which I expect to see. I tried to change my windows settings for performance or to visual aspect but it is not the reason why it is not working.

If you have Win 8.1 do you have tkk working as expected?

EDIT2: This is my look using example from http://www.tkdocs.com/tutorial/firstexample.html (Win7 and Win8.1)

my look

Community
  • 1
  • 1
Pavel Hanpari
  • 4,029
  • 2
  • 20
  • 23
  • I don't think ttk affects the root window, only the widgets inside. – Bryan Oakley Nov 23 '15 at 20:49
  • Thank you, but even with code copied from this source: http://www.tkdocs.com/tutorial/firstexample.html tkinter is not working as indicated on picture. Same old-fashioned theme as usual. – Pavel Hanpari Nov 23 '15 at 20:52
  • certainly, using the "alt" theme will give bad results. If you don't explicitly set the theme and create a ttk Button, does the button look correct? – Bryan Oakley Nov 23 '15 at 20:57
  • Not giving explicitly theme is resulting in old tinker. I tried to change them but I see no difference. I just received two windows with used style which is pretty weird because I was expecting one. – Pavel Hanpari Nov 23 '15 at 21:09
  • One more comment. Now I realized that changing theme is changing color inside but I am not able to reach any fancy graphic expected from ttk example. The look is the same only color has changed. My issue with two windows is my mistake. I forgot to explicitly add main Tk() class to style constructor. Sorry about that. – Pavel Hanpari Nov 23 '15 at 21:17
  • Is the appearance you are trying to get from the specified document [this?](http://www.tkdocs.com/images/f2m_all.png) Because from the code provided (2nd block) it seems to work as intended. – Steven Summers Nov 24 '15 at 01:57
  • Well, not working for me. See Edit2 from above. – Pavel Hanpari Nov 24 '15 at 08:19

1 Answers1

1

The difference can be easily seen on ubuntu between the themes. So, maybe it is a problem with win8.1. Considered using the ttkthemes module? The ttkthemes module is another set of more "Stylish" styles. To install:

sudo apt-get install python3-tk
sudo -H pip3 install ttkthemes

To know more, go to: https://github.com/RedFantom/ttkthemes/wiki/Usage

I have answered another similar question,you can refer to it through this link: How to make pyinstaller import the ttk theme? Lemme know in the comments if this also, doesn't work.

Eshita Shukla
  • 791
  • 1
  • 8
  • 30