Posted to tcl by starseeker at Sat Apr 25 14:05:49 GMT 2020view raw

  1. #include "stdlib.h"
  2.  
  3. #include "tcl.h"
  4. #include "tk.h"
  5.  
  6. #define wsize 500
  7.  
  8. int
  9. main()
  10. {
  11. Tcl_Interp *interp = Tcl_CreateInterp();
  12. Tk_Init(interp);
  13. Tk_Window tkwin = Tk_MainWindow(interp);
  14. Tk_GeometryRequest(tkwin, wsize, wsize);
  15. Tk_MakeWindowExist(tkwin);
  16. Tk_MapWindow(tkwin);
  17. Tcl_Eval(interp, "bind . <Button-1> \"puts A\"");
  18. Tcl_Eval(interp, "event generate . <Button-1>");
  19.  
  20. while (1) {
  21. int handled = 0;
  22. while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT)) {
  23. handled++;
  24. }
  25. if (!Tk_GetNumMainWindows()) {
  26. exit(0);
  27. }
  28. }
  29.  
  30. }
  31.  
  32. Error:
  33.  
  34. A
  35. invalid command name "::tk::ScreenChanged"
  36. while executing
  37. "::tk::ScreenChanged :1.0"
  38. (changing screen in event binding)
  39.  

Comments

Posted by starseeker at Sat Apr 25 14:27:24 GMT 2020 [text] [code]

Problem turned out to be Tcl_Init not getting called - added before Tk_Init and it cleared the error.