Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2016
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import sys
  2. from PyQt4 import QtGui, QtCore
  3.  
  4. class Example(QtGui.QWidget):
  5.  
  6. def __init__(self):
  7. super(Example, self).__init__()
  8. self.initUI()
  9.  
  10. def initUI(self):
  11. ov_main = QtGui.QHBoxLayout()
  12. ov_col1 = QtGui.QFormLayout()
  13. ov_col2 = QtGui.QVBoxLayout()
  14. ov_custs = QtGui.QFormLayout()
  15. grid = QtGui.QGridLayout()
  16.  
  17. overviewBox = QtGui.QGroupBox('Overview')
  18.  
  19. # Main window
  20. grid.addWidget(QtGui.QLabel('Part Number'), 1, 1)
  21. grid.addWidget(QtGui.QLineEdit(), 1, 2)
  22. grid.addWidget(overviewBox, 2, 1, 1, 2)
  23.  
  24. # overview box
  25. labels = ['Description:', 'Sales:', 'Sales:', 'Shipped:']
  26. self.overview_data = []
  27.  
  28. for i, label in enumerate(labels):
  29. lbl = QtGui.QLabel('- blank -')
  30. lbl.setText(' - blank - ')
  31. self.overview_data.append(lbl)
  32. ov_col1.addRow(label, lbl)
  33.  
  34. # top 5 frame
  35. rows = ['<u>Top 5 Customers (by quantity shipped)</u>'] + ['' for i in range(5)]
  36. self.topFive = []
  37. for item in rows:
  38. print("Item")
  39. if not item == '':
  40. ov_col2.addWidget(QtGui.QLabel(item))
  41. else:
  42. cust = QtGui.QLabel(' - Customer - ')
  43. qty = QtGui.QLabel('1234')
  44. self.topFive.append([cust, qty])
  45. ov_custs.addRow(cust, qty)
  46.  
  47. ov_col1.setLabelAlignment(QtCore.Qt.AlignRight)
  48. ov_custs.setFormAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight)
  49. ov_main.addLayout(ov_col1)
  50. ov_main.addLayout(ov_col2)
  51. ov_col2.addLayout(ov_custs)
  52.  
  53. self.setLayout(grid)
  54. overviewBox.setLayout(ov_main)
  55.  
  56. self.move(300, 150)
  57. self.setWindowTitle('OPW Sales Analyzer')
  58. name = 'a'
  59. val = 1
  60. for cust,qty in self.topFive:
  61. cust.setText(name)
  62. qty.setText(str(val))
  63. name = name * 2
  64. val = val * 10
  65.  
  66.  
  67. self.show()
  68.  
  69. def main():
  70.  
  71. app = QtGui.QApplication(sys.argv)
  72. ex = Example()
  73. sys.exit(app.exec_())
  74.  
  75. if __name__ == '__main__':
  76. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement