Jump to content

Recommended Posts

Posted

guys, i have a script that downloads an image and im trying to make it display that image on my GUI. here is a sample code, am i just doing something wrong? the image never displays. This is just an example to show how im using it. ive verified all my variables, it downloads the .jpg in the script dir but it just wont show it.

thanks,

anyday

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>

$Form1_1 = GUICreate("Form1", 1061, 789, 192, 124)
$artcover = GUICtrlCreatePic("", 664, 104, 300, 276, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))


GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUISetState(@SW_SHOW)
$picfilename = "test.jpg"
$source = "http://www.google.com/test.jpg"

$artdl = inetget($source, $picfilename)
GUICtrlSetImage($artcover, $picfilename)
Posted (edited)

guys, i have a script that downloads an image and im trying to make it display that image on my GUI. here is a sample code, am i just doing something wrong? the image never displays. This is just an example to show how im using it. ive verified all my variables, it downloads the .jpg in the script dir but it just wont show it.

thanks,

anyday

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>

$Form1_1 = GUICreate("Form1", 1061, 789, 192, 124)
$artcover = GUICtrlCreatePic("", 664, 104, 300, 276, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))


GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUISetState(@SW_SHOW)
$picfilename = "test.jpg"
$source = "http://www.google.com/test.jpg"

$artdl = inetget($source, $picfilename)
GUICtrlSetImage($artcover, $picfilename)

try this one:

$picfilename = @Scriptdir & "\test.jpg"

Edited by andygo
Posted

Ive tried yall's suggestions, let me post my whole code and see if yall can see why its not working?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\Darlene\Documents\mp3.kxf
$Form1_1 = GUICreate("Form1", 1061, 789, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 40, 1041, 729)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Download")
$song = GUICtrlCreateInput("", 12, 101, 217, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Song Name:", 12, 77, 86, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
$searchbtn = GUICtrlCreateButton("Search", 244, 101, 75, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView1 = GUICtrlCreateListView("ID|Name|Group", 12, 165, 952, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$download = GUICtrlCreateButton("Download", 342, 101, 75, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView2 = GUICtrlCreateListView("Time|Message", 12, 349, 954, 190)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$itunes = GUICtrlCreateButton("Add To iTunes", 444, 101, 91, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TabSheet2 = GUICtrlCreateTabItem("Wikipedia")
GUICtrlSetState(-1,$GUI_SHOW)
$Label2 = GUICtrlCreateLabel("Wikipedia Artist Lookup", 12, 77, 214, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
$artist = GUICtrlCreateInput("", 12, 101, 217, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$artistsearch = GUICtrlCreateButton("Search", 244, 101, 75, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView3 = GUICtrlCreateListView("Track #|Name|Time", 24, 384, 626, 374)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView4 = GUICtrlCreateListView("Album|URL", 24, 192, 466, 182)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel("Discography", 28, 157, 214, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
$getinfo = GUICtrlCreateButton("Get Info", 512, 200, 75, 25, $WS_GROUP)

GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

local $selartist
local $i = 1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $artistsearch
            _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView4))
            $namesearch = GUICtrlRead($artist)
            $wiki = _INetGetSource("http://www.wikipedia.com/w/index.php?search="&(StringReplace($namesearch, " ", "+")))
            _WikiFormat($wiki)
            ;ConsoleWrite(">"&$namesearch&"</a></div>")

        Case $getinfo
            _GetSelected()
            $sons = _INetGetSource($selartist[1])
            ;ConsoleWrite($sons)
            $file = fileopen("test.txt", 1)
            filewrite($file, $sons)
            _FormatSongs($sons)


    EndSwitch
WEnd


Func _WikiFormat($source)
    $start                                      = StringInStr($source, ">"&$namesearch&" discography</a>")
    $start                                      = StringInStr($source, "<ul>", 0, 1, $start)
    $end                                        = StringInStr($source, "</ul>", 0, 1, $start)
    $result                                     = StringMid($source, $start+5, $end-$start-5)
    $result                                     = StringReplace($result, "<li><i>", "")
    $result                                     = StringReplace($result, "</a></i>", "")
    $result                                     = StringReplace($result, "</li>", "")
    $result                                     = StringReplace($result, "<li>", "")
    $result                                     = StringReplace($result, "<i>", "")

    Do
    $count                                      = StringLen($result)
    $result2                                    = Stringleft($result, (stringinstr($result, @LF)))
    $urlstart                                   = StringinStr($result2, "href=""")
    $urlend                                     = StringInStr($result2, """", 0, 2, $urlstart)
    $url                                        = StringMid($result2, $urlstart+6, $urlend-$urlstart-6)
    $titlestart                                 = StringInStr($result2, """>")
    $titleend                                   = StringLen($result2)
    $title                                      = StringRight($result2, $titleend-$titlestart-1)
    GUICtrlCreateListViewItem                   ($title&"|"&"http://www.wikipedia.com"&$url, $listview4)
    $result = StringReplace($result, $result2, "")
    Until $count = 0
EndFunc

Func _GetSelected()
    $selected = GUICtrlRead(GUICtrlRead($listview4))
    $selartist = StringSplit($selected, "|", 2)
    Return $selartist

EndFunc

Func _FormatSongs($source)
    if StringInStr($source, "#</th>") >= 1  Then

    Else
        If StringInStr($source, "Track</th>") >= 1 Then

        Else
            If StringInStr($source, "#</td>") >= 1 Then

            Else
                If Stringinstr($source, "No.</th>") >= 1 Then
                    Do
                        $l = StringInStr($source, $i&".</td>")
                        If $l >= 1 Then
                        $namestart = stringinstr($source, """>", 0, 1, $l)
                        $nameend = StringInStr($source, "&#160",0, 1, $namestart)
                        $name = StringMid($source, $namestart+2, $nameend-$namestart-3)
                        $timestart = stringinstr($source, """>", 0, 1, $nameend)
                        $timeend = stringinstr($source, "</td>", 0, 1, $timestart)
                        $time = stringmid($source, $timestart+2, $timeend-$timestart-2)
                        GUICtrlCreateListViewItem($i&"|"&$name&"|"&$time, $listview3)
                        $i = $i + 1
                        Else
                        $l = 0
                        EndIf
                    until $l = 0

                        $picstart = stringinstr($source, "class=""image""")
                        $picend = stringinstr($source, """ width=", 0, 1, $picstart)
                        $source = stringmid($source, $picstart+31, $picend-$picstart-31)
                        $picfilename = Stringmid($source, Stringinstr($source, "/", 0, -1)+1, StringLen($source)-StringInStr($source, "/", 0, -1))
                        $artdl = inetget($source, $picfilename)
                        $artcover = GUICtrlCreatePic(@ScriptDir&"\"&$picfilename, 664, 104, 300, 276, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
                        GUISETState(@SW_Show)
                        consolewrite(@ScriptDir&"\"&$picfilename & @CRLF)

                        consolewrite($source & @CRLF & $picfilename)
                        ;ConsoleWrite($picurl)

                Else
                EndIf

            EndIf
        EndIf
    EndIf



EndFunc
Posted (edited)

**EDIT**

i tested this by adding a picture box on my form instead of inside of a tabsheet and the picture shows fine, so how do i get the pics to show up within the tabsheet?

**EDIT**

**2nd edit**

well i got it fixed, it was the pic style @WS_CLIPSIBLINGS that was keepin the pic from showing up on my tabsheet

thanks for all the help

************

is there a trick to adding a pic to a TabSheet? i can see the pic now but only a small portion of it and it is off of my tabsheet?

Edited by anyday

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
  • Recently Browsing   0 members

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