#gui #ui #widgets #bindings #graphics

fltk-calendar

A calendar dialog for fltk-rs

11 releases

0.4.0 Mar 31, 2023
0.3.6 Mar 22, 2022
0.3.5 Dec 19, 2021
0.3.3 Sep 8, 2021
0.1.2 Feb 19, 2021

#34 in #widgets

Download history 11/week @ 2023-02-01 65/week @ 2023-02-08 50/week @ 2023-02-15 30/week @ 2023-02-22 8/week @ 2023-03-01 5/week @ 2023-03-08 5/week @ 2023-03-15 2/week @ 2023-03-22 22/week @ 2023-03-29 22/week @ 2023-04-05 25/week @ 2023-04-12 4/week @ 2023-04-19 10/week @ 2023-04-26 16/week @ 2023-05-03 17/week @ 2023-05-10 8/week @ 2023-05-17

52 downloads per month
Used in booklibrs

MIT license

10KB
157 lines

fltk-rs-calendar

A calendar dialog for fltk-rs. It's separated into its own crate since it requires a dependency on chrono, also the Calendar::get_date() method returns a chrono::NaiveDate.

Usage

Add the following to your Cargo.toml:

[dependencies]
fltk-calendar = "0.3"

Then the dialog can be instatiated use the Calendar::new(x, y) or Calendar::default() functions. And the date can be chosen by double clicking on a cell.

use fltk::{prelude::*, *};
use fltk_calendar::calendar;
use chrono::prelude::*;

fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    let mut win = window::Window::new(100, 100, 400, 300, "");
    let mut but = button::Button::new(160, 200, 80, 40, "Click");
    win.end();
    win.show();
    but.set_callback(move |_| {
        let cal = calendar::Calendar::default(); // or calendar::Calendar::new(200, 100);
        let date = cal.get_date();
        println!("{:?}", date);
        if let Some(date) = date {
            println!("{:?}", date.year());
            println!("{:?}", date.month());
            println!("{:?}", date.day());
        }
    });
    app.run().unwrap();
}

Dependencies

~13MB
~297K SLoC