Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Changing Gtk theme #586

Closed
StefanMathis opened this issue Aug 19, 2021 · 5 comments
Closed

Changing Gtk theme #586

StefanMathis opened this issue Aug 19, 2021 · 5 comments

Comments

@StefanMathis
Copy link

Hello,

I'm currently developing a GUI with GTK.jl and I'd like to change the theme at runtime (e.g. to the win32 theme when the program is executed on Windows). Is there an easy way to do this? I searched quite a bit on the web and found for example this explanation on how to do it with Python:
https://stackoverflow.com/questions/42881112/pygtk3-how-to-change-application-theme

However, as far as I understand, the themes for Gtk.jl are provided by the .jll packages in the main Gtk.jl file. Does this mean that for any specific theme a .jll-Package needs to be built? Furthermore, how can one select a specific theme? For example, in Gtk.jl the following packages are imported:
adwaita_icon_theme_jll, hicolor_icon_theme_jll
From the look and feel, I'd say that the Adwaita theme is used by default, however I could not identify where in the code this is actually specified.

Any help would be appreciated very much :-)

@tknopp
Copy link
Collaborator

tknopp commented Aug 19, 2021

Could you try setting it using an environment variable? See https://unix.stackexchange.com/questions/14129/gtk-enable-set-dark-theme-on-a-per-application-basis

@tknopp
Copy link
Collaborator

tknopp commented Aug 19, 2021

Yes this works

GTK_THEME=Adwaita:dark julia

makes all widgets dark.

@StefanMathis
Copy link
Author

StefanMathis commented Aug 20, 2021

Thank you very much for your answer. To clarify a little bit for anyone as uninformed as myself who stumbles upon this thread: You can set the environment variable directly in Julia by the following command:
ENV["GTK_THEME"] = "win32"
I use this command in the __init__ function of my module. Works like a charm!

@tknopp
Copy link
Collaborator

tknopp commented Aug 20, 2021

I think there is also some possibility to do this at runtime within Gtk but actually this solution with the environment variable and the __init__ function is also fine from my perspective.

@StefanMathis
Copy link
Author

I didn't test it, but I think you can actually change the theme at runtime because __init__ is just a function :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants