main.c 850 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //:w! | !clear && gcc -ltk -ltcl main.c -o template && ./template
  2. #include "tkc.h"
  3. int print_hello(TCL_FUNCTION_SIGNITURE)
  4. {
  5. tkc_puts("Hello, World!");
  6. return 0;
  7. }
  8. int print_entry_text(TCL_FUNCTION_SIGNITURE)
  9. {
  10. tkc_puts(argv[1]);
  11. return 0;
  12. }
  13. int main(void)
  14. {
  15. tkc_init();
  16. tkc_window_("template","200x200","0 0");
  17. tkc_set_arc_theme();
  18. tkc_command("on_button_0_pressed", print_hello);
  19. tkc_command("on_button_1_pressed", print_entry_text);
  20. TKC_WIDGET
  21. button_0 = tkc_button("-text {Say hello} -command {on_button_0_pressed}"),
  22. button_1 = tkc_button("-text {Print entry}"),
  23. entry_0 = tkc_entry("");
  24. tkc_configure(button_1, "-command {on_button_1_pressed [%s get]}", entry_0);
  25. tkc_grid(button_0, 0,0,1,1, "-sticky WE");
  26. tkc_grid(button_1, 0,1,1,1, "");
  27. tkc_grid( entry_0, 1,0,2,1, "-sticky WE");
  28. tkc_mainloop();
  29. return 0;
  30. }