Go to advanced search

by tom.slick
Tue Apr 05, 2016 8:47 pm
Forum: Python
Topic: Scratch a Python
Replies: 10
Views: 1610

Re: Scratch a Python

Try this http://code.activestate.com/recipes/134892/ class _GetchUnix: def __init__(self): import tty, sys def __call__(self): import sys, tty, termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) finally: termios.tcsetattr(f...
by tom.slick
Sun Apr 03, 2016 11:22 pm
Forum: Python
Topic: print results in pyqt?
Replies: 1
Views: 752

Re: print results in pyqt?

Adding labels to your layouts is the easiest way. def main(): app = QtGui.QApplication(sys.argv) tabs = QtGui.QTabWidget() tab1 = QtGui.QWidget() tab2 = QtGui.QWidget() tabs.setWindowTitle('Weather') tabs.resize(250, 150) vBoxlayout1 = QtGui.QVBoxLayout() vBoxlayout2 = QtGui.QVBoxLayout() vBoxlayout...
by tom.slick
Thu Mar 31, 2016 10:33 pm
Forum: Python
Topic: Open with python 3
Replies: 3
Views: 835

Re: Open with python 3

Add the correct shebang to the top of your script

Code: Select all

#!/usr/bin/python3
by tom.slick
Sun Mar 27, 2016 6:12 am
Forum: Python
Topic: WiringPi-Python
Replies: 13
Views: 4973

Re: WiringPi-Python

Warnings are nothing to worry about and from your output above you have wiringpi installed in python2 and python3.

Good luck and have fun
by tom.slick
Sat Mar 26, 2016 11:07 pm
Forum: Python
Topic: WiringPi-Python
Replies: 13
Views: 4973

Re: WiringPi-Python

it seems that there is a problem with the instructions. [email protected]:~/WiringPi-Python/WiringPi $ swig2.0 -python wiringpi.i or swig3.0 -thread -python wiringpi.i swig2.0: ../../Source/Modules/lang.cxx:332: Language::Language(): Assertion `!this_' failed. Aborted [email protected]:~/WiringPi-Python/WiringPi ...
by tom.slick
Sat Mar 26, 2016 4:00 pm
Forum: Python
Topic: WiringPi-Python
Replies: 13
Views: 4973

Re: WiringPi-Python

What are you trying to do? Install wiringpi git clone git://git.drogon.net/wiringPi cd wiringPi ./build install wiringpi2-python apt-get install -y python-dev python-setuptools python-pip git clone https://github.com/Gadgetoid/WiringPi2-Python.git cd WiringPi2-Python python setup.py install From the...
by tom.slick
Sat Mar 26, 2016 7:51 am
Forum: Python
Topic: Pyobfuscate ?
Replies: 17
Views: 2800

Re: Pyobfuscate ?

OP said "just a fun (and challenging) hobby." I don't care if you use C or python, it can be cracked. To someone that wants to see the source then there is nothing that you can do. But for 98% of the people out there then some something as simple as base64 is more then enough. If having fun is part ...
by tom.slick
Fri Mar 25, 2016 9:33 pm
Forum: Python
Topic: Pyobfuscate ?
Replies: 17
Views: 2800

Re: Pyobfuscate ?

This is every basic, but fits the fun part. Use base64 python 2 example import base64 exec(base64.b64decode('CnByaW50ICAnSGVsbG8nCmEgPSByYXdfaW5wdXQoJ0lzIHRoaXMgZ29vZCBlbm91Z2g/IHkvbicpCmlmIGEgPT0gJ3knOgogIHByaW50ICdHb29kIHlvdSBoYXZlIHlvdXIgYW5zd2VyJwplbHNlOgogIHByaW50ICd3ZWxsIHRoYXQgc3Vja3MnCg=='))...
by tom.slick
Fri Mar 25, 2016 9:10 pm
Forum: Python
Topic: WiringPi-Python
Replies: 13
Views: 4973

Re: WiringPi-Python

from the readme file for WiringPi2-Python
https://github.com/Gadgetoid/WiringPi2- ... ter/README

Code: Select all

import wiringpi2
by tom.slick
Fri Mar 25, 2016 6:40 am
Forum: Python
Topic: RF Signal to launch kweb
Replies: 1
Views: 388

Re: RF Signal to launch kweb

by tom.slick
Fri Mar 25, 2016 6:24 am
Forum: Python
Topic: Python update rrdtool database with empty records
Replies: 1
Views: 833

Re: Python update rrdtool database with empty records

1. You are only updating once at the end 2. You import rrdtool and don't use it, instead you use something else? Use the rrdtool module and update in the loop #!/usr/bin/python import rrdtool import sys import time import os import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) DEBUG = 1 # read SPI data fr...
by tom.slick
Fri Mar 25, 2016 5:00 am
Forum: Python
Topic: GPIO.add_event_detect
Replies: 4
Views: 3196

Re: GPIO.add_event_detect

The event detect is running is a separate thread. Your parent thread would continue to run. To use your example, if you pressed your button at 10 seconds in (290 remaining) and your event took 200 seconds to complete, then when the event is finished you would have 90 seconds remaining on your call t...
by tom.slick
Wed Mar 23, 2016 11:55 pm
Forum: Python
Topic: GPIO.add_event_detect
Replies: 4
Views: 3196

Re: GPIO.add_event_detect

Like a property, so your second example is the correct usage.
by tom.slick
Wed Mar 23, 2016 11:35 pm
Forum: Python
Topic: Raspberry pi Sense HAT pong game
Replies: 1
Views: 763

Re: Raspberry pi Sense HAT pong game

All you need to do is add a few variables to keep track of the key presses and the time. Increment your key up/down variables in your while not game_over loop and set your game start time before the loop import time up_key_pressed = 0 down_key_pressed = 0 start_time = time.time() while not game_over...
by tom.slick
Wed Mar 16, 2016 12:10 am
Forum: Python
Topic: GPIO without keyboard (Python)
Replies: 11
Views: 1959

Re: GPIO without keyboard (Python)

Create a bash script that launches your python script.

Code: Select all

#!/bin/bash
sudo python example_gpio.py
Clicking on the bash script will launch the python script with sudo
as long as you don't need to type in a password it will work.

Go to advanced search