Buy Me a Coffee? Your support is much appreciated!
PayPal Me: https://www.paypal.me/jiejenn/5 Venmo: @Jie-Jenn
Source Code:
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLineEdit, \
QHBoxLayout, QVBoxLayout
from PyQt6.QtCore import Qt
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('Auto Convert Text To Proper Case')
self.window_width, self.window_height = 700, 100
self.resize(self.window_width, self.window_height)
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.input = QLineEdit()
self.input.setPlaceholderText('Type Something')
self.input.textChanged.connect(self.auto_convert_texts)
self.layout.addWidget(self.input)
def auto_convert_texts(self, txt):
proper_case_text = txt.title()
self.input.setText(proper_case_text)
if __name__ == '__main__':
# don't auto scale when drag app to a different monitor.
# QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
app = QApplication(sys.argv)
app.setStyleSheet('''
QWidget {
font-size: 20px;
}
''')
myApp = MyApp()
myApp.show()
try:
sys.exit(app.exec())
except SystemExit:
print('Closing Window...')
