Jump to content

refresh input data in a label in a gui


Recommended Posts

Hallo, I want to refresh some data in a label of an gui i have put in before. The dates shold be added if you click on the add button, however it doesnt work, it only displays the first input, when i enter a second data it is not added to the second label and the first label returns 0

$best1a = ""
$best2a = ""
$best3a = ""
$best4a = ""
$best5a = ""

#include <GUIConstants.au3>

GUICreate("Pizza-Bestellung",250,200) ; will create a dialog box that when displayed is centered

$check1 = GUICtrlCreateinput ("",10,10, 100, 20)
$check2 = GUICtrlCreateinput ("1",120,10, 35, 20)
GUICtrlCreateUpdown ( $check2)

$hin = GUICtrlCreateButton ("Hinzufügen", 160, 10, 80, 20)

GUICtrlCreateLabel("Bestellung:",10,40)
$best1 = GUICtrlCreateLabel($best1a,15,60, 200, 12)
$best2 = GUICtrlCreateLabel($best2a,15,75, 200, 15)
$best3 = GUICtrlCreateLabel($best3a,15,95, 200, 15)
$best4 = GUICtrlCreateLabel($best4a,15,115, 200, 15)
$best5 = GUICtrlCreateLabel($best5a,15,135, 200, 15)

$abb = GUICtrlCreateButton ("Abbrechen", 70, 160, 80, 25)
$ok = GUICtrlCreateButton ("Ok", 160, 160, 80, 25)

GUISetState ()    ; will display an  dialog box with 1 checkbox

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
    
    Case $msg = $GUI_EVENT_CLOSE
            Exitloop
            

    Case $msg = $abb
            Exitloop


    Case $msg = $hin
        $check1 = GUICtrlRead($check1)
        $check2 = GUICtrlRead($check2)
        $best1a = GUICtrlRead($best1a)
        $best2a = GUICtrlRead($best2a)
        $best3a = GUICtrlRead($best3a)
        $best4a = GUICtrlRead($best4a)
        $best5a = GUICtrlRead($best5a)
    ;msgbox(0,"","- " & $best1a & " x " & $check1 & " x " & $check2)
            ;msgbox(0,"",$best1 & $best2 & $best3)
            if $best1a = "" then 
                $best1a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best1, $best1a )
            ;msgbox(0,"",@error)
            Else
            if $best2a = "" then 
                $best2a = "- " & $check2 & " x " & $check1  
                GUICtrlSetData ( $best2, $best2a )
            Else
            if $best3a = "" then 
                $best3a = "- " & $check2 & " x " & $check1  
                GUICtrlSetData ( $best3, $best3a )
            Else
            if $best4a = "" then 
                $best4a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best4, $best4a )
            Else
            if $best5a = "" then 
                $best5a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best5, $best5a )
            EndIf
            EndIf
        EndIf
    EndIf
EndIf

    Case $msg = $ok
              exitloop
       EndSelect
Wend

GUIDelete()

THX for help

Link to comment
Share on other sites

maybe like this

$best1a = ""
$best2a = ""
$best3a = ""
$best4a = ""
$best5a = ""

#include <GUIConstants.au3>

GUICreate("Pizza-Bestellung",250,200); will create a dialog box that when displayed is centered

$check1 = GUICtrlCreateinput ("",10,10, 100, 20)
$check2 = GUICtrlCreateinput ("1",120,10, 35, 20)
GUICtrlCreateUpdown ( $check2)

$hin = GUICtrlCreateButton ("Hinzufügen", 160, 10, 80, 20)

GUICtrlCreateLabel("Bestellung:",10,40)
$best1 = GUICtrlCreateLabel($best1a,15,60, 200, 12)
$best2 = GUICtrlCreateLabel($best2a,15,75, 200, 15)
$best3 = GUICtrlCreateLabel($best3a,15,95, 200, 15)
$best4 = GUICtrlCreateLabel($best4a,15,115, 200, 15)
$best5 = GUICtrlCreateLabel($best5a,15,135, 200, 15)

$abb = GUICtrlCreateButton ("Abbrechen", 70, 160, 80, 25)
$ok = GUICtrlCreateButton ("Ok", 160, 160, 80, 25)

GUISetState ()   ; will display an  dialog box with 1 checkbox


