#๐Ÿ”’ i just got back into coding and i finished my first project

11 messages ยท Page 1 of 1 (latest)

lucid hawk
#

the program is suppose to give you a quote every time i press the button

import csv
import random as r
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


data_list = []


with open(r'C:\csvquotes.csv', mode='r') as file:
    csv_reader = csv.reader(file)
    for row in csv_reader:
        data_list.append(row)


 




def window():
    global b
    global w
    app = QApplication(sys.argv)
    w = QWidget()
    b = QLabel(w)
    b.setText("")
    b.setGeometry(50000, 50000,1000,100)
    w.button = QPushButton("click me", w)
    w.button.clicked.connect(on_click)
    w.button.setGeometry(150, 200, 200, 100)
    w.setGeometry(100, 100, 500, 500)
    b.move(50, 20)
    w.setWindowTitle("PyQt5")
    w.show()
    sys.exit(app.exec_())


def on_click():
    random_quote = r.choice(data_list)[0]
    b.setText("")
    print(random_quote)
    b.setText(random_quote)

if __name__ == '__main__':
    window()

i use pyqt5 since ive used pyautogui for something else earlier and i wanted to try something new idk what is better

jagged skyBOT
#

@lucid hawk

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

olive elbow
#

you also don't need to setText to "" before changing the quote

#

did you mean pysimplegui?

lucid hawk
lucid hawk
olive elbow
#

either way, pyqt5 is pretty much the most powerful option you have

lucid hawk
#

ok

jagged skyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.