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

Raymond Nijssen r.nijssen at terglobo.nl
Thu Oct 22 00:04:08 PDT 2020


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
> <r.nijssen at terglobo.nl> 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
>>>>
>>>>
>>>>
>>>> *@*
>>>>
>>>>
>>>>
>>>> lin at lifa.dk
>>>>
>>>> *D*
>>>>
>>>>
>>>>
>>>> 6313 6849
>>>>
>>>>
>>>>
>>>> *W*
>>>>
>>>>
>>>>
>>>> www.lifa.dk <http://www.lifa.dk>
>>>>
>>>> *M*
>>>>
>>>>
>>>>
>>>> *CVR*
>>>>
>>>>
>>>>
>>>> 20937289
>>>>
>>>>
>>>> <https://www.linkedin.com/company/lifa-a-s/>
>>>> Følg os på LinkedIn og læs de seneste nyheder fra LIFA A/S
>>>>
>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at 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 at 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 at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> 
> 
> 
> 
> 
> 
> 
>    Roxo
> 


More information about the Qgis-user mailing list