python - PYQT QpushButton with QcomboBox multi-slot connect -


so have developed gui work, having trouble connecting qcombobox multiple different slot, depending on user input. essentially, want user able select drive qcombobox, press qpushbutton , automatically directed network drive.

screenshot

i have been scratching head on logic days now. know second part of code should go (maybe?):

def retranslateui(self, mainwindow):     self.btngo.clicked.connect(self.driverselectclicked)  def driverselectclicked(self):     if self.combobox1.currentindex() == 0:        os.startfile('c:/')     if self.combobox1.currentindex() == 1:        os.startfile('z:/')      

you should pulling drive path information directly combobox. in addition setting text combobox entry, can set data

drives = ['c:\\', 'z:\\'] drive in drives:     text = '[{}] disk drive'.format(drive)     self.combobox1.additem(text, drive) 

then later, when you're processing click, can read data field contains drive , use directly

def driverselectclicked(self):     drive = self.combobox1.itemdata(self.combobox1.currentindex())     if drive:        os.startfile(drive)  

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -