konum.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel, QComboBox
  2. from .harita_widget import HaritaWidget
  3. from PyQt5.QtCore import Qt
  4. class Konum(QWidget):
  5. def __init__(self, ebeveyn=None):
  6. super(Konum, self).__init__(ebeveyn)
  7. self.e = ebeveyn
  8. kutu = QGridLayout()
  9. kutu.setAlignment(Qt.AlignCenter)
  10. self.setLayout(kutu)
  11. self.bigli_label = QLabel()
  12. kutu.addWidget(self.bigli_label,0,0,1,2)
  13. self.harita = HaritaWidget(self)
  14. kutu.addWidget(self.harita,1,0,1,2)
  15. self.bolge_label = QLabel()
  16. kutu.addWidget(self.bolge_label,2,0,1,1)
  17. self.sehir_label = QLabel()
  18. kutu.addWidget(self.sehir_label,2,1,1,1)
  19. self.bolge_combo = QComboBox()
  20. self.bolge_combo.currentTextChanged.connect(self.sehir_combo_doldur)
  21. kutu.addWidget(self.bolge_combo,3,0,1,1)
  22. self.sehir_combo = QComboBox()
  23. self.sehir_combo.currentTextChanged.connect(self.sehir_combo_degisti)
  24. kutu.addWidget(self.sehir_combo,3,1,1,1)
  25. self.bolge_combo_doldur()
  26. self.bolge_combo.setCurrentText("Europe")
  27. self.sehir_combo.setCurrentText("Istanbul")
  28. def bolge_combo_doldur(self):
  29. self.duzenli_ulke = {}
  30. for i in self.harita.koordinat_pixelleri.items():
  31. degistir = i[1].split("/")
  32. if len(degistir) == 2:
  33. varmi = self.duzenli_ulke.get(degistir[0], "yok")
  34. if varmi == "yok":
  35. self.duzenli_ulke[degistir[0]] = [degistir[1]]
  36. else:
  37. self.duzenli_ulke[degistir[0]].append(degistir[1])
  38. elif len(degistir) == 3:
  39. varmi = self.duzenli_ulke.get(degistir[0], "yok")
  40. if varmi == "yok":
  41. self.duzenli_ulke[degistir[0]] = [degistir[1]+"/"+degistir[2]]
  42. else:
  43. self.duzenli_ulke[degistir[0]].append(degistir[1]+"/"+degistir[2])
  44. self.bolge_combo.addItems(self.duzenli_ulke.keys())
  45. def sehir_combo_doldur(self):
  46. self.sehir_combo.clear()
  47. self.sehir_combo.addItems(self.duzenli_ulke[self.bolge_combo.currentText()])
  48. def sehir_combo_degisti(self):
  49. if self.sehir_combo.currentText() != "":
  50. bolge_adi = self.bolge_combo.currentText()+"/"+self.sehir_combo.currentText()
  51. self.harita.pin_hareket_ettir(bolge_adi)
  52. self.e.milis_ayarlar["konum"] = bolge_adi
  53. def harita_tiklandi(self,tiklanan):
  54. self.bolge_combo.setCurrentText(tiklanan[0])
  55. self.sehir_combo.setCurrentText(tiklanan[1])
  56. def showEvent(self, event):
  57. self.e.setWindowTitle(self.e.d[self.e.s_d]["Saat Dilimi"])
  58. self.bigli_label.setText(self.e.d[self.e.s_d]["Lütfen saat dilimini ayarlayabilmemiz için harita üzerinden konumunuzu seçiniz."])
  59. self.bolge_label.setText(self.e.d[self.e.s_d]["Bölge"])
  60. self.sehir_label.setText(self.e.d[self.e.s_d]["Şehir"])