2 Pi Qs

Why would this return the version number in a Raspberry PI console application:
mWriteLCD(“rebooter v” + str(app.Version))
And this not return a version number in a Raspberry PI GUI application:
Window1.Title = “rebooter v” + str(app.Version)

In the console app I get the Major and Minor Version numbers as expected (rebooter v1.5). In the GUI it just says rebooter v

Also I have a push button that I need to change the caption once pressed. The code it runs takes a while to execute so I’d like to have it change from “Check Now” to “Checking” so the user will know it’s working. No matter where I put the pbCheckNow.Caption code I never see it change. I have set properties, added app.DoEvents code to no avail.

I hope someone has a a solution to my vexation!

Look in the Shared build settings at the Short version. That’s what App.Version is set to.

Thanks Greg! I didn’t see the second Version text box below the Auto Increment (slider?). I must have found it in the console app! Works great now!

I must say the remote debugger is a wonderful thing! Saves so much time AND allows remote debugging just like it’s name. I had just been using it to test the app but I thought, why not put a breakpoint in the slow method and see if the push button caption ever changes?

So I did that. Even though the slow method says at the top:
pbCheckNow.Caption = “checking”
app.DoEvents
and at the bottom:
pbCheckNow.Caption = “Check Now”
app.DoEvents
the caption never changes.

I had thought maybe the Allow Auto Deactivate Appearance selection might be causing a problem but it appears to not have an effect.

Since this is running on a tiny LCD touchscreen screen it would be nice to let a user know they had pressed the button. It takes a while for nmap to find out if DHCP is working so the method runtime is about 10 seconds and we know how impatient people without Internet can be.

Any excellent ideas?

put the code in a thread. instead of directly setting captions - set some string variables defined for the window. Set up the timer which will run every 1/2 seconds and will copy texts from string variables to objects’ captions.

Thanks Pawel!
Moving that method to a thread is a good idea.

All,
I have been changing captions on buttons for over 20 years using code like I posted. Not to be regressive but when something this simple doesn’t work I consider it broken.

As a test I created a simple project with a window, a push button and a method. The push button calls the method that contains:

PushButton1.Caption = “HERE!”
app.DoEvents
PushButton1.Caption = “THERE!”
app.DoEvents

The results when run on a MacBook in the debugger with a breakpoint set on the first line in the method are as expected, HERE! then THERE!. On a Paspberry Pi only THERE! appears when the button is pressed. The HERE! caption change never appears.

Interestingly this does work:
PushButton1.Caption = “HERE!”
app.DoEvents
app.DoEvents
PushButton1.Caption = “THERE!”

It solves my problem, inelegantly, but it works. Yes the two app.DoEvents are needed after the first caption statement but the last one isn’t.

Use “App.DoEvents(10)”

That will sort this.

I tried that previously, no joy.

I stumbled across the 2 X app.DoEvents by accident when I had this:

PushButton1.Caption = “HERE!”
app.DoEvents
app.DoEvents(5000)
PushButton1.Caption = “THERE!”

to get a delay. When HERE! appeared I started trying permutations and the 2 X app.DoEvents works as well as the second app.DoEvents(any number here).

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.