Desktop.Open() question

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Desktop.Open() question

Post by Diverod »

Seems I don't understand the proper usage for this. When I try the below

Code: Select all

Public Sub Button1_Click()

  Desktop.Open("https://startpage.com/", True)

End
I get nothing.
If I put https://startpage.com/ as the text of a UrlLabel and click on it, it functions properly.
I did check my Components and noticed that gb.desktop is only partially green. (Is that significant?)

I've tried throwing peanut butter at the wall for 2 days and can't get anything to stick! I must be doing something wrong. :?:
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Desktop.Open() question

Post by BruceSteers »

It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open
If at first you don't succeed , try doing something differently.
BruceS
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Desktop.Open() question

Post by Diverod »

BruceSteers wrote: Monday 13th December 2021 1:10am It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open
Yes, works fine in terminal with xdg-open https://startpage.com/.
I have this in the notes of my UrlLabel

Code: Select all

Public Sub ulbStartPage_Click()

  '' If you add the 'gb.desktop' component you can use (this worked with 3.14.3)
  '' After updating to 3.16.3 this crashes and needed the component gb.pcre
  '' sudo apt-get install gambas3-gb-pcre
  '' This now works but opens 2 of the same web page < add Wait = True to correct
   Desktop.Open("https://startpage.com/", True)
    
End
But then I realized that the UrlLabel ignores the Desktop.Open("https://startpage.com/", True) and uses whatever is in the text of the label.
I also didn't understand what the gb.pcre had to do with anything and it's not checked in Project > Components, but it did stop the crashing.

I was just wanting to open a couple different web pages programmatically. If it works for you it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?

Thanks for your response.
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Desktop.Open() question

Post by Diverod »

I just saw this in my terminal window if it helps.

Code: Select all

rodg@rodg-ubuntu:~$ xdg-open https://startpage.com/
rodg@rodg-ubuntu:~$ Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
/usr/share/libdrm/amdgpu.ids: No such file or directory
Opening in existing browser session.
[7518:7518:0100/000000.902768:ERROR:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process.
It did open the browser properly and switched to it, causing me to miss the above.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Desktop.Open() question

Post by BruceSteers »

Diverod wrote: Monday 13th December 2021 3:07am
BruceSteers wrote: Monday 13th December 2021 1:10am It works as expected for me with that url.

do you get a result if you use xdg-open in a terminal?

xdg-open https://startpage.com/

Desktop.Open() uses xdg-open
Yes, works fine in terminal with xdg-open https://startpage.com/.
I have this in the notes of my UrlLabel

Code: Select all

Public Sub ulbStartPage_Click()

  '' If you add the 'gb.desktop' component you can use (this worked with 3.14.3)
  '' After updating to 3.16.3 this crashes and needed the component gb.pcre
  '' sudo apt-get install gambas3-gb-pcre
  '' This now works but opens 2 of the same web page < add Wait = True to correct
   Desktop.Open("https://startpage.com/", True)
    
End
But then I realized that the UrlLabel ignores the Desktop.Open("https://startpage.com/", True) and uses whatever is in the text of the label.
I also didn't understand what the gb.pcre had to do with anything and it's not checked in Project > Components, but it did stop the crashing.

I was just wanting to open a couple different web pages programmatically. If it works for you it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?

Thanks for your response.
Aah yes, you are doing something twice there.
UrlLabel is a clickable link, it's already doing what you are doing. the link is set in the Link field not the Text field (possibly it uses the text field if the link field has not been filled).

your Click event function would make sense for a normal label but not for UrlLabel.
To override the UrlLabel function use Stop Event

Code: Select all

Public Sub ulbStartPage_Click()

   Desktop.Open("https://startpage.com/", True)
   Stop Event  ' cancel the standard function of urlLabel
       
End
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]
If at first you don't succeed , try doing something differently.
BruceS
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Desktop.Open() question

Post by Diverod »

BruceSteers wrote: Monday 13th December 2021 2:51pm
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]
I think I'll just sidestep the Desktop.Open for now. I think I run a little behind the curve on Gambas updates due to the use of Ubuntu 20.04.3. but I don't really know enough to be sure of that

The above will work great for me, so my problem is Solved. :D Thanks Bruce.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Desktop.Open() question

Post by BruceSteers »

Diverod wrote: Monday 13th December 2021 3:20pm
BruceSteers wrote: Monday 13th December 2021 2:51pm
Or you could just use the shell
Exec ["xdg-open", "https://startpage.com/"]
I think I'll just sidestep the Desktop.Open for now. I think I run a little behind the curve on Gambas updates due to the use of Ubuntu 20.04.3. but I don't really know enough to be sure of that

The above will work great for me, so my problem is Solved. :D Thanks Bruce.
You're welcome.

If you want to keep updated i made some utilities to help update to latest gambas versions..

the easiest way on an ubuntu system is to use the PPA method..

see the apt repository PPA latest gambas install info here..
http://gambaswiki.org/wiki/install/ubuntu
There's instructions for adding either the gambas stable release or the latest development branch


Gambas compile and install info...
http://gambaswiki.org/wiki/install

Some utilities to simplify auto-tools install method..
http://gambaswiki.org/wiki/installtools
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Desktop.Open() question

Post by stevedee »

Diverod wrote: Monday 13th December 2021 3:07am ...it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?
It means "not finished, but stable"

Fully green means "stable"

Fully white/hollow means "experimental"
Diverod
Posts: 28
Joined: Friday 12th November 2021 1:31am
Location: North Central Florida

Re: Desktop.Open() question

Post by Diverod »

stevedee wrote: Monday 13th December 2021 4:25pm
Diverod wrote: Monday 13th December 2021 3:07am ...it makes me wonder if that little green circle to the right of gb.desktop in Project > Components being only half green means I'm missing something?
It means "not finished, but stable"

Fully green means "stable"

Fully white/hollow means "experimental"
Thanks stevedee, that's great info. I had truly been wondering the meaning of the half filled circle.
I see now that if I'd left my mouse over that green circle it would have told me a bit more. :shock:
BruceSteers wrote: Monday 13th December 2021 3:28pm Some utilities to simplify auto-tools install method..
http://gambaswiki.org/wiki/installtools
Thanks Bruce, I used one of your auto-tools(very,very nice) Simple Upgrade so Gambas should be correct now. Desktop.Open still doesn't work for me so it must be something with Ubuntu. No worries though as "xdg-open" works great.

Thanks to All, RodG
Post Reply