Skip to content

Instantly share code, notes, and snippets.

View eyllanesc's full-sized 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 August 15, 2018 02:16
Raspberry Pi Course Code
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 June 26, 2022 20:11
Functions to save and restore Widgets in PyQt.
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())
@eyllanesc
eyllanesc / CheckBoxExample.py
Last active July 16, 2017 18:29
CheckBoxExample
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)
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()
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())
#!/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 March 21, 2018 07:17
Matplotlib with PyQt4
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 July 28, 2017 15:24
PyQt5 Dynamically add rectangles to QML grid
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
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")
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)