Jump to content

Reload pic within a tab


Recommended Posts

Hey,

For some reason, the GUI doesn't want to reload a picture. Here's the scenario. I used the tabbed interface, and in one tab exists a weather checker. Everytime the weather information gets pulled up, it successfully places weather information into the labels, such as degrees and humidity. Also, I use INetGet to retrieve a picture displaying the weather (ex: a sun, clouds, whatever). The problem is that the image doesn't refresh until the window is minimized, and when the window returns, the image is visible in ALL tabs, not just the weather tab.

;--- WEATHER TAB

$weatherpic = GuiCtrlCreatePic ("sky.gif",320,100,40,40) ;OK if doesn't exist

;--- FUNCTION

$pic = "http://www.google.com/images/weather/mostly_sunny.gif"

InetGet($pic,"sky.gif", 1, 1)

I tried using GuiCtrlSetGraphic ($weatherpic, $GUI_GR_REFRESH) in the function after the new image loaded, but it doesn't work...

Any ideas? :(

Edited by logikal16
Link to comment
Share on other sites

Hey,

For some reason, the GUI doesn't want to reload a picture. Here's the scenario. I used the tabbed interface, and in one tab exists a weather checker. Everytime the weather information gets pulled up, it successfully places weather information into the labels, such as degrees and humidity. Also, I use INetGet to retrieve a picture displaying the weather (ex: a sun, clouds, whatever). The problem is that the image doesn't refresh until the window is minimized, and when the window returns, the image is visible in ALL tabs, not just the weather tab.

;--- WEATHER TAB

$weatherpic = GuiCtrlCreatePic ("sky.gif",320,100,40,40) ;OK if doesn't exist

;--- FUNCTION

$pic = "http://www.google.com/images/weather/mostly_sunny.gif"

InetGet($pic,"sky.gif", 1, 1)

I tried using GuiCtrlSetGraphic ($weatherpic, $GUI_GR_REFRESH) in the function after the new image loaded, but it doesn't work...

Any ideas?  :(

<{POST_SNAPBACK}>

Can you post a simplify script reproducing the behaviour you described?

Thanks :(

Link to comment
Share on other sites

Here's the script, thanks for wanting to help...

Tab:

#include <GuiConstants.au3>

TraySetIcon ("shell32.dll",47)
GuiCreate ("Matt's Automate-Me", 400, 380)
GuiSetFont (9,400,1,"Georgia")
GuiSetIcon ("shell32.dll",47)

;---------------> INITIALIZE

$version = "0.1b"
GuiCtrlCreatePic ("automate.gif",0,0,400,50)
$statusMsg = GuiCtrlCreateLabel ("Ready",10,355,200)

;---------------> MAIN TAB

GuiCtrlCreateTab (10, 60, 380, 280)

;---------------> WEATHER TAB
GuiCtrlCreateTabItem ("Somethingelse")
GuiCtrlCreateTabItem ("Weather")
$weatherpic = GuiCtrlCreatePic ("sky.gif",320,100,40,40)
GuiCtrlCreateLabel ("Your Local Weather!",20,100)
$z = IniRead ("user.ini","Weather","Zip","default")
$zipcode = GuiCtrlCreateInput ($z,20,120,60,20)
$getweather = GuiCtrlCreateButton ( "Go",100,120,40,20)

GuiSetFont (12,600,1,"Georgia")
$cond1 = GuiCtrlCreateLabel ("",100,180,200,20,$SS_CENTER)
GuiSetFont (9,400,1,"Georgia")
$cond2 = GuiCtrlCreateLabel ("",100,210,200,20,$SS_CENTER)
$cond3 = GuiCtrlCreateLabel ("",100,240,200,20,$SS_CENTER)
$cond4 = GuiCtrlCreateLabel ("",100,270,200,20,$SS_CENTER)
$cond5 = GuiCtrlCreateLabel ("",100,300,200,20,$SS_CENTER)

Loop: (all USER.INI does is retrieve a stored zip code)

GuiSetState ()
While 1
    $msg = GuiGetMsg ()
    
    Select
    
       Case $msg = $Gui_EVENT_CLOSE
          ExitLoop
          
       Case $msg = $getweather
          If GuiCtrlRead ($getWeather) == "" Then
             MsgBox (0,"Error!","Zip Code?")       
          Else
             IniWrite ("user.ini","Weather","Zip",GuiCtrlRead ($zipcode))
             getWeather()
          EndIf
    EndSelect
WEnd
Exit

Function:

;---------------> GET WEATHER

Func getWeather ()
   
   GuiCtrlSetData ($cond1, "")
   GuiCtrlSetData ($cond2, "")
   GuiCtrlSetData ($cond3, "")
   GuiCtrlSetData ($cond4, "")
   GuiCtrlSetData ($cond5, "")
   GuiCtrlSetData ($statusMsg,"Processing request")
   InetGet("http://www.google.com/search?q=weather+" & GuiCtrlRead ($zipcode), "weather.htm", 1, 1)
   
   $contents = ""

   While @InetGetActive
      Sleep(50)
   Wend

   $file = FileOpen ("weather.htm", 0)

   While 1
      $contents = $contents & FileRead ($file, 1000)
      If @error = -1 Then ExitLoop
   Wend
   
  ; CITY
   
   $invalid = 0

   While StringLeft ($contents, 22) <> "<b>Weather</b> for <b>"
      $contents = StringTrimLeft ($contents, 1)
      $invalid = $invalid + 1
      If $invalid = 5000 Then
         $invalid = 0
         GuiCtrlSetData ($cond1, "Invalid Zip Code?")
         ExitLoop
      EndIf
   Wend
   
   If $invalid <> 0 Then
  
   $contents = StringTrimLeft ($contents, 22)
   $letters = ""
  
   While StringLeft ($contents, 4) <> "</b>"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend
  
   $contents = StringTrimLeft ($contents, 4)
   $city = $letters
   
  ; TEMPERATURE
   
   While StringLeft ($contents, 17) <> "<font size=+1><b>"
      $contents = StringTrimLeft ($contents, 1)
   Wend
   
   $contents = StringTrimLeft ($contents, 17)
   $letters = ""
  
   While StringLeft ($contents, 4) <> "&deg"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend   
   
   $contents = StringTrimLeft ($contents, 4)
   $temperature = $letters & " °"
   
  ; CONDITION
   
   While StringLeft ($contents, 17) <> "<font size=-1><b>"
      $contents = StringTrimLeft ($contents, 1)
   Wend
   
   $contents = StringTrimLeft ($contents, 17)
   $letters = ""
  
   While StringLeft ($contents, 8) <> "</b><br>"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend   
   
   $contents = StringTrimLeft ($contents, 8)
   $condition = $letters
   
  ; WIND
   
   $letters = ""
  
   While StringLeft ($contents, 4) <> "<br>"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend   
   
   $contents = StringTrimLeft ($contents, 4)
   $wind = $letters
   
  ; HUMIDITY
   
   $letters = ""
  
   While StringLeft ($contents, 7) <> "</font>"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend   
   
   $contents = StringTrimLeft ($contents, 7)
   $humidity = $letters    
   
  ; IMAGE LINK
   
   While StringLeft ($contents, 4) <> "src="
      $contents = StringTrimLeft ($contents, 1)
   Wend
  
   $contents = StringTrimLeft ($contents, 5)
   $letters = ""
  
   While StringLeft ($contents, 5) <> " alt="
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
   Wend
   
   $pic = "http://www.google.com" & StringTrimRight ($letters, 1)
   $contents = ""
   
  ; PUTTING IT ALL TOGETHER
   
   GuiCtrlSetData ($cond1, $city)
   GuiCtrlSetData ($cond2, $temperature)
   GuiCtrlSetData ($cond3, $condition)
   GuiCtrlSetData ($cond4, $wind)
   GuiCtrlSetData ($cond5, $humidity)
   
   InetGet($pic,"sky.gif", 1, 1)
   
   While @InetGetActive
      Sleep(50)
   Wend
   
   GuiCtrlSetGraphic ($weatherpic, $GUI_GR_REFRESH)
   GuiCtrlCreatePic ("sky.gif",320,100,40,40)
   
   EndIf

   GuiCtrlSetData ($statusMsg,"Ready")
   
EndFunc

Type in a zip code, such as 10001, and after it loads (it takes a few seconds), click the other tab and you'll notice that the picture is only visible upon refresh, and it it visible on ALL tabs (and isn't supposed to be) :(

Edited by logikal16
Link to comment
Share on other sites

anyone?

<{POST_SNAPBACK}>

Your problem come from the fact that after retrieving the image you create a new picture which is not on the tab but behind. you must create the picture as you did with a first image and update it with GUICtrlsetImage
InetGet($pic,"sky.gif", 1, 1)
   
   While @InetGetActive
      Sleep(50)
   Wend
   
   GuiCtrlSetImage($weatherpic,"sky.gif")

:(

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...