Search code examples
pythonwxpythonwxwidgetsclipboard

Writing a clipboard manager using wxpython?


Current state: I have a tray icon, two context menus - one for about/options/exit/etc. on right-click and one on left-click for clipboard management.

One thing I'm not sure of is how to sync clipboard contents - I grasped how to read and write data from/to clipboard, but I don't know how to detect changes(or should I check periodically?).

How would you do this?


Solution

  • Anyone please correct me if I am wrong but as far as I think the only way to implement is polling.

    I also tried looking at the source code one of the famous clipboard manager http://parcellite.sourceforge.net/.

    I found this peace of code in that.

      /* Add the daemon loop */
      timeout_id = g_timeout_add_full(G_PRIORITY_LOW,
                                      DAEMON_INTERVAL,
                                      (GSourceFunc)daemon_check,
                                      NULL,
                                      (GDestroyNotify)reset_daemon);
    

    And in the header file, DAEMON_INTERVAL is defined as 500. So, it checks after every 500 milliseconds.