I would like to have 2 input text boxes next to each other.
I've attempted to copy/past the code for one text box but that has not yielded the proper result. Only one text box shows.
If possible I'd like to get the labels to sit in-line with the text boxes as well.
class UI_central(QtGui.QDialog):
def __init__(self, parent=None):
super(UI_central, self).__init__(parent)
"""
Input box for stock name
"""
label1 = QtGui.QLabel('Stock', self)
label1.move(50, 0)
self.line_edit = QtGui.QLineEdit()
self.line_edit.setText("Stock name")
hbox = QtGui.QHBoxLayout()
hbox.addWidget(self.line_edit)
self.setLayout(hbox)
"""
Input box for stock amount
"""
label2 = QtGui.QLabel('How Many?', self)
label2.move(100, 0)
self.line_edit2 = QtGui.QLineEdit()
self.line_edit2.setText("Stock amount")
hbox2 = QtGui.QHBoxLayout()
hbox2.addWidget(self.line_edit2)
self.setLayout(hbox2)
"""
Push buttons
"""
submit_button = QtGui.QPushButton("Submit")
clear_button = QtGui.QPushButton("Clear")
hbox.addWidget(submit_button)
hbox.addWidget(clear_button)
self.connect(submit_button, QtCore.SIGNAL("clicked()"),
self.submit)
self.connect(clear_button, QtCore.SIGNAL("clicked()"),
self.clear)
return
def submit(self):
str = self.line_edit.text()
# check str before doing anything with it!
print(str)
def clear(self):
print ("cleared")
self.line_edit.setText("")