PyQt help question

Post here if you need help with creating a Graphical User Interface in Python.

PyQt help question

Postby LavaCreeperKing » Mon Sep 19, 2016 11:14 pm

Hey, so I have been doing stuff with PyQt and I have a question about how you can have a loop running with the program. So I have tried it and yes I can have a loop in my program but the problem is that if I have a GUI window that has a text edit widget and I have a While loop running the window and program work fine but when I try to type something into the text edit widget the text is in all caps. My caps lock is not enabled and if I disable the loop the text will be normal. Now I do understand that I could just convert the text to lowercase but lets say you need a letter to be uppercase. Why is this happening and how can I get around this? Does PyQt offer some kind of built in loop function or something that I need to use instead of a while loop?
Posts: 103
Joined: Wed Sep 02, 2015 11:31 pm

Re: PyQt help question

Postby nilamo » Tue Sep 20, 2016 7:01 pm

There's no reason a while loop would cause your text to be all caps. If anything, it'd cause your app to be unresponsive since you're keeping the main thread busy.
We'll need to see some code to see what's up, because uppercase is not the default for the editor.
This forum is shutting down. Future discussion should take place at
User avatar
Posts: 87
Joined: Thu Jul 21, 2016 8:00 pm
Location: Michigan

Re: PyQt help question

Postby LavaCreeperKing » Wed Sep 21, 2016 6:21 pm

This should work as an example of working code. What you do is enter a size for the pygame window then click the view button it brings up the pygame window when starts the while loop so you can close the pygame window when you click the x button.(This code is part of a program I am making.)After the loop starts if you type a letter into a text edit widget it will be uppercase but if you type in a letter before the loop is tarted or if you stop the loop the letter is in lowercase.

Code: Select all
from PyQt4 import QtCore, QtGui
import sys
import pygame

    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Setup1(object):
    def setupUi(self, Form): = False
        Form.resize(281, 258)
        self.View = QtGui.QPushButton(Form)
        self.View.setGeometry(QtCore.QRect(10, 230, 75, 23))
        self.Winput = QtGui.QLineEdit(Form)
        self.Winput.setGeometry(QtCore.QRect(10, 140, 71, 20))
        self.Hinput = QtGui.QLineEdit(Form)
        self.Hinput.setGeometry(QtCore.QRect(10, 190, 71, 20))

        QtCore.QObject.connect(self.View, QtCore.SIGNAL(_fromUtf8("clicked()")), self.pgview)

    def pgview(self):
            self.v = self.Winput.text()
            self.w = int(self.v)
            self.v = self.Hinput.text()
            self.h = int(self.v)
        except ValueError:
            print('Pleas enter a size for the pygame window.')
    def pgloop(self):
        while not
            for event in pygame.event.get():
                if event.type == pygame.QUIT:

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Pygame Edit Mode", None))
        self.View.setText(_translate("Form", "View", None))

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    Form = QtGui.QWidget()
    ui = Setup1()
Posts: 103
Joined: Wed Sep 02, 2015 11:31 pm

Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests