1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Themes - functions to list and set the overall theme (look and feel) of
//! the Tk program.
//!
//! * also see the Tk [manual](https://www.tcl-lang.org/man/tcl8.6/TkCmd/ttk_style.htm#M17)
use super::wish;
/// Returns a list of the current themes.
///
/// For example:
///
/// ```
/// let themes = rstk::theme_names();
/// println!("{} available themes: ", themes.len());
/// for theme in themes {
/// println!(" - {}", theme);
/// }
/// ```
///
/// Lists the themes (on Linux):
///
/// ```text
/// 4 available themes:
/// - clam
/// - alt
/// - default
/// - classic
/// ```
///
pub fn theme_names() -> Vec<String> {
let themes = wish::ask_wish("puts [ttk::style theme names] ; flush stdout");
let mut result: Vec<String> = vec![];
for theme in themes.split_whitespace() {
result.push(String::from(theme));
}
result
}
/// Sets the current theme to the given theme-name
pub fn use_theme(name: &str) {
let msg = format!("ttk::style theme use {}", name);
wish::tell_wish(&msg);
}