title: Store Value of Combo Box in PyQt
body: <p>I am making a simple graphical interface. I have two tables named calling_directory and receiving_directory. I am displaying the values using combo box. Now I would like to know, which value have I selected and would like to store that value in a variable. How do I do that? </p>
  
  <p>Secondly, I would like to use a reset button, that would set the combo box value to default. How do I do that? </p>
  
  <pre><code>import re
  import serial
  import sqlite3
  import os
  import csv
  import time
  from subprocess import *
  import serial.tools.list_ports
  import sys
  from PyQt4 import QtGui, QtCore
  from PyQt4.QtGui import *
  from PyQt4.QtCore import *
  import threading
  
  global data
  con_ports=[]
  ports=[]
  dial_ports=[]
  receiving_ports=[]
  
  class Example(QtGui.QWidget):
  
      def __init__(self):
          super(Example, self).__init__()
          self.initUI()
  
      def initUI(self):
          btn1 = QtGui.QPushButton('Proceed', self)
          btn1.resize(btn1.sizeHint())
          btn1.move(460, 220)
          btn2 = QtGui.QPushButton('Reset',self)
          btn2.resize(btn2.sizeHint())
          btn2.move(5, 220)
          self.setGeometry(300,300,550,250)   
          self.setWindowTitle('Calling Functions')
          self.setWindowIcon(QtGui.QIcon('images.jpg'))
  
          self.lbl1 = QtGui.QLabel("Dialing Number", self)
          combo1 = QtGui.QComboBox(self)
          conn = sqlite3.connect('database')
          combo1.addItem('None')
          c = conn.cursor()
          c.execute('''select number from Calling_Directory''')
          rows = c.fetchall()
          for row in rows:
              calling_number=row[0]
              combo1.addItem(row[0])
              #calling_location=row[1]
              #x=x+120
          #conn.commit()
          combo1.move(10, 40)
          self.lbl1.move(10, 20)
          self.lbl1.adjustSize()  
  
          self.lbl2 = QtGui.QLabel("Receiving Number", self)
          combo2 = QtGui.QComboBox(self)
          #conn = sqlite3.connect('database')
          combo2.addItem('None')
          #c = conn.cursor()
          c.execute('''select number from Receiving_Directory''')
          rows2 = c.fetchall()
          for row in rows2:
              receiving_number=row[0]
              combo2.addItem(row[0])
              #calling_location=row[1]
                  #x=x+120
          conn.commit()
          combo2.move(150, 40)
          self.lbl2.move(150, 20)
  
          self.lbl2.adjustSize()  
          self.show()
  
      def closeEvent(self,event):
          reply=QtGui.QMessageBox.question(self,'Mesage',"Are you sure you want to quit?",QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
          if(reply==QtGui.QMessageBox.Yes):
              event.accept()
          else:
              event.ignore()
  
  def main():
      app = QtGui.QApplication(sys.argv)
      ex=Example()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>