Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-22 Thread Raymond Nijssen

Yes, that! Thanks!

Raymond

On 21-10-2020 23:31, Fernando M. Roxo da Motta wrote:

On Wed, 21 Oct 2020 17:18:05 +0200, Raymond Nijssen
 wrote:



This script works for me. But I'm not all sure about the way I start
a new process for QGIS and quit the python script. I think ending the
command with an "&" only works on unix kind of systems..


   Perhaps the 'run()' method of subprocess module can be a more
suitable answer:

   https://docs.python.org/3/library/subprocess.html

   HTH.



---

import sys
import os
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout,
QComboBox, QPushButton

# adjust these to your setup:
qgis_bin = '/home/raymond/git/QGIS/build-master/output/bin/qgis'
profile_path = '/home/raymond/.local/share/QGIS/QGIS3/profiles'


def run_qgis():
  profile_name = cb.currentText()
  cmd = f'{qgis_bin} --profile {profile_name} &'
  #print(cmd)
  w.close()
  os.system(cmd)


app = QApplication(sys.argv)

w = QWidget()
w.setWindowTitle('Choose QGIS profile')

l = QVBoxLayout()

cb = QComboBox()
for fn in os.scandir(profile_path):
  if fn.is_dir():
  cb.addItem(fn.name)
l.addWidget(cb)

btn = QPushButton('Run QGIS')
btn.clicked.connect(run_qgis)
l.addWidget(btn)

w.setLayout(l)

w.show()

sys.exit(app.exec_())

---

On 21-10-2020 14:00, Raymond Nijssen wrote:

Hi Lars,

I don't think you can. You can make a startup.py script that runs
every time you start QGIS, but it sits in your profile folder. So
when QGIS runs it, QGIS must already be aware of the profile that
is being used. Also, changing the profile needs a QGIS restart, so
it seems QGIS cannot change profile anymore while running.

Maybe you can make a small python (pyqt?) script that displays a
dialog with profile name picker and does a "qgis --profile NAME"
for you?

Regards,
Raymond


On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:

Hi list.

If I have multiple profiles defined, is it possible to have QGIS
prompt me everytime for which profile to use ?

I know that I can add “--profile NAME” to the command line, but is
looking for a way to avoid having multiple start icons.

Med venlig hilsen

Lars I. Nielsen, LIFA A/S
GIS-kons., FME+Python Certified Professional
Geoinformatik

*T*



6313 6800



*@*



l...@lifa.dk

*D*



6313 6849



*W*



www.lifa.dk 

*M*



*CVR*



20937289



Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
  

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user








   Roxo


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Fernando M. Roxo da Motta
On Wed, 21 Oct 2020 17:18:05 +0200, Raymond Nijssen
 wrote:


> This script works for me. But I'm not all sure about the way I start
> a new process for QGIS and quit the python script. I think ending the 
> command with an "&" only works on unix kind of systems..

  Perhaps the 'run()' method of subprocess module can be a more
suitable answer:

  https://docs.python.org/3/library/subprocess.html

  HTH.

> 
> ---
> 
> import sys
> import os
> from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, 
> QComboBox, QPushButton
> 
> # adjust these to your setup:
> qgis_bin = '/home/raymond/git/QGIS/build-master/output/bin/qgis'
> profile_path = '/home/raymond/.local/share/QGIS/QGIS3/profiles'
> 
> 
> def run_qgis():
>  profile_name = cb.currentText()
>  cmd = f'{qgis_bin} --profile {profile_name} &'
>  #print(cmd)
>  w.close()
>  os.system(cmd)
> 
> 
> app = QApplication(sys.argv)
> 
> w = QWidget()
> w.setWindowTitle('Choose QGIS profile')
> 
> l = QVBoxLayout()
> 
> cb = QComboBox()
> for fn in os.scandir(profile_path):
>  if fn.is_dir():
>  cb.addItem(fn.name)
> l.addWidget(cb)
> 
> btn = QPushButton('Run QGIS')
> btn.clicked.connect(run_qgis)
> l.addWidget(btn)
> 
> w.setLayout(l)
> 
> w.show()
> 
> sys.exit(app.exec_())
> 
> ---
> 
> On 21-10-2020 14:00, Raymond Nijssen wrote:
> > Hi Lars,
> > 
> > I don't think you can. You can make a startup.py script that runs
> > every time you start QGIS, but it sits in your profile folder. So
> > when QGIS runs it, QGIS must already be aware of the profile that
> > is being used. Also, changing the profile needs a QGIS restart, so
> > it seems QGIS cannot change profile anymore while running.
> > 
> > Maybe you can make a small python (pyqt?) script that displays a
> > dialog with profile name picker and does a "qgis --profile NAME"
> > for you?
> > 
> > Regards,
> > Raymond
> > 
> > 
> > On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:  
> >> Hi list.
> >>
> >> If I have multiple profiles defined, is it possible to have QGIS 
> >> prompt me everytime for which profile to use ?
> >>
> >> I know that I can add “--profile NAME” to the command line, but is 
> >> looking for a way to avoid having multiple start icons.
> >>
> >> Med venlig hilsen
> >>
> >> Lars I. Nielsen, LIFA A/S
> >> GIS-kons., FME+Python Certified Professional
> >> Geoinformatik
> >>
> >> *T*
> >>
> >>
> >>
> >> 6313 6800
> >>
> >>
> >>
> >> *@*
> >>
> >>
> >>
> >> l...@lifa.dk
> >>
> >> *D*
> >>
> >>
> >>
> >> 6313 6849
> >>
> >>
> >>
> >> *W*
> >>
> >>
> >>
> >> www.lifa.dk 
> >>
> >> *M*
> >>
> >>
> >>
> >> *CVR*
> >>
> >>
> >>
> >> 20937289
> >>
> >>
> >> 
> >> Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S
> >>
> >>
> >> ___
> >> Qgis-user mailing list
> >> Qgis-user@lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> >>  
> > ___
> > Qgis-user mailing list
> > Qgis-user@lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user  
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user







  Roxo

