Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fltk-rs/fltk-calendar
A calendar dialog for fltk-rs
https://github.com/fltk-rs/fltk-calendar
Last synced: about 2 months ago
JSON representation
A calendar dialog for fltk-rs
- Host: GitHub
- URL: https://github.com/fltk-rs/fltk-calendar
- Owner: fltk-rs
- License: mit
- Created: 2021-02-11T22:43:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-12T21:30:38.000Z (4 months ago)
- Last Synced: 2024-10-13T10:38:25.255Z (3 months ago)
- Language: Rust
- Size: 19.5 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```toml
[dependencies]
fltk-calendar = "0.4"
```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.
```rust,no_run
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();
}
```