[ Visual Components] TextGadget and Progressbar cannot change state

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

[ Visual Components] TextGadget and Progressbar cannot change state

Post by skinkairewalker »

hello !
i am using Macbook Air BigSur, i am trying this script, but dont works fine like windows :

Code: Select all

If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget       (3,  10, 10, 250,  20, "ProgressBar Standard  (50/100)", #PB_Text_Center)
    ProgressBarGadget(0,  10, 30, 250,  30, 0, 100)
       ;  set 1st progressbar (ID = 0) to 50 of 100
    TextGadget       (4,  10, 70, 250,  20, "ProgressBar Smooth  (50/200)", #PB_Text_Center)
    ProgressBarGadget(1,  10, 90, 250,  30, 0, 200, #PB_ProgressBar_Smooth)
   ; SetGadgetState   (1, 50)   ;  set 2nd progressbar (ID = 1) to 50 of 200
    TextGadget       (5, 100,135, 200,  20, "ProgressBar Vertical  (100/300)", #PB_Text_Right)
    ProgressBarGadget(2, 270, 10,  30, 120, 0, 300, #PB_ProgressBar_Vertical)
    ;SetGadgetState   (2, 100)   ; set 3rd progressbar (ID = 2) to 100 of 300
    Repeat 
      
      For i = 0 To 100
        
        SetGadgetState   (0, i)
   
      Next i   
      
      For i = 0 To 100
        
        SetGadgetState   (1, i)
      
      Next i  
      
      For i = 0 To 100
        
        SetGadgetState   (2, i)
        
      Next i  
      
      Delay(1000)  
      
    Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf
  
  
most of the time it even crashes and stops the application when I run it , regarding TextGadget, it is not being changed when I need to "update" what is written
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: [ Visual Components] TextGadget and Progressbar cannot change state

Post by mk-soft »

No Delay() may be used in an event loop. Otherwise, the events cannot be processed and an overflow occurs in the event loop and the programme no longer reacts. In your code you create hundreds of events that are not processed.

This does not work at all.

Code: Select all

If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget       (3,  10, 10, 250,  20, "ProgressBar Standard  (50/100)", #PB_Text_Center)
    ProgressBarGadget(0,  10, 30, 250,  30, 0, 100)
       ;  set 1st progressbar (ID = 0) to 50 of 100
    TextGadget       (4,  10, 70, 250,  20, "ProgressBar Smooth  (50/200)", #PB_Text_Center)
    ProgressBarGadget(1,  10, 90, 250,  30, 0, 200, #PB_ProgressBar_Smooth)
   ; SetGadgetState   (1, 50)   ;  set 2nd progressbar (ID = 1) to 50 of 200
    TextGadget       (5, 100,135, 200,  20, "ProgressBar Vertical  (100/300)", #PB_Text_Right)
    ProgressBarGadget(2, 270, 10,  30, 120, 0, 300, #PB_ProgressBar_Vertical)
    ;SetGadgetState   (2, 100)   ; set 3rd progressbar (ID = 2) to 100 of 300
    
    AddWindowTimer(0, 1, 1000)
    
    event_cnt = 0
    Repeat 
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Timer
          For i = 0 To 100
            
            SetGadgetState   (0, i)
       
          Next i   
          
          For i = 0 To 100
            
            SetGadgetState   (1, i)
          
          Next i  
          
          For i = 0 To 100
            
            SetGadgetState   (2, i)
            
          Next i  
      EndSelect
      event_cnt + 1
      SetWindowTitle(0, "Events: " + event_cnt)
    ForEver 
  EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: [ Visual Components] TextGadget and Progressbar cannot change state

Post by collectordave »

Just trying to understand what is wanted.

It seems you want the progressbars to increase by 1 every second. There is also some mention of a text gadget updating.

Threw this together:

Code: Select all

Global iLoop.i

If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget       (3,  10, 10, 250,  20, "ProgressBar Standard  (0/100)", #PB_Text_Center)
    ProgressBarGadget(1,  10, 30, 250,  30, 0, 100)

    
    AddWindowTimer(0, 1, 1000)

    Repeat 
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Timer

          iLoop = iLoop + 1

          SetGadgetState   (1, iLoop)
          
          SetGadgetText(3,Str(Iloop))

      EndSelect

    ForEver 
  EndIf
  
  End
  
  
which seems to work.

just no vertical progressbar on the MAC.

There is no smooth progressbar on the MAC it says in the help
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply