https://github.com/fernandolguevara/tcltk.c3l
Tcl/Tk bindings for c3 (WIP)
https://github.com/fernandolguevara/tcltk.c3l
c3 tcl tcl-tk tk
Last synced: 4 months ago
JSON representation
Tcl/Tk bindings for c3 (WIP)
- Host: GitHub
- URL: https://github.com/fernandolguevara/tcltk.c3l
- Owner: fernandolguevara
- Created: 2024-10-31T20:20:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-02T23:15:11.000Z (over 1 year ago)
- Last Synced: 2025-08-03T14:45:24.393Z (10 months ago)
- Topics: c3, tcl, tcl-tk, tk
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tcl/Tk bindings for c3
## Example
```c++
module app;
import std::io, tcltk;
fn CInt on_btn_clicked(CInt clientData, Tcl_Interp* tcl_interp, CInt argc, void* argv) {
io::printn("called from tcl/tk");
CInt rc = tcltk::tcl_eval(tcl_interp, `
tk_messageBox -message "Really quit?" \
-icon question -type yesno \
-detail "Select \"Yes\" to make the application exit"
`);
if(rc == 0) {
ZString answer = tcltk::tcl_get_string_result(tcl_interp);
if(answer.str_view() == "yes"){
io::printn("quiting...");
defer tcltk::tcl_exit(0);
}
}
return 0;
}
fn void! main(String[] args) {
Tcl_Interp* tcl_interp = tcltk::tcl_create_interp();
if(!tcl_interp) {
io::printn("can not create tcl interpreter.");
}
tcltk::tcl_init(tcl_interp);
tcltk::tk_init(tcl_interp);
ZString script = `
puts "Hello, from Tcl/Tk!"
package require Tk
button .btnExit -text "Click me!" -command exitProc
pack .btnExit
`;
tcltk::tcl_create_command(tcl_interp, "exitProc", &on_btn_clicked, 0, null);
CInt rc = tcltk::tcl_eval(tcl_interp, script);
if(rc == 0){
for(;;) {
tcltk::tcl_do_one_event(0);
}
}
}
```