Jump to content



Photo

GUICtrlCreatePic Issues

GUI

  • Please log in to reply
15 replies to this topic

#1 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 18 February 2012 - 03:09 PM

Right, I've been racking my brain for a little while about this now, I've created a GUI sample for a design project in uni, however I can't get the pic function to work. We are designing a screen that will show time, date and some events etc. The code is below, and its the two GUICtrlCreatePic function calls that are the issue. They don't do anything, at all!

AutoIt         
#cs This is a script to run and display a GUI for EG-M62 group project It will call a window that will show the funtionality desired for the PC interaction of our product #ce #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $today= @YEAR & "/" & @MON & "/" & @MDAY buildGUI() while 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE   ExitLoop Case $msg = $close   $close_response = MsgBox(1,"Warning","Close without saving?")   Select   Case $close_response = 1    ExitLoop   EndSelect Case $msg = $button   progress("Saving")   $ok_response = MsgBox(64,"Complete", "Please reinsert USB into the base of the light")   Select   Case $ok_response = 1    ExitLoop   EndSelect Case $msg = $fact_reset   MsgBox(48,"Warning","Pressing ok will reset all values to default, and erase any stored events")   progress("Resetting all data")   MsgBox(64,"Completed","Reset completed") Case $msg = $update   MsgBox(64,"Update","About to update the calendar files")   progress("Updating; please wait") Case $msg = $exitfilemenu   $close_response = MsgBox(1,"Warning","Close without saving?")   Select   Case $close_response = 1    ExitLoop   EndSelect Case $msg = $manualedit   Run("notepad.exe") Case $msg = $softupdate   progress("Updating Software") Case $msg = $aboutdisp   MsgBox(64,"About","LiteTawe Configuration Software; Version 0.1 BETA") Case $msg = $saveevent   MsgBox(64,"Success","Event Saved") EndSelect   WEnd func buildGUI() Global $button, $close, $fact_reset, $update, $exitfilemenu, $manualedit, $softupdate, $aboutdisp, $selecteddate, $eventname, $iconselect, $saveevent $m=700 $n=600 GUICreate("Display Control",$m,$n) GUISetState(@SW_SHOW) $filemenu = GUICtrlCreateMenu("&File") $advancedmenu = GUICtrlCreateMenu("&Advanced") $aboutmenu = GUICtrlCreateMenu("&About") $exitfilemenu = GUICtrlCreateMenuItem("Exit", $filemenu) $manualedit = GUICtrlCreateMenuItem("Manual Edit",$advancedmenu) $softupdate = GUICtrlCreateMenuItem("Update Software",$aboutmenu) $aboutdisp = GUICtrlCreateMenuItem("About",$aboutmenu)   $button = GUICtrlCreateButton("Ok", $m-166, $n-80, 75, 23) $close = GUICtrlCreateButton("Close", $m-85, $n-80, 75, 23) $fact_reset = GUICtrlCreateButton("Factory Reset", $m-85,$n-50,75,23) $update = GUICtrlCreateButton("Update", $m-166,$n-50,75,23) GUICtrlCreateLabel("Clock format set-up", $m-136,10) $12hour = GUICtrlCreateRadio("12 Hour",$m-126,30) $24hour = GUICtrlCreateRadio("24 Hour",$m-126,50) $digital = GUICtrlCreateCheckbox("Digital",$m-126,70) $analogue = GUICtrlCreateCheckbox("Analogue",$m-126,90) GUICtrlCreateLabel("Add events to calendar",10,10) $selecteddate = GUICtrlCreateMonthCal($today,10,30,230,165) $eventname = GUICtrlCreateInput("",250,40,250,20) GUICtrlCreateLabel("Event Name",260,20,100,20) GUICtrlCreateLabel("Choose Icon",260,70,100,20)   $iconselect = GUICtrlCreateButton("...",270,90,35,23) $annual = GUICtrlCreateCheckbox("Annual Event",315,90) $saveevent = GUICtrlCreateButton("Save Event",315,120,75,23) GUICtrlSetState($digital,$GUI_CHECKED) GUICtrlSetState($annual,$GUI_CHECKED) GUICtrlSetState($12hour,$GUI_CHECKED) GUICtrlCreatePic(@WorkingDir & "...\GUI\Screen.jpg",10,270,100,100) GUICtrlCreatePic(@WorkingDir & "...\GUI\Info.jpg",$m-110,$n-113,100,100) EndFunc func progress($textstring) ProgressOn("Progress", $textstring, "Working...") For $i = 0 To 100 ProgressSet($i) Sleep(5) Next ProgressSet(100, "Done!") Sleep(500) ProgressOff() EndFunc

