python - Associate many QButtons with many QLineEdits -



python - Associate many QButtons with many QLineEdits -

the app building looks this:

the app include several more qtoolbuttons , qlineedits. when qtoolbutton pressed color dialog presented. hex code of color added lineedit. possible each qlineedit associated qtoolbutton when button pressed app automatically knows lineedit add together text to. code using is:

self.connect(self.bgbut, signal("clicked()"),self.bgbut_click) #bgbut qtoolbutton

and calling

def bgbut_click(self):

but become impractical 15 plus line edits , toolbuttons add. there way efficiently associate each toolbutton corresponding lineedit?

i advice next 3 steps.

step 1: while or after setup of ui of widget create dictionary buttons keys , line edits values.

self.button_map = {} self.button_map[self.but1] = self.edit1 self.button_map[self.but2] = self.edit2 ..

step 2: connect buttons same method in widget. did that, guess.

self.but1.clicked.connect(self.buttons_clicked) self.but2.clicked.connect(self.buttons_clicked) ..

step 3: in method connected buttons sender, corresponding line edit dictionary created before , set text accordingly.

def buttons_clicked(self): text = color_dialog_get_some_text() # customize self.button_map[self.sender].settext(text)

python pyqt pyside

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -