|
Post by wbtcpip on Nov 13, 2023 2:39:13 GMT 1
Ciao GB Friends
do you think exists a way do display one weather widget in a GB32 form?
i would download the latest widget every hour or so and display it as image in a GB32 form or picture control.
do you think is it possible to convert that widgets to images?
thanks
Attachments:
|
|
|
Post by (X) on Nov 13, 2023 11:28:25 GMT 1
This gets the webpage html code and puts it in an edit box...
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23 Form Full frm1 = App.Name, 0, 0, 800, 600 Ocx TextBox ed1 = , 0, 0, frm1.ScaleWidth, frm1.ScaleHeight With ed1 .MultiLine = True .ScrollBars = 2 EndWith Try Dim xmlhttp As Object Set xmlhttp = CreateObject("MSXML2.XMLHTTP") Dim url$ = "https://www.weatherapi.com/weather/q/london-city-of-london-greater-london-united-kingdom-2801268" ' Replace "YOUR_API_ENDPOINT" with the actual API endpoint 'xmlhttp.Open "GET", "YOUR_API_ENDPOINT", False xmlhttp.Open "GET", url$, False xmlhttp.send ' Process the response (xmlhttp.responseText) ed1 = xmlhttp.responseText Set xmlhttp = Nothing Catch Trace Err$ EndCatch Do Sleep 50 DoEvents Loop Until frm1 Is Nothing Sub frm1_ReSize If !IsNothing(ed1) With ed1 .Left = 0 .Top = 0 .Width = frm1.ScaleWidth .Height = frm1.ScaleHeight EndWith EndIf EndSub
|
|
|
Post by wbtcpip on Nov 13, 2023 12:28:35 GMT 1
unfortunately it does nothing here
|
|
|
Post by (X) on Nov 13, 2023 13:07:34 GMT 1
This performs a live screen capture of the screen and what ever application window is visible. It does not get information from the internet, it's just a capture tool.
$Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx
LoadForm frm1 With frm1 .AutoRedraw = 1 .BackColor = 0 .ToolTipText = "Right Click && Drag to reposition Capture Area" EndWith
Do Sleep 50 P_ScreenCap DoEvents Loop Until frm1 Is Nothing
Proc P_ScreenCap Static Long msx, msy Local Long x, y Local Long hDC = Screen.GetDC If (MouseK == 2) msx = MouseSX msy = MouseSY EndIf If (msx == 0) BitBlt hDC, MouseSX, MouseSY, frm1.ScaleWidth, frm1.ScaleHeight, frm1.hDC2, 0, 0, SRCCOPY Else BitBlt hDC, msx, msy, frm1.ScaleWidth, frm1.ScaleHeight, frm1.hDC2, 0, 0, SRCCOPY EndIf frm1.Invalidate sb1.SimpleText = "(" & MouseSX & "," & MouseSY & ") (" & msx & "," & msy & ")" Screen.ReleaseDC EndProc
Sub frm1_ReSize
|
|
|
Post by (X) on Nov 13, 2023 13:27:24 GMT 1
unfortunately it does nothing here
I changed the code so you don't have to create a frm1 in the form designer... See changes in original post.
You should see the webpage contents such as this partial exerpt:
In theory one could parse this code and extract the information you want to display in GB32.
|
|
|
Post by wbtcpip on Nov 13, 2023 13:32:39 GMT 1
thank you, the problem is that i want a final image not the page html code. i want to show the weather image in my app by code.
|
|
|
Post by (X) on Nov 13, 2023 13:42:28 GMT 1
If weatherapi created a downloadable image and made it available (other than displaying it as an html document) then this would be trivial. You'd just have to download the image from a url to GB32.
I'm gonna look for info about web scraping application/utils...
|
|
|
Post by (X) on Nov 13, 2023 14:38:39 GMT 1
Its seems like MS WebView2 might be a solution to display HTML / The internet as part of and under control of an application...
DIM webView AS OBJECT webView = CreateObject("WebView2.CoreWebView2")
' Assume webView is the WebView2 control webView.Navigate("https://www.example.com")
' Assume webView is the WebView2 control webView.AddEvent("NavigationCompleted", @NavigationCompletedHandler)
|
|
|
Post by Roger Cabo on Nov 13, 2023 15:27:07 GMT 1
Do you want to do in D2D or in standard graphics code like Line, Box, Circle, etc?
you can define a Proc Like
Proc Draw_IconWeather(xpos%,ypos%, sun%, cloud%, rain%, degree%, size as double)
// here you draw the single icons with line, box and circle, text // a cloud has only 4 commands to draw // use defline for different line sizes EndProc
|
|
|
Post by Roger Cabo on Nov 13, 2023 16:09:49 GMT 1
Do you want to do in D2D or in standard graphics code like Line, Box, Circle, etc? ? I have understand that he wants to draw the UI of the weather board in gb32.. or? I think it's a bit quirky to open a web browser with the correct HTML site from GB32 and grab the image from the website by a desktop get dib function. But that works.. That's the easiest way to do.. :-) Otherwise he can draw a cloud, sun and rain and text with 6 or 7 graphic commands
|
|
|
Post by wbtcpip on Nov 13, 2023 20:35:40 GMT 1
Its seems like MS WebView2 might be a solution to display HTML / The internet as part of and under control of an application... DIM webView AS OBJECT webView = CreateObject("WebView2.CoreWebView2")
' Assume webView is the WebView2 control webView.Navigate("https://www.example.com")
' Assume webView is the WebView2 control webView.AddEvent("NavigationCompleted", @NavigationCompletedHandler)
Webview works under GB32? this sample don't work here! "Bad assignment error"
|
|
|
Post by wbtcpip on Nov 13, 2023 20:40:16 GMT 1
I have understand that he wants to draw the UI of the weather board in gb32.. or? I think it's a bit quirky to open a web browser with the correct HTML site from GB32 and grab the image from the website by a desktop get dib function. But that works.. That's the easiest way to do.. :-) Otherwise he can draw a cloud, sun and rain and text with 6 or 7 graphic commands yes i can redraw the widget by my self using icons and text but i was wondering if we can render this code in a form or generate a picture from it. webview would be good to render it but it do not work on gb32 and we don't have a minibrowser in our loved language
<div id="weatherapi-weather-widget-2"></div><script type='text/javascript' src='https://www.weatherapi.com/weather/widget.ashx?loc=2437359&wid=2&tu=1&div=weatherapi-weather-widget-2' async></script><noscript><a href="https://www.weatherapi.com/weather/q/istanbul-2437359" alt="Hour by hour Istanbul weather">10 day hour by hour Istanbul weather</a></noscript>
|
|
|
Post by (X) on Nov 13, 2023 21:40:21 GMT 1
I found a weather forecast site that offers a JSON file containing a nice chunk of weather forecast data for any city in the world.
Now, I am trying to figure out how to read a JSON file using GB32 after running in circles trying to get an API to do it for me. This seems like a good candidate for packing into a TreeView control.
{ "city": { "lang": "en", "cityName": "London", "cityLatitude": "51.504722000", "cityLongitude": "-0.131111000", "cityId": 32, "isCapital": true, "stationName": "London", "tourismURL": "", "tourismBoardName": "", "isDep": false, "timeZone": "+0000", "isDST": "N", "member": { "memId": 10, "memName": "United Kingdom of Great Britain and Northern Ireland", "shortMemName": "", "url": "www.metoffice.gov.uk", "orgName": "Met Office", "logo": "uk_logo.png", "ra": 6 }, "forecast": { "issueDate": "2023-11-13 12:00:00", "timeZone": "UTC", "forecastDay": [ { "forecastDate": "2023-11-13", "wxdesc": "", "weather": "Sunny Intervals", "minTemp": "", "maxTemp": "15", "minTempF": "", "maxTempF": "59", "weatherIcon": 2101 }, { "forecastDate": "2023-11-14", "wxdesc": "", "weather": "Cloudy", "minTemp": "11", "maxTemp": "13", "minTempF": "52", "maxTempF": "55", "weatherIcon": 2301 }, { "forecastDate": "2023-11-15", "wxdesc": "", "weather": "Sunny", "minTemp": "9", "maxTemp": "12", "minTempF": "48", "maxTempF": "54", "weatherIcon": 2402 }, { "forecastDate": "2023-11-16", "wxdesc": "", "weather": "Cloudy", "minTemp": "5", "maxTemp": "10", "minTempF": "41", "maxTempF": "50", "weatherIcon": 2301 }, { "forecastDate": "2023-11-17", "wxdesc": "", "weather": "Cloudy", "minTemp": "6", "maxTemp": "10", "minTempF": "43", "maxTempF": "50", "weatherIcon": 2301 } ] }, "climate": { "raintype": "Rainfall", "raindef": "1", "rainunit": "mm", "datab": 1981, "datae": 2010, "tempb": "", "tempe": "", "rdayb": "", "rdaye": "", "rainfallb": "", "rainfalle": "", "climatefromclino": "", "climateMonth": [ { "month": 1, "maxTemp": "8.1", "minTemp": "3.1", "meanTemp": null, "maxTempF": "46.6", "minTempF": "37.6", "meanTempF": null, "raindays": "11.4", "rainfall": "41.6", "climateFromMemDate": "2001-05-15" }, { "month": 2, "maxTemp": "8.6", "minTemp": "2.7", "meanTemp": null, "maxTempF": "47.5", "minTempF": "36.9", "meanTempF": null, "raindays": "8.5", "rainfall": "36.3", "climateFromMemDate": "2001-05-15" }, { "month": 3, "maxTemp": "11.6", "minTemp": "4.6", "meanTemp": null, "maxTempF": "52.9", "minTempF": "40.3", "meanTempF": null, "raindays": "9.8", "rainfall": "40.3", "climateFromMemDate": "2001-05-15" }, { "month": 4, "maxTemp": "14.6", "minTemp": "5.9", "meanTemp": null, "maxTempF": "58.3", "minTempF": "42.6", "meanTempF": null, "raindays": "9.0", "rainfall": "40.1", "climateFromMemDate": "2001-05-15" }, { "month": 5, "maxTemp": "18.1", "minTemp": "8.9", "meanTemp": null, "maxTempF": "64.6", "minTempF": "48.0", "meanTempF": null, "raindays": "9.2", "rainfall": "44.9", "climateFromMemDate": "2001-05-15" }, { "month": 6, "maxTemp": "21.0", "minTemp": "11.8", "meanTemp": null, "maxTempF": "69.8", "minTempF": "53.2", "meanTempF": null, "raindays": "7.4", "rainfall": "47.4", "climateFromMemDate": "2001-05-15" }, { "month": 7, "maxTemp": "23.4", "minTemp": "13.7", "meanTemp": null, "maxTempF": "74.1", "minTempF": "56.7", "meanTempF": null, "raindays": "6.3", "rainfall": "34.6", "climateFromMemDate": "2001-05-15" }, { "month": 8, "maxTemp": "23.1", "minTemp": "13.8", "meanTemp": null, "maxTempF": "73.6", "minTempF": "56.8", "meanTempF": null, "raindays": "8.1", "rainfall": "54.3", "climateFromMemDate": "2001-05-15" }, { "month": 9, "maxTemp": "20.0", "minTemp": "11.4", "meanTemp": null, "maxTempF": "68.0", "minTempF": "52.5", "meanTempF": null, "raindays": "8.6", "rainfall": "51.0", "climateFromMemDate": "2001-05-15" }, { "month": 10, "maxTemp": "15.5", "minTemp": "8.8", "meanTemp": null, "maxTempF": "59.9", "minTempF": "47.8", "meanTempF": null, "raindays": "10.9", "rainfall": "61.1", "climateFromMemDate": "2001-05-15" }, { "month": 11, "maxTemp": "11.3", "minTemp": "5.8", "meanTemp": null, "maxTempF": "52.3", "minTempF": "42.4", "meanTempF": null, "raindays": "10.9", "rainfall": "57.5", "climateFromMemDate": "2001-05-15" }, { "month": 12, "maxTemp": "8.4", "minTemp": "3.4", "meanTemp": null, "maxTempF": "47.1", "minTempF": "38.1", "meanTempF": null, "raindays": "9.5", "rainfall": "48.4", "climateFromMemDate": "2001-05-15" } ] } } }
|
|
|
Post by wbtcpip on Nov 14, 2023 15:49:37 GMT 1
ok currently me i'm using this www.weatherapi.com/ and i'm parsing the xml data and display it with gb32 on my tv channel wz3.newradio.it:8080/public/9052 currently i'm only displaying current observations but i want to show also weather for next days. if you can parse with json let me know because parsing xml is a little hard for me.
|
|
|
Post by dragonjim on Nov 15, 2023 13:21:57 GMT 1
Use the Set command as in Set webView = CreateObject("WebView2.CoreWebView2")
The other two lines need to be prefaced with Void or ~.
Finally, I think the method webview.AddEventListener may work better as this one will not.
It is possible that Webview2 may not work with GB32 as it communicates using Classes which GB32 does not support.
|
|
|
Post by (X) on Nov 20, 2023 5:26:18 GMT 1
I have been working out the bugs of reading a JSON file using GB32 and it's looking good!
I will test further and hopefully post my code soon.
|
|
|
Post by wbtcpip on Nov 20, 2023 8:21:40 GMT 1
very good! thank you
|
|
|
Post by (X) on Nov 21, 2023 0:19:03 GMT 1
I am starting to use a treeview to display the data. I don't know which I like better: "Chewing glass" or "Working with Treeview".
|
|
|
Post by (X) on Nov 21, 2023 19:34:01 GMT 1
Take a look at this new post for a "Demo JSON Parser.G32"
Now that we can load Weather Report stored as a JSON file and managed to store it in a Hash Table, it should be possible to build a representational graphic of the included Weather data.
|
|
|
Post by Roger Cabo on Nov 22, 2023 22:06:22 GMT 1
I see, it's not a graphic.. the table contains a background graphic only.. The rest is text and a lot icons..
|
|
|
Post by Roger Cabo on Nov 23, 2023 0:25:28 GMT 1
Here is a small sample that draws a cloud. Place the cloud anywhere with x,y and zoom it. 1= original , 2 = double The zoom works for enlargement but not for resizing below 1.0 for any reason, it's a bug and will have a look for tomorrow. wireframe=true will display as wireframe to uncover the circle positions much more easy.. That's fun to me.. $Library "gfawinx" $Library "UpdateRT" UpdateRuntime ' Patches GfaWin23.Ocx
Dim Wireframe% = True Color RGB(30, 60, 80) PBox 0, 0, _X, _Y
Draw_Cloud(0, 0, 1.0) // Enlarge with > 1.0 Stop
Proc Draw_Cloud(x%, y%, zoom#) Dim border% = 6 Dim _rgb% = RGB(128, 128, 128) cloudCircle(x, y, 40, 78, 13, _rgb%, zoom#) cloudCircle(x, y, 56, 70, 20, _rgb%, zoom#) cloudCircle(x, y, 80, 60, 25, _rgb%, zoom#) cloudCircle(x, y, 100, 74, 17, _rgb%, zoom#) cloudBox(x, y, 40, 74, 100 - 40, 17, _rgb%, zoom#) _rgb% = RGB(240, 240, 240) cloudCircle(x, y, 40, 78, 13 - border%, _rgb%, zoom#) cloudCircle(x, y, 56, 70, 20 - border%, _rgb%, zoom#) cloudCircle(x, y, 80, 60, 25 - border%, _rgb%, zoom#) cloudCircle(x, y, 100, 74, 17 - border%, _rgb%, zoom#) cloudBox(x%, y%, 40, 74, 100 - 40, 17 - border%, _rgb%, zoom#) EndProc
Proc cloudCircle(x%, y%, offsX%, offsY%, size1%, _rgb%, zoom#) Color _rgb% offsX *= zoom# offsY *= zoom# If Wireframe% Circle x + offsX, y + offsY, size1 * zoom Else PCircle x + offsX, y + offsY, size1 * zoom EndIf EndProc
Proc cloudBox(x%, y%, offsX%, offsY%, size1%, size2%, _rgb%, zoom#)
// there is anything wrong with zoom below 1.0
Color _rgb% Dim dx%, dy%, dx1%, dy1% dx = offsX * zoom dy = offsY * zoom dx1 = dx + (size1 * zoom) dy1 = dy + (size2 * zoom) Color _rgb% If Wireframe% Box x + dx, y + dy, x + dx1, y + dy1 Else PBox x + dx, y + dy, x + dx1, y + dy1 EndIf EndProc
|
|
|
Post by Roger Cabo on Nov 23, 2023 19:57:11 GMT 1
Another Update that draws a cloud, sun with beams and rain Based on the small size the normal graphics is a bit edgy. Later its possible the call a weather with all properties Sun only Could white only Could grey only Rain only Mist only Or in all combinations I would love to get another country and city info as well, anyhow. from the website.. or any other.. I think that a bit tricky.
|
|
|
Post by (X) on Nov 23, 2023 20:55:32 GMT 1
|
|
|
Post by (X) on Nov 23, 2023 21:39:57 GMT 1
Here is a simplified demo...
|
|