Self confessed noob...







#2 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,750 posts

Posted 18 February 2012 - 04:46 PM

adz89,

Are you sure you have a valid path in those 2 statements? @WorkingDir defaults to the script folder and does not have a final "\" - so your path is currently "Script_Folder...\GUI\Info.jpg". Does not look very likely to work to me. ;)

When I put a valid path in those lines I get the images displayed - try doing the same. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#3 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,493 posts

Posted 19 February 2012 - 07:39 AM

@adz89
Why are you using @WorkingDir anyway? Do you know what a working directory is? You probably want @ScriptDir

#4 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 19 February 2012 - 09:38 PM

@adz89
Why are you using @WorkingDir anyway? Do you know what a working directory is? You probably want @ScriptDir

Well I thought that would have been the way to go about it, I've come from a MATLAB programming background, so I'm having a bit of difficulty trying to get the syntax right.

I've adjusted the script to now read
 GUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100) GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100)


but it still doesn't work...

Edited by adz89, 19 February 2012 - 10:02 PM.

Self confessed noob...

#5 AlmarM

AlmarM

    Programming my way.

  • Active Members
  • PipPipPipPipPipPip
  • 1,642 posts

Posted 20 February 2012 - 08:52 AM

The only thing I can say about this is, are you sure those are valid paths?

@ScriptDir returns the path your AU3 script is ran from.

#6 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 20 February 2012 - 04:31 PM

The only thing I can say about this is, are you sure those are valid paths?

@ScriptDir returns the path your AU3 script is ran from.


Well I've created the GUI folder within the folder that the script is, and of course the correct file name/extension
Self confessed noob...

#7 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,750 posts

Posted 20 February 2012 - 04:35 PM

adz89,

Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. :)

M23
  • adz89 likes this
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#8 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 20 February 2012 - 04:44 PM

adz89,

Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. :)

M23

Well I added this;
$check = FileExists(@ScriptDir & "GUIScreen.jpg") If $check = 1 Then MsgBox(0,"Success","File Exists") ElseIf $check = 0 Then MsgBox(0,"Fail","File not found") EndIf


and it said that the file exists.
Self confessed noob...

#9 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,750 posts

Posted 20 February 2012 - 04:47 PM

adz89,

And yet using those same strings with GUICtrlCreatePic fails? :)

Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. ;)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#10 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 20 February 2012 - 05:06 PM

adz89,

And yet using those same strings with GUICtrlCreatePic fails? :)

Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. ;)

M23


Ok will do, I'll let you know in due course
Self confessed noob...

#11 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 20 February 2012 - 09:17 PM

Ok, well still nothing happening...

Here is the code I used;

#include <GUIConstantsEx.au3> buildGUI() while 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE   ExitLoop EndSelect WEnd func buildGUI() $m=700 $n=600 GUICreate("Display Control",$m,$n) GUISetState(@SW_SHOW) GUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100) GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100) EndFunc

Self confessed noob...

#12 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,750 posts

Posted 20 February 2012 - 09:29 PM

adz89,

I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. :)

Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? ;)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#13 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 21 February 2012 - 01:53 PM

adz89,

I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. :)

Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? ;)

M23


Well I'm out at the moment, but I'll try other images later, but the images can be open in picture viewer, and are both .jpg's...

I'll let you know how it goes with other images.
Self confessed noob...

#14 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 21 February 2012 - 03:18 PM

Ok, I got it working, not sure what the problem was though. I renamed the non-working pic from screen to disp_ex and left it as a jpg, and resaved the jpg file to be a bmp...

All working now though!

Thanks for the help guys, if anyone's interested I'll post the working, final script later!
Self confessed noob...

#15 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,750 posts

Posted 21 February 2012 - 04:31 PM

adz89,

Glad you got it working despite my ineffective help. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
RecFileListToArray- An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items

#16 adz89

adz89

    Seeker

  • Active Members
  • 45 posts

Posted 21 February 2012 - 09:29 PM

adz89,

Glad you got it working despite my ineffective help. ;)

M23


It was the help that was ineffective, it was my programming skills! :)
Self confessed noob...





Also tagged with one or more of these keywords: GUI

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users