# How can I generate WXME files from some other external files?

**URL:** <https://racket.discourse.group/t/how-can-i-generate-wxme-files-from-some-other-external-files/1176>\
**Category:** Questions & Answers\
**Tags:** gui\
**Created:** [July 23, 2022, 9:51pm UTC](https://racket.discourse.group/t/how-can-i-generate-wxme-files-from-some-other-external-files/1176 "2022-07-23T21:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![etaoinbe](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@etaoinbe](https://racket.discourse.group/u/etaoinbe)\
**Post date:** [July 23, 2022, 9:51pm UTC](https://racket.discourse.group/t/how-can-i-generate-wxme-files-from-some-other-external-files/1176/1 "2022-07-23T21:51:23Z")

</div>

how can I generate WXME files from some other external files?

the decoding wxme chapter appearst to assume you already have a wxme file, I want to GENERATE a wxme file that can be edited afterwards in drracket

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [July 24, 2022, 11:49am UTC](https://racket.discourse.group/t/how-can-i-generate-wxme-files-from-some-other-external-files/1176/2 "2022-07-24T11:49:50Z")

</div>

Sorry I don’t have time to work this out myself.

If I was to do it it’d check the DrRacket and gui **framework** documentation to start, and follow that by reading the respective source code.  
I’d also probably use a text or even hex editor to inspect a sample file I made with DrRacket to take a look. Racket source code search in DrRacket and GitHub are also useful.

Sorry I can’t offer more specific help but I hope this gets you on the right path.

Stephen

---

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [July 24, 2022, 12:47pm UTC](https://racket.discourse.group/t/how-can-i-generate-wxme-files-from-some-other-external-files/1176/3 "2022-07-24T12:47:16Z")

</div>

You can generate WXME files by setting up a `text%` or `pasteboard%` with the snips you want and calling `save-file`. The example below will save a WXME file with some text and an image in the "hello.wxme" file. You can open the resulting file in DrRacket to see that it has the same contents as the opened window.

Note that the snips that can be saved into WXME format need to have read and write methods implemented correctly -- in the example below, the plot is interactive in the window, but if you open the WXME file in DrRacket, you'll get a static image -- this is because the plot snip does not implement a correct save/read operation and relies on the parent image snip for this...

Hope this helps,  
Alex.

```scheme
#lang racket/gui
(require pict pict/snip plot)

(define toplevel (new frame% [label "WXME Demo"] [width 400] [height 300]))
(define canvas (new editor-canvas% [parent toplevel]))
(define text (new text%))

(send canvas set-editor text)

(send text insert "Hello World! ")
(send text insert (new pict-snip% [pict (standard-fish 100 50)]))
(send text insert (plot-snip (function sin -5 5) #:width 300 #:height 200))

(send text save-file "hello.wxme")

(send toplevel show #t)

```
