Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
I may be slow to respond.

Edwin Yllanes eyllanesc

:octocat:
I may be slow to respond.
View GitHub Profile
@eyllanesc
eyllanesc / DHT.py
Last active Aug 15, 2018
Raspberry Pi Course Code
View DHT.py
import Adafruit_DHT
import time
isRunning = True
while isRunning:
try:
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, 4)
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity))
else:
@eyllanesc
eyllanesc / read_and_write_example.py
Last active Jun 11, 2021
Functions to save and restore Widgets in PyQt.
View read_and_write_example.py
import sys
from PyQt5.QtCore import QFileInfo, QSettings
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import qApp, QApplication, QMainWindow, QFormLayout, QLineEdit, QTabWidget, QWidget, QAction
def restore(settings):
finfo = QFileInfo(settings.fileName())
View CheckBoxExample.py
import sys
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QCheckBox, QLineEdit
from functools import partial
class Widget(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setLayout(QVBoxLayout())
self.le = QLineEdit(self)
View main.py
import sys, time
from PyQt4 import QtGui, QtCore
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.setGeometry(50, 50, 500, 200)
self.setWindowTitle("TEST APP!")
self.field_dict = {}
self.home()
View Stadium.py
class Stadium(QWidget):
def __init__(self, pixmap, parent=None):
QWidget.__init__(self, parent=parent)
self.pixmap = pixmap
self.pos = None
self.setMouseTracking(True)
def paintEvent(self, event):
painter = QPainter(self)
w = min(1.0*self.width()/self.pixmap.width(), 1.0*self.height()/self.pixmap.height())
View Plotter3.1.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
#Importing PyQt5 library to construct widgets for Graphic User Interface (GUI) application
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import (QLineEdit, QPushButton, QSlider, QApplication, QVBoxLayout, QHBoxLayout,
QApplication, QWidget, QLabel, QCheckBox, QRadioButton, QPlainTextEdit, QSizePolicy,
QMainWindow,QFrame, QFileDialog, QTableWidgetItem, QTableWidget, QMenu, QMessageBox,
QAction, QToolBar)
@eyllanesc
eyllanesc / canvas.py
Last active Mar 21, 2018
Matplotlib with PyQt4
View canvas.py
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.pyplot as plt
class Canvas(FigureCanvas):
def __init__(self, parent=None):
self.figure = plt.figure()
FigureCanvas.__init__(self, self.figure)
self.setParent(parent)
@eyllanesc
eyllanesc / main.py
Last active Jul 28, 2017
PyQt5 Dynamically add rectangles to QML grid
View main.py
from PyQt5.QtGui import QGuiApplication, QColor
from PyQt5.QtQml import QQmlApplicationEngine, QQmlComponent
from PyQt5.QtCore import QUrl, Qt, QCoreApplication, QAbstractListModel, QModelIndex, QTimer, qsrand, qrand, QTime
from PyQt5.QtQuick import QQuickItem
class Data(object):
def __init__(self, width=35, height=35, color=QColor("red")):
self._width = width
self._height = height
self._color = color
View TestQButtonGroup.py
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
app = QApplication(sys.argv)
w = QWidget()
w.setLayout(QVBoxLayout())
skillP = QCheckBox("Passive")
skillCb = QCheckBox("Combat")
skillCm = QCheckBox("Command")
View QTableWidgetTest.py
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
class Widget(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setLayout(QVBoxLayout())
self.le = QLineEdit(":P", self)