Skip to content

Commit

Permalink
use buttonbox
Browse files Browse the repository at this point in the history
  • Loading branch information
frida-161 committed May 17, 2023
1 parent 7bbc8ee commit 9db6dcc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions qgis_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,44 @@
QLineEdit,
QCompleter,
QMessageBox,
QDialogButtonBox,
QComboBox)
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
from pathlib import Path
import subprocess
import sys
import os
import platform


def choose_qgis(dirs):
combobox = QComboBox()
combobox.addItems(dirs)
buttonbox = QDialogButtonBox()
dialog = QDialog()
layout = QVBoxLayout()
layout.addWidget(combobox)
layout.addWidget(buttonbox)
dialog.setLayout(layout)
dialog.setWindowTitle("Choose QGIS Install:")
combobox.returnPressed.connect(dialog.accept)
buttonbox.accepted.connect(dialog.accept)
dialog.exec_()

return combobox.currentText()


def start_qgis():
if os.name == "nt":
if platform.system() == "Windows":
font_name = "Segoe UI"
elif platform.system() == "Darwin":
font_name = "San Francisco"
else:
font_name = "Ubuntu"

app = QApplication(sys.argv)
app.setFont(QFont(font_name, 15))

if os.name == "nt":
if platform.system() == "Windows":
profile_path = (
Path.home() / Path("AppData/Roaming/QGIS/QGIS3/profiles")
)
Expand All @@ -63,6 +68,12 @@ def start_qgis():
else:
QMessageBox.critical(None, "Error", "QGIS bat not found")
return
elif platform.system() == "Darwin":
profile_path = (
Path.home() /
Path("~/Library/Application Support/QGIS/QGIS3/profiles")
)
qgis_path = "qgis"
else:
profile_path = Path.home() / Path(".local/share/QGIS/QGIS3/profiles")
qgis_path = "qgis"
Expand Down

0 comments on commit 9db6dcc

Please sign in to comment.