<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20605">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst,
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle,
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;">
<div>Hello,</div><div><br></div><div data-signatureblock="true">I am trying to get the value of a label after a button is clicked. I know that I can use (send x get-label) to get the value of the label, but it only gets the initial value of the label in my case "No Zip Code Entered". Also, after that button is pressed I would like to run code that queries an API and parses xml information using the zip code from the label. Below is my code:</div><div><br></div><div>Thanks in Advanced,</div><div><br></div><div>Puzzledplane</div><div><br></div><div>GUI:</div><div><br></div><div> #lang racket<br> (require racket/gui/base)<br> <br> ;; Creates a Frame called mainframe<br> (define mainframe (new frame% [label "Forecaster - Powered by Wunderground API"]<br> [width 500]<br> [height 500]<br> [stretchable-width 500]<br> [stretchable-height 500]))<br> <br> ;; Creates a Current Conditions group-box-panel<br> (define maingroup (new group-box-panel%<br> [label "Current Conditions:"]<br> [parent mainframe]<br> [min-height 450]<br> [stretchable-height 450]))<br> <br> <br> (define cclabel (new message% [parent maingroup]<br> [label "Insert Conditions Here from API"] ))<br> <br> ;; Creates a Zip Code group-box-panel<br> (define zipcodegroup (new group-box-panel%<br> [label "Zip Code:"]<br> [parent mainframe]<br> [min-height 100]<br> [stretchable-height 100]))<br> <br> ;; Zip Code Message Label -- Defaults to No Zip Code Entered<br> (define zipcodelabel (new message% [parent zipcodegroup]<br> [label "No Zip Code Entered"] ))<br> <br> ;; Zip Code Text-Field<br> (define zipInput <br> (new text-field% <br> [parent zipcodegroup]<br> [label ""]<br> [init-value ""]<br> [min-width 5]<br> [stretchable-width 5]<br> [callback (lambda(f ev)<br> (define v (send f get-value))<br> (unless (string->number v)<br> (send f set-value (regexp-replace* #rx"[^0-9]+" v ""))))]))<br> <br> ;; Submit Button<br> (define submit-button <br> (new button% <br> [parent zipcodegroup]<br> [label "Submit"]<br> [callback (lambda (button event)<br> (let ([v (send zipInput get-value)])<br> (send zipcodelabel set-label v)<br> ))]))<br> ;; Show Frame<br> (send mainframe show #t)</div><div><br></div><div>XML Parsing:</div><div><br></div><div> #lang racket<br> (require net/url xml xml/path)<br> <br> (define curent-cond-url (string->url "<a href="http://api.wunderground.com/api/%2asnip%2a/conditions/q/autoip.xml" target="_parent">http://api.wunderground.com/api/*snip*/conditions/q/autoip.xml</a>"))<br> (define current-cond-port (get-pure-port curent-cond-url))<br> (define response (port->string current-cond-port))<br> (close-input-port current-cond-port)<br> <br> (define data (xml->xexpr<br> ((eliminate-whitespace '(response))<br> (read-xml/element (open-input-string response)))))<br> <br> (define curr-location (se-path*/list '(display_location full) data))<br> (define curr-weather (se-path*/list '(current_observation weather) data))<br> (define curr-temp (se-path*/list '(current_observation temp_f) data))<br> (define curr-humidity (se-path*/list '(current_observation relative_humidity) data))<br> (define curr-wind (se-path*/list '(current_observation wind_string) data))<br> (define curr-feels-like (se-path*/list '(current_observation feelslike_f) data))<br> <br> <br> (define current-conditions <br> (list (list 'Location: curr-location) (list 'Conditions: curr-weather) <br> (list 'Temperature: curr-temp) (list 'Feels-Like: curr-feels-like)<br> (list 'Humidity: curr-humidity) (list 'Wind: curr-wind)))<br></div>
</div>
</body>
</html>