Categories
Database Development

How to create mysql database and table using with QtSql.QSqlDatabase

I am moving to MySQL from sqlit3 with some reasons. I am using python3.7 and QtSql.QSqlDatabase. I am trying below code but showing Driver not loaded Driver not loaded What am i missing. print(list(map(str, QSqlDatabase.drivers()))) [‘QSQLITE’, ‘QODBC’, ‘QODBC3’, ‘QPSQL’, ‘QPSQL7’] Below is my example code: from PyQt5 import QtCore, QtGui, QtWidgets, QtSql from PyQt5.QtSql import […]

Categories
Mastering Development

How to save and restore widget properties that is unique for each instance of the widget?

I would like the ability to save and restore the widget state (properties and values) in my PyQt5 app. The widget state should be saved to an .ini file. This has already been demonstrated in the following Stackoverflow answers: How to save text in QLineEdits in PyQt even if the Widget gets closed? Loading Widgets […]

Categories
Mastering Development

Return old value to combobox with dynamic search and autocompletion

I have a reimplemented comboBox that performs dynamic search and autocompletion (code isn’t mine). The problem is when I type something, that doesn’t match any value in combobox list and press enter – I receive an empty string. But I wish to receive instead an old value, that was in combobox before I started to […]

Categories
Mastering Development

Drag & Drop Widget Implementation Error- RuntimeWarning: MetaObjectBuilder::addMethod: Invalid method signature provided for “dropped”

This is the custom widget I created for this: from PySide2.QtCore import * from PySide2.QtWidgets import * from PySide2.QtGui import * import os class DragDropWidget(QWidget): def __init__(self, parent=None): super(DragDropWidget, self).__init__(parent) self.setAcceptDrops(True) def dragEnterEvent(self, event): if event.mimeData().hasUrls: event.accept() else: event.ignore() def dragMoveEvent(self, event): if event.mimeData().hasUrls: if len(event.mimeData().urls()) != 1: event.ignore() else: event.setDropAction(Qt.CopyAction) event.accept() else: event.ignore() def […]

Categories
Mastering Development

PyQt5: How to Resize mainwindow to fit a Stackedwidget or Stackedlayout

I have a MainWindow with a Dockwidget attached to it for the sole purpose of switching between multiple Stackedwidget/StackedLayout The Issue i am having is that the StackedLayout holds a particular widget that displays a large image which resizes the MainWindow as expected but when switching from that Widget to another using the docked widget […]

Categories
Mastering Development

I don’t able to convert this python file to exe file to be able to run on windows? [closed]

This uses sklearn module too. I have tried to convert this python file using cx_freeze, auto-py-to-exe, pyinstaller. But I didn’t able to convert it, its giving me no errors but also dont execute. I have merged all my modules in one . from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QApplication, QWidget, QTableWidget, QTableWidgetItem, […]

Categories
Mastering Development

Pyqt5 Crashes when setText is called

I’m making a typing test, which displays a word that you type. Once you type the word and its correct, the display should change to a different word. However, when I call the setText function. My app crashes with the error ‘NoneType’ object has no attribute to ‘setText’. What am I doing wrong?! PS: All […]

Categories
Mastering Development

How to link Qt Designer button to a function in a separate file [duplicate]

I’m new to Python and I’ve searched for an answer but couldn’t find it (or rather couldn’t properly implement it). I’ve generated a window with a few buttons in QtDesigner’s file named "arch.ui", converted to arch.py. As I’ll be updating GUI occasionally, I don’t want to create functions in arch.py, so I’ve created a main.py […]

Categories
Mastering Development

ValueError: could not convert string to float: when using matplotlib, arduino and pyqt5

While using an arduino code (also connecting pin 13 to A0 in an arduino uno) to have changing values int PinOutput = 13; int PinInput = A0; int inph; int inpl; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(PinInput, INPUT); pinMode(PinOutput, OUTPUT); } void loop() { // put your […]

Categories
Mastering Development

How to capture output of external python script in a PyQt5 QTextEdit? [duplicate]

I am trying to run an external Python script and capture the printed output in a PyQt5 QTextEdit, but that code only captures its own (prueba.py) output. The main.py script calls prueba.py (PyQt5 window) witch execute the target script (detect.py) prueba.py # -*- coding: utf-8 -*- # Form implementation generated from reading ui file ‘prueba.ui’ […]