While 1
       $msg = GUIGetMsg()
       Select
    
    Case $msg = $GUI_EVENT_CLOSE
            Exitloop
            

    Case $msg = $abb
            Exitloop


    Case $msg = $hin
        $check1a = GUICtrlRead($check1)
        $check2a = GUICtrlRead($check2)
        $best1a = GUICtrlRead($best1)
        $best2a = GUICtrlRead($best2)
        $best3a = GUICtrlRead($best3)
        $best4a = GUICtrlRead($best4)
        $best5a = GUICtrlRead($best5)
   ;msgbox(0,"","- " & $best1a & " x " & $check1 & " x " & $check2)
           ;msgbox(0,"",$best1 & $best2 & $best3)
            if $best1a = "" then
                $best1b = "- " & $check2a & " x " & $check1a
                GUICtrlSetData ( $best1, $best1b )
           ;msgbox(0,"",@error)
            Elseif $best2a = "" then
                $best2b = "- " & $check2a & " x " & $check1a    
                GUICtrlSetData ( $best2, $best2b )
            Elseif $best3a = "" then
                $best3b = "- " & $check2a & " x " & $check1a    
                GUICtrlSetData ( $best3, $best3b )
            Elseif $best4a = "" then
                $best4b = "- " & $check2a & " x " & $check1a
                GUICtrlSetData ( $best4, $best4b )
            Elseif $best5a = "" then
                $best5b = "- " & $check2a & " x " & $check1a
                GUICtrlSetData ( $best5, $best5b )
            EndIf
  

    Case $msg = $ok
              exitloop
       EndSelect
Wend

GUIDelete()

8)

NEWHeader1.png

Link to comment
Share on other sites

Hallo, I want to refresh some data in a label of an gui i have put in before. The dates shold be added if you click on the add button, however it doesnt work, it only displays the first input, when i enter a second data it is not added to the second label and the first label returns 0

$best1a = ""
$best2a = ""
$best3a = ""
$best4a = ""
$best5a = ""

#include <GUIConstants.au3>

GUICreate("Pizza-Bestellung",250,200); will create a dialog box that when displayed is centered

$check1 = GUICtrlCreateinput ("",10,10, 100, 20)
$check2 = GUICtrlCreateinput ("1",120,10, 35, 20)
GUICtrlCreateUpdown ( $check2)

$hin = GUICtrlCreateButton ("Hinzufügen", 160, 10, 80, 20)

GUICtrlCreateLabel("Bestellung:",10,40)
$best1 = GUICtrlCreateLabel($best1a,15,60, 200, 12)
$best2 = GUICtrlCreateLabel($best2a,15,75, 200, 15)
$best3 = GUICtrlCreateLabel($best3a,15,95, 200, 15)
$best4 = GUICtrlCreateLabel($best4a,15,115, 200, 15)
$best5 = GUICtrlCreateLabel($best5a,15,135, 200, 15)

$abb = GUICtrlCreateButton ("Abbrechen", 70, 160, 80, 25)
$ok = GUICtrlCreateButton ("Ok", 160, 160, 80, 25)

GUISetState ()   ; will display an  dialog box with 1 checkbox

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
    
    Case $msg = $GUI_EVENT_CLOSE
            Exitloop
            

    Case $msg = $abb
            Exitloop
    Case $msg = $hin
        $check1 = GUICtrlRead($check1)
        $check2 = GUICtrlRead($check2)
        $best1a = GUICtrlRead($best1a)
        $best2a = GUICtrlRead($best2a)
        $best3a = GUICtrlRead($best3a)
        $best4a = GUICtrlRead($best4a)
        $best5a = GUICtrlRead($best5a)
;msgbox(0,"","- " & $best1a & " x " & $check1 & " x " & $check2)
        ;msgbox(0,"",$best1 & $best2 & $best3)
            if $best1a = "" then 
                $best1a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best1, $best1a )
        ;msgbox(0,"",@error)
            Else
            if $best2a = "" then 
                $best2a = "- " & $check2 & " x " & $check1  
                GUICtrlSetData ( $best2, $best2a )
            Else
            if $best3a = "" then 
                $best3a = "- " & $check2 & " x " & $check1  
                GUICtrlSetData ( $best3, $best3a )
            Else
            if $best4a = "" then 
                $best4a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best4, $best4a )
            Else
            if $best5a = "" then 
                $best5a = "- " & $check2 & " x " & $check1
                GUICtrlSetData ( $best5, $best5a )
            EndIf
            EndIf
        EndIf
    EndIf
EndIf

    Case $msg = $ok
              exitloop
       EndSelect
Wend

GUIDelete()

THX for help

I had an issue like this where labels were appearing to not update when passed valid data. The best that i could figure, the GUI was being refreshed, but not all of the labels were. I had a visible string in the labels when they were created, so when i updated them (or tried to) the labels were then showing as blank. I was able to see that data was being passed though, by evaluating the variables being passed, and the @error with msgbox's. In the end, with Gafrost's help i added a status bar to my gui to show the data. If your variables ARE being passed, and they do have good values, (both can be verified with just a msgbox right before the GUICtrlSetData() ) you may want to try something like that instead.
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...