Python Forum

Full Version: Beginner Need Help With PyQt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm learning Python through a YouTube channel that offers many tutorials in Computer Science and especially programming.
The tutorial I was watching is about creating a menu and have the Exit button in the 'File' menu. I copied the code from his video ran it but it shows an empty window with size 320x240 and not showing anything else.
Here is the code that he had in his YouTube tutorial:

import sys
from PyQt4.QtGui import *

a = QApplication(sys.argv)

w = QMainWindow()

w.resize(320, 240)

w.setWindowTitle("Hello World!")

mainMenu = w.menuBar()
fileMenu = mainMenu.addMenu('&File')

exitButton = QAction('Exit', w)
exitButton.setShortcut('Ctrl+Q')
exitButton.setStatusTip('Exit Application')
exitButton.triggered.connect(w.close)
fileMenu.addAction(exitButton)

w.show()

sys.exit(a.exec_())
Would anyone explain to me why this is not working or supply me with any sites/articles/videos etc.?
I've not watched the youtube video but that code works as described on Linux Mint.
What you need to do is quote what operating system youre running
and also paste the traaceback so someone can help you further.
Hi,
I need help with this :
    def change(self):
        m = 2
        cur = conn.cursor()
        conn.text_factory = str
        cur.execute(" SELECT quranuthmani FROM Translation WHERE sura = ?", (m,))

        all_rows = cur.fetchall()
        a = 0
        self.SearchResult.setRowCount(286)
        for row in all_rows:
            Scontent = QtWidgets.QTableWidgetItem()
            Scontent.setText("{}".format(row[0]))

            self.SearchResult.setItem(a ,0,Scontent)
            a = a + 1

        self.SearchResult.resizeRowsToContents()

    def find_items(self):

        items = self.SearchResult.findItems(self.lineEdit.text(),QtCore.Qt.MatchContains)
        brush = QtGui.QBrush(QtGui.QColor("orange"))
        brush.setStyle(QtCore.Qt.SolidPattern)
        for item in items:
            item.setForeground(brush)
Search result is a qtable widget and the data is text so:
I want to select the exact text that I put in lineEdit and mark it or highlight it but the above code select all the cell.