Giter Club home page Giter Club logo

examples's People

Contributors

aaronpinto avatar arudarin avatar day0dreamer avatar hsiafan avatar matt-meyers avatar mherrmann avatar mottosso avatar olli-suoniemi avatar rafale25 avatar sammatzko avatar snoyes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

.

.

09 Qt dark theme does not work on pyqt6

At least on my linux PyQt6 it just does not run.
instead of QPalette need QPalette.ColorRole
qt.white does not work I settled on QColorConstants.White
QColorConstants.Red etc.
I added QColorConstants, QAction, QKeySequence to the
from PyQt6.QtGui import

Another example of PyQt usage?

I made a video course for Packt on Reactive programming with Python and it included a bunch of code for using PyQt5 as well:

The example is a bit bigger than just showcasing one widget, it would be nice to include a link to https://github.com/rudolfolah/Reactive-Programming-in-Python/blob/master/Section%206/client/

Alternatively, I could create a PR that simplifies that example further but still gives devs an opportunity to see an example of using multiple PyQt widgets with multiple windows/forms/layouts.

How to debug QtDesigner plugin?

In this demo :

image

If I raise Exception or print , I can't get anything output, and Custom Plugin not show in QtDesigner :

image

So , How do I debug My plugin?

QML example not working

Followed the instructions, the first example works. Trying the 06 QML Python example returns an error.

(venv) C:\Users\X\Documents\Python Scripts\qtexamples\src\01 PyQt QLabel>cd "C:\Users\User\Documents\Python Scripts\qtexamples\src\06 QML Python example"

(venv) C:\Users\X\Documents\Python Scripts\qtexamples\src\06 QML Python example>python main.py
QQmlApplicationEngine failed to load component
file:///C:/Users/X/Documents/Python Scripts/qtexamples/src/06 QML Python example/main.qml:1 plugin cannot be loaded for module "QtQuick": Cannot load library C:\Users\X\Documents\Python Scripts\qtexamples\venv\lib\site-packages\PyQt5\Qt\qml\QtQuick.2\qtquick2plugin.dll: The specified procedure could not be found.

Example for QML and fbs is missing

I'm coming from the Book "Python and Qt - The Best Parts". I don't know if this is the right spot for this issue, but it is mainly about the book.

This book uses the examples in this repo. There's one example how to use QML with PyQt. Then later on fbs is being added to the stack. Now I wanted to combine both but fell on my nose doing so.

If you use QML like in the example and add fbs to it, the frozen app won't do anything. It starts a UI process but doesn't open a window. In that situation you have to kill that process, or you can't freeze the project again, because the .exe is still running in the background. By fiddling around I found what the problem is:

The frozen app has no copy of the .qml file. So, it can't load it. You need to move it into the src/main/resources/base folder and load it like so:

engine = QQmlApplicationEngine()
engine.load(app_context.get_resource('window.qml'))

Freezing the project like this makes the frozen executable run as expected.

Yes, you can combine the information from the book to come to this solution. But I think it should be mentioned explicitly that you have to use .get_resource() for .qml files, too.

07 Qt Text Editor - Errors on QAction and QKeySequence

In Pyqt6 QAction was moved to QtGui, QKeySequence requires the StandardKey addition

from PyQt6.QtWidgets import *
from PyQt6.QtGui import QKeySequence, QAction

class MainWindow(QMainWindow):
    def closeEvent(self, e):
        if not text.document().isModified():
            return
        answer = QMessageBox.question(
            window, None,
            "You have unsaved changes. Save before closing?",
            QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel
        )
        if answer & QMessageBox.Save:
            save()
            if text.document().isModified():
            	# This happens when the user closes the Save As... dialog.
            	# We do not want to close the window in this case because it
            	# would throw away unsaved changes.
                e.ignore()
                
        elif answer & QMessageBox.Cancel:
            e.ignore()

app = QApplication([])
app.setApplicationName("Text Editor")
text = QPlainTextEdit()
window = MainWindow()
window.setCentralWidget(text)

file_path = None

menu = window.menuBar().addMenu("&File")
open_action = QAction("&Open")
def open_file():
    global file_path
    path = QFileDialog.getOpenFileName(window, "Open")[0]
    if path:
        text.setPlainText(open(path).read())
        file_path = path
open_action.triggered.connect(open_file)
open_action.setShortcut(QKeySequence.StandardKey.Open)
menu.addAction(open_action)

save_action = QAction("&Save")
def save():
    if file_path is None:
        save_as()
    else:
        with open(file_path, "w") as f:
            f.write(text.toPlainText())
        text.document().setModified(False)
save_action.triggered.connect(save)
save_action.setShortcut(QKeySequence.StandardKey.Save)
menu.addAction(save_action)

save_as_action = QAction("Save &As...")
def save_as():
    global file_path
    path = QFileDialog.getSaveFileName(window, "Save As")[0]
    if path:
        file_path = path
        save()
save_as_action.triggered.connect(save_as)
menu.addAction(save_as_action)

close = QAction("&Close")
close.triggered.connect(window.close)
menu.addAction(close)

help_menu = window.menuBar().addMenu("&Help")
about_action = QAction("&About")
help_menu.addAction(about_action)
def show_about_dialog():
    text = "<center>" \
           "<h1>Text Editor</h1>" \
           "&#8291;" \
           "<img src=icon.svg>" \
           "</center>" \
           "<p>Version 31.4.159.265358<br/>" \
           "Copyright &copy; Company Inc.</p>"
    QMessageBox.about(window, "About Text Editor", text)
about_action.triggered.connect(show_about_dialog)

window.show()
app.exec()

A question on pyqt5

I am making a software and gonna distribute it (for free),so still I need to buy a licence from riverbank?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.