Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python UI - Getting Label to show to left of QLineEdit
#1
I would like the QLineEdit field to follow the label.

Right now the label lives in the upper left hand corner of the dialogue box.



"""
Import block
"""
from PyQt4 import QtCore
from PyQt4 import QtGui

"""
Classes block
"""
class UI_central(QtGui.QDialog):

    def __init__(self, parent=None):
        super(UI_central, self).__init__(parent)
        
        label1 = QtGui.QLabel('Stock', self)
        
        self.line_edit = QtGui.QLineEdit()
        self.line_edit.setText("Starting...")
        
        hbox = QtGui.QHBoxLayout()
        hbox.addWidget(self.line_edit)
        self.setLayout(hbox)
        
        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()
        print(str)

    def clear(self):
        print ("cleared")
        self.line_edit.setText("")
Quote
#2
Disregard.

Found a few mistakes within my code and got it to run successfully.

Thanks for viewing. Tongue
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python code unable to show Bokeh line chart kirito85 2 198 Feb-06-2019, 07:52 AM
Last Post: kirito85
  How do I make my plot show up? ThomasM4 0 267 Dec-09-2018, 05:28 AM
Last Post: ThomasM4
  misclassification rate calculation for multi class label python_newbie09 1 686 Jan-12-2018, 06:06 PM
Last Post: Larz60+
  Making a number triangle that points to the left SomeNoob 2 1,553 Jul-13-2017, 06:19 AM
Last Post: SomeNoob
  Setup a label by binding listbox importing a subclass method using python 3 and tkint Dannds 0 1,127 Mar-21-2017, 09:38 PM
Last Post: Dannds

Forum Jump:


Users browsing this thread: 1 Guest(s)