-- 
 Non luctari, ludare ---+ WYSIWYG
Fernando M. Roxo da Motta   | Editor?
Except where explicitly stated I speak on my own behalf.|  VI !!
PU5RXO  | I see text,
 Quis custodiet ipsos custodes?-+ I get text!
 
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Charles Dixon-Paver
I tried to make a quick and dirty cross platform one with zenity that will
work OOTB without worrying about the python environment setup. Didn't work
as planned as the zenity portable app for windows seems a bit glitchy
(there's no way to cancel I could find). Anyway, it should work OOTB on
Gnome, and I share because it might be a handy way for someone to pass
other parameters to a program.

Windows:
--
@echo off
@setlocal enableextensions
@cd /d "%~dp0"
@ SETLOCAL EnableDelayedExpansion
@ if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0"
%* && exit

REM Get Zenity Portable and add it to your PATH
REM or keep it in the batchfile dir https://github.com/maravento/winzenity

Set "profilesDir=%APPDATA%\QGIS\QGIS3\profiles"

Set dirs=

for /f "tokens=* usebackq" %%I in (`dir %profilesDir% /A:D /O:N /B`) do (
  Set "dirs=!dirs! %%I"
)

for /f %%X in ('zenity --entry --timeout 10 --ok-label="OK"
--cancel-label="OK ANYWAY" --title "User Profile" --text "Select your
profile." !dirs!') do (
  Set "selectedProfile=%%X"
  ECHO %ERRORLEVEL%
)

REM if %ERRORLEVEL% == 1 exit

if "!selectedProfile!"=="" (
for /f "tokens=* usebackq" %%F in (`findstr /L /C:"defaultProfile"
%profilesDir%\profiles.ini`) do (
  Set defaultProfile=%%F
  for /F "tokens=2 delims==" %%A in ("!defaultProfile!") do (
Set selectedProfile=%%A
  )
))

%COMSPEC% /C "CALL C:\OSGeo4W64\bin\qgis.bat --profile !selectedProfile!"

EXIT




Linux:

#!/usr/bin/env bash

qgisBin=$(which qgis)

profilesDir=~/.local/share/QGIS/QGIS3/profiles

dirList=$(ls -d $profilesDir/*/)

dirNames=$(for dir in "${dirList[@]}"; do echo "$(basename --suffix=/ -a
$dir)"; done)

dirs=()

for dir in ${dirNames[@]}
do
  dirs=(${dirs[@]} "$dir")
done

selectedProfile=$(zenity --entry --timeout 10 --title "User Profile" --text
"Select your profile." "${dirs[@]}")

# If cancelled, then exit

[[ "$?" != "0" ]] && exit 1

if [ -z "$selectedProfile" ]
then
  selectedProfile=$(awk -F "=" '/defaultProfile/ {print $2}'
$profilesDir/profiles.ini)
fi

$qgisBin --profile $selectedProfile & disown

exit


On Wed, 21 Oct 2020 at 17:18, Raymond Nijssen  wrote:

> This script works for me. But I'm not all sure about the way I start a
> new process for QGIS and quit the python script. I think ending the
> command with an "&" only works on unix kind of systems..
>
> ---
>
> import sys
> import os
> from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout,
> QComboBox, QPushButton
>
> # adjust these to your setup:
> qgis_bin = '/home/raymond/git/QGIS/build-master/output/bin/qgis'
> profile_path = '/home/raymond/.local/share/QGIS/QGIS3/profiles'
>
>
> def run_qgis():
>  profile_name = cb.currentText()
>  cmd = f'{qgis_bin} --profile {profile_name} &'
>  #print(cmd)
>  w.close()
>  os.system(cmd)
>
>
> app = QApplication(sys.argv)
>
> w = QWidget()
> w.setWindowTitle('Choose QGIS profile')
>
> l = QVBoxLayout()
>
> cb = QComboBox()
> for fn in os.scandir(profile_path):
>  if fn.is_dir():
>  cb.addItem(fn.name)
> l.addWidget(cb)
>
> btn = QPushButton('Run QGIS')
> btn.clicked.connect(run_qgis)
> l.addWidget(btn)
>
> w.setLayout(l)
>
> w.show()
>
> sys.exit(app.exec_())
>
> ---
>
> On 21-10-2020 14:00, Raymond Nijssen wrote:
> > Hi Lars,
> >
> > I don't think you can. You can make a startup.py script that runs every
> > time you start QGIS, but it sits in your profile folder. So when QGIS
> > runs it, QGIS must already be aware of the profile that is being used.
> > Also, changing the profile needs a QGIS restart, so it seems QGIS cannot
> > change profile anymore while running.
> >
> > Maybe you can make a small python (pyqt?) script that displays a dialog
> > with profile name picker and does a "qgis --profile NAME" for you?
> >
> > Regards,
> > Raymond
> >
> >
> > On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:
> >> Hi list.
> >>
> >> If I have multiple profiles defined, is it possible to have QGIS
> >> prompt me everytime for which profile to use ?
> >>
> >> I know that I can add “--profile NAME” to the command line, but is
> >> looking for a way to avoid having multiple start icons.
> >>
> >> Med venlig hilsen
> >>
> >> Lars I. Nielsen, LIFA A/S
> >> GIS-kons., FME+Python Certified Professional
> >> Geoinformatik
> >>
> >> *T*
> >>
> >>
> >>
> >> 6313 6800
> >>
> >>
> >>
> >> *@*
> >>
> >>
> >>
> >> l...@lifa.dk
> >>
> >> *D*
> >>
> >>
> >>
> >> 6313 6849
> >>
> >>
> >>
> >> *W*
> >>
> >>
> >>
> >> www.lifa.dk 
> >>
> >> *M*
> >>
> >>
> >>
> >> *CVR*
> >>
> >>
> >>
> >> 20937289
> >>
> >>
> >> 
> >> Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S
> >>
> >>
> >> ___
> >> Qgis-user mailing 

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Raymond Nijssen
This script works for me. But I'm not all sure about the way I start a 
new process for QGIS and quit the python script. I think ending the 
command with an "&" only works on unix kind of systems..


---

import sys
import os
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, 
QComboBox, QPushButton


# adjust these to your setup:
qgis_bin = '/home/raymond/git/QGIS/build-master/output/bin/qgis'
profile_path = '/home/raymond/.local/share/QGIS/QGIS3/profiles'


def run_qgis():
profile_name = cb.currentText()
cmd = f'{qgis_bin} --profile {profile_name} &'
#print(cmd)
w.close()
os.system(cmd)


app = QApplication(sys.argv)

w = QWidget()
w.setWindowTitle('Choose QGIS profile')

l = QVBoxLayout()

cb = QComboBox()
for fn in os.scandir(profile_path):
if fn.is_dir():
cb.addItem(fn.name)
l.addWidget(cb)

btn = QPushButton('Run QGIS')
btn.clicked.connect(run_qgis)
l.addWidget(btn)

w.setLayout(l)

w.show()

sys.exit(app.exec_())

---

On 21-10-2020 14:00, Raymond Nijssen wrote:

Hi Lars,

I don't think you can. You can make a startup.py script that runs every 
time you start QGIS, but it sits in your profile folder. So when QGIS 
runs it, QGIS must already be aware of the profile that is being used. 
Also, changing the profile needs a QGIS restart, so it seems QGIS cannot 
change profile anymore while running.


Maybe you can make a small python (pyqt?) script that displays a dialog 
with profile name picker and does a "qgis --profile NAME" for you?


Regards,
Raymond


On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:

Hi list.

If I have multiple profiles defined, is it possible to have QGIS 
prompt me everytime for which profile to use ?


I know that I can add “--profile NAME” to the command line, but is 
looking for a way to avoid having multiple start icons.


Med venlig hilsen

Lars I. Nielsen, LIFA A/S
GIS-kons., FME+Python Certified Professional
Geoinformatik

*T*



6313 6800



*@*



l...@lifa.dk

*D*



6313 6849



*W*



www.lifa.dk 

*M*



*CVR*



20937289



Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Richard Duivenvoorde
On 10/21/20 1:21 PM, Lars I. Nielsen, LIFA A/S wrote:
> Hi list.
> 
> If I have multiple profiles defined, is it possible to have QGIS prompt me 
> everytime for which profile to use ?
> 
> I know that I can add “--profile NAME” to the command line, but is looking 
> for a way to avoid having multiple start icons.

For what I know Nathan (in bcc) was our 'profile'-hero... 
Maybe he can tell if this is an easy 'feature-request' or if that is really 
hard to implement?
Others feel free to chime in, if I am pointing to the wrong person, or you know 
more...  :-)

Regards,

Richard Duivenvoorde
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Charles Dixon-Paver
If you don't want to bother with a full blown python app, on windows you
could pretty easily make a "custom-profile-qgis.cmd" batchfile with
something like the following:



@echo off
@setlocal enableextensions
@cd /d "%~dp0"

Set "MYPROFILE=default"
ECHO Please type the name of your user profile:
Set /P "MYPROFILE="

%COMSPEC% /C "CALL C:\OSGeo4W64\bin\qgis.bat --profile %MYPROFILE% %*"



Changing the QGIS startup batch location of course. You could also probably
extend it easily with https://ss64.com/nt/choice.html

Then your "shortcut" will prompt you for the profile you want to use.

I reckon pulling off the same in bash is also pretty trivial...

Regards

On Wed, 21 Oct 2020 at 14:00, Raymond Nijssen  wrote:

> Hi Lars,
>
> I don't think you can. You can make a startup.py script that runs every
> time you start QGIS, but it sits in your profile folder. So when QGIS
> runs it, QGIS must already be aware of the profile that is being used.
> Also, changing the profile needs a QGIS restart, so it seems QGIS cannot
> change profile anymore while running.
>
> Maybe you can make a small python (pyqt?) script that displays a dialog
> with profile name picker and does a "qgis --profile NAME" for you?
>
> Regards,
> Raymond
>
>
> On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:
> > Hi list.
> >
> > If I have multiple profiles defined, is it possible to have QGIS prompt
> > me everytime for which profile to use ?
> >
> > I know that I can add “--profile NAME” to the command line, but is
> > looking for a way to avoid having multiple start icons.
> >
> > Med venlig hilsen
> >
> > Lars I. Nielsen, LIFA A/S
> > GIS-kons., FME+Python Certified Professional
> > Geoinformatik
> >
> > *T*
> >
> >
> >
> > 6313 6800
> >
> >
> >
> > *@*
> >
> >
> >
> > l...@lifa.dk
> >
> > *D*
> >
> >
> >
> > 6313 6849
> >
> >
> >
> > *W*
> >
> >
> >
> > www.lifa.dk 
> >
> > *M*
> >
> >
> >
> > *CVR*
> >
> >
> >
> > 20937289
> >
> >
> > 
> > Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S
> >
> >
> > ___
> > Qgis-user mailing list
> > Qgis-user@lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> >
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Raymond Nijssen

Hi Lars,

I don't think you can. You can make a startup.py script that runs every 
time you start QGIS, but it sits in your profile folder. So when QGIS 
runs it, QGIS must already be aware of the profile that is being used. 
Also, changing the profile needs a QGIS restart, so it seems QGIS cannot 
change profile anymore while running.


Maybe you can make a small python (pyqt?) script that displays a dialog 
with profile name picker and does a "qgis --profile NAME" for you?


Regards,
Raymond


On 21-10-2020 13:21, Lars I. Nielsen, LIFA A/S wrote:

Hi list.

If I have multiple profiles defined, is it possible to have QGIS prompt 
me everytime for which profile to use ?


I know that I can add “--profile NAME” to the command line, but is 
looking for a way to avoid having multiple start icons.


Med venlig hilsen

Lars I. Nielsen, LIFA A/S
GIS-kons., FME+Python Certified Professional
Geoinformatik

*T*



6313 6800



*@*



l...@lifa.dk

*D*



6313 6849



*W*



www.lifa.dk 

*M*



*CVR*



20937289



Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Have QGIS prompt for profile to use everytime ?

2020-10-21 Thread Lars I. Nielsen, LIFA A/S
Hi list.

If I have multiple profiles defined, is it possible to have QGIS prompt me 
everytime for which profile to use ?

I know that I can add "--profile NAME" to the command line, but is looking for 
a way to avoid having multiple start icons.


Med venlig hilsen

Lars I. Nielsen, LIFA A/S
GIS-kons., FME+Python Certified Professional
Geoinformatik
[cid:image001.gif@01D6A7AC.CF171BE0]
T
6313 6800
@
l...@lifa.dk
D
6313 6849
W
www.lifa.dk
M
CVR
20937289

[cid:image002.png@01D6A7AC.CF171BE0]
Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user