Python Forum

Full Version: How can I sync Combobox index to other combobox index?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I have a question. I'm getting the data from the text file until the sql handles it. What I want is to return the index value of the element I selected on the ComboBox named Companies to the other boxes. In this way, the passwords of the companies etc. will also be poured onto the screen. So exactly what I want is to set the index values ​​of the selected item on the first ComboBox and the other ComboBoxes. I've done this with C#, and I'm leaving it as an example.

My Python Code:
import sys
from PyQt5 import QtWidgets
from PyQt5.QtGui import QIcon
from PyQt5.QtGui import QIcon
from AyGrupOtomasyon import Ui_MainWindow
from selenium import webdriver
import time
import os
from selenium.webdriver.common.keys import Keys
import threading


class MyApp(QtWidgets.QMainWindow):
    def __init__(self):
        super(MyApp, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.btn_Bildirge_2.clicked.connect(self.ButonV2Calistir)
        self.DosyaOku()

    def DosyaOku(self):
        os.chdir("Data")
        dosyaOku = open("sirket.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Firmalar.addItem(i)
        dosyaOku = open("kullanici.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Kullanici.addItem(i)
        dosyaOku = open("kod.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Kod.addItem(i)
        dosyaOku = open("isveren.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Isveren.addItem(i)
        dosyaOku = open("araci.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Araci.addItem(i)
        dosyaOku = open("sistem.txt", "r", encoding="utf-8")
        for i in dosyaOku:
            self.ui.cb_Sistem.addItem(i)
    def ButonV2Calistir(self):
        def ButonV2():
            browser = webdriver.Chrome("chromedriver.exe")
            browser.get("https://ebildirge.sgk.gov.tr/EBildirgeV2")
            var = input()
        ButonV2CalistirThread = threading.Thread(target=ButonV2)
        ButonV2CalistirThread.start()

def app():
    app = QtWidgets.QApplication(sys.argv)
    app.setStyle('Fusion')
    win = MyApp()
    win.show()
    sys.exit(app.exec_())

app()
C# Code:

KullaniciList.SelectedIndex = SirketList.SelectedIndex;
kodList.SelectedIndex = SirketList.SelectedIndex;
sistemList.SelectedIndex = SirketList.SelectedIndex;
isverenList.SelectedIndex = SirketList.SelectedIndex;
ListAraci.SelectedIndex = SirketList.SelectedIndex;

[Image: Q8Y9tyR]
Your code has no ComboBox and cannot be executed because AyGrupOtomasyon is missing.
You can try something like

ListAraci.setCurrentIndex(SirketList.currentIndex())