Vote Up 0 Vote Down

tkinter linux

Hello guys i was just discovering Tkinter library ,
so i read about ttk which makes widgets themes ,
but why it don't work in linux it looks ugly

windows pythonlinux python
flag

Answers


Vote Up 0 Vote Down
You'll notice that the window colours and decorations are different for idle whether you are using windows or linux. Your program is using the computers 'default' settings for creating windows. You can either try to set the colours by hand in your program or change the gtk theme in linux. I'm not even sure the former option is possible under tkinter, I've never used it but it should be do-able. ..
flag | link |
Vote Up 0 Vote Down
I am a PyGi (GTK+ 3) user. And I coded this for one of my application, to use a different theme instead of the default one.

from gi.repository import Gtk
# Change theme of the app.
themes = ['Default', 'Greybird']
setting = Gtk.Settings.get\_default()
setattr(setting.props, 'gtk-theme-name', themes[config.THEME])


We can use CSS to design our widgets in GUI. Just like we use it for web-pages.

Have you ever looked at tkinter.ttk.Style

# The example is copied from original Python docs.
# As an example, let’s change the Combobox for the default theme a bit:
from tkinter import ttk
import tkinter

root = tkinter.Tk()

style = ttk.Style()
style.theme\_settings("default", { # I think you can change theme here.
"TCombobox": {
"configure": {"padding": 5},
"map": {
"background": [("active", "green2"),
("!disabled", "green4")],
"fieldbackground": [("!disabled", "green3")],
"foreground": [("focus", "OliveDrab1"),
("!disabled", "OliveDrab2")]
}
}
})

combo = ttk.Combobox().pack()

root.mainloop()


Check the tkinter.ttk section in Python docs. ..
flag | link |

Your Answer

Login before answering

Login with facebook