<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Zahari!<br>
      <br>
      First my personal meaning when working with Python + Qt:<br>
      <br>
      - Qt is great for classical GUI tasks, so solve graphical things
      using qt<br>
      - BUT: As soon as it comes to surrounding task (networking, etc.),
      Qt offers tools too which may be great helpers in the C++ world,
      but since we are using python, my experience is, that other
      libraries are much more flexible and comfortable to use.<br>
      <br>
      Your question about cross platform use of the clipboard could be
      one of the tasks where it is better to use other python tools:
      pyperclip. In the attachment, you can find 3 files, one containing
      an app for copying to the clipboard, one containing an app for
      pasting from the clipboard and one file containing the code of
      pyperclip. Start the apps for copying and pasting in parallel (I
      tried it on my Ubuntu by running the scripts from two different
      terminals). Per default, they use Qt to copy to the clipboard. By
      changing the USE_PYPERCLIP variable in both scripts, you can
      achieve the same using pyperclip. On my machine, both ways work
      perfectly fine. But on yours probably only the pyperclip approach
      will work without freeze/crash!?<br>
      <br>
      Hope it helps!<br>
      Aaron<br>
      <br>
      <br>
      <br>
      <br>
      Am 15.10.2013 00:45, schrieb Zahari Dim:<br>
    </div>
    <blockquote
cite="mid:CANx7HSbky+S=2NddBTEPLCwk_mR3N91HWQ1mpJGOwmrFC0EnAg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Hi,<br>
          <br>
        </div>
        <div>I need to programatically fill the clipboard with content
          that has custom mime types. I could make it work with PyQt4
          (with some cabarets). But when I try the same for PySide, the
          application I try to paste to just freezes, both under windows
          and linux. How could  make this work with PySide:<br>
          <br>
          <br>
          <p style="margin:0px;text-indent:0px"> </p>
          <p style="margin:0px;text-indent:0px"> </p>
          #This works<br>
          from PyQt4 import QtCore, QtGui<br>
        </div>
        <div>#This doesn't<br>
        </div>
        <div>#from PySide import QtCore, QtGui<br>
          <br>
          def start_app():<br>
              app = QtCore.QCoreApplication.instance()<br>
              if app is None:<br>
                  print "app"<br>
                  app = QtGui.QApplication([])<br>
              return app<br>
          <br>
                <br>
          #@run_in_qt <br>
          def set_clipboard(content, mime = 'text/plain'):<br>
              <br>
              mymime = QtCore.QMimeData()<br>
              mymime.setData(mime,
          QtCore.QByteArray(content.encode('utf-8')))<br>
              app = start_app()<br>
              clipboard = app.clipboard()<br>
              clipboard.setMimeData(mymime)<br>
              <br>
          <br>
          def get_clipboard():<br>
              content = QtGui.QApplication.clipboard().mimeData()<br>
              avaiable_formats = content.formats()<br>
              return {fmt:content.data(fmt) for fmt in avaiable_formats}<br>
          <br>
          <br>
        </div>
        <div>#PyQt4 doesn't work without this line _outside_ any of the
          functions....<br>
        </div>
        <div>__app = start_app()<br>
          <br>
          <br>
        </div>
        <div>Any help would be appreciated.<br>
          <br>
        </div>
        <div>Zahari Dimitrov.<br>
        </div>
        <div>    <br>
          <br>
              <br>
              <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
PySide mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PySide@qt-project.org">PySide@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/pyside">http://lists.qt-project.org/mailman/listinfo/pyside</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>