Go to advanced search

by Davies
Mon Nov 13, 2017 4:04 pm
Forum: Beginners
Topic: 8 relay GPIO pins not working
Replies: 1
Views: 360

Re: 8 relay GPIO pins not working

when posting code use the code tags otherwise ur code looses its indentations. "test an 8 way 5v relay which has an external 5v power sourse, which I've grd onto GPIO grd pin." you put 5v power to GPIO ground? does the relay module have a pin labelled jd-vcc like this type?.. http://www.considerit.c...
by Davies
Sun Nov 12, 2017 8:30 pm
Forum: Beginners
Topic: GUI Fullscreen
Replies: 3
Views: 914

Re: GUI Fullscreen

root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight())) should gain fullscreen regardless of screen size perhaps the -pad you use could be cutting it short of ur screen root.overrideredirect(True) removes the top bar, close and minimise buttons root.resizable(width=...
by Davies
Sun Nov 12, 2017 8:17 pm
Forum: Automation, sensing and robotics
Topic: simple temperature monitor and relay activation GUI
Replies: 8
Views: 1613

Re: simple temperature monitor and relay activation GUI

you need to choose a language you want to use, for me it was python but it would be best for you to look through examples of languages and see if you can digest any of it, if you can then use that language. if you dont want to put much effort in and decided to go for say python it would be worth goo...
by Davies
Sun Nov 12, 2017 7:24 pm
Forum: Python
Topic: Your python learning recommendations?
Replies: 5
Views: 596

Re: Your python learning recommendations?

a lot depends on where u want to go with things, for me i was interested in IO and how i could control them, starting with an LED and a button, i followed a guide on how to make the LED light up when the button was pressed. then i wanted to use a graphical button and a on screen box to interact with...
by Davies
Sat Oct 14, 2017 2:22 pm
Forum: Python
Topic: web.py webpage running at host location
Replies: 1
Views: 355

Re: web.py webpage running at host location

ive been able to use threading and webbrowser but now it opens 2 instances of the web page.. import web import threading import webbrowser import time def open_web(): time.sleep(2) webbrowser.open('http://localhost:8080') t1 = threading.Thread(target=open_web) t1.daemon = True t1.start() urls = ( '/...
by Davies
Sat Oct 14, 2017 1:36 pm
Forum: Python
Topic: web.py webpage running at host location
Replies: 1
Views: 355

web.py webpage running at host location

is it possible to have web.py open its own output? for example python script... import web urls = ( '/', 'Index' ) app = web.application(urls, globals()) render = web.template.render('static/') class Index(object): def GET(self): msg = "Hello World" return render.index(msg=msg) if __name__ == "__mai...
by Davies
Sun Oct 08, 2017 3:54 pm
Forum: Python
Topic: 7” Pi display screen overlay text.
Replies: 11
Views: 1244

Re: 7” Pi display screen overlay text.

hey paddy, i was thinking more along the lines of a text overlay also suggested by the OP.. transparency effects and closing/opening of tkinter windows is possible and something i wanted to put into this example but i just dont have time right now, so if the OP is wanting to use tkinter theyll have ...
by Davies
Sat Oct 07, 2017 1:25 pm
Forum: Python
Topic: 7” Pi display screen overlay text.
Replies: 11
Views: 1244

Re: 7” Pi display screen overlay text.

to get the keyboard info you could use pynput from pynput import keyboard def on_press(key): try: print('alphanumeric key {0} pressed'.format( key.char)) except AttributeError: print('special key {0} pressed'.format( key)) def on_release(key): print('{0} released'.format( key)) if key == keyboard.Ke...
by Davies
Mon Jul 03, 2017 10:19 pm
Forum: Python
Topic: Python script for Multiple DS18b20
Replies: 9
Views: 2591

Re: Python script for Multiple DS18b20

it seems to gain the results twice as fast for me when checking 2 temp sensors with threading compared to without threading

post your code
by Davies
Mon Jul 03, 2017 1:13 pm
Forum: Python
Topic: looking for number in string
Replies: 2
Views: 412

Re: looking for number in string

Excellent, thank you elParaguayo
by Davies
Mon Jul 03, 2017 11:04 am
Forum: Python
Topic: looking for number in string
Replies: 2
Views: 412

looking for number in string

hi all, im looking for a number within a string of numbers.. the number im looking for could be 3 or 4 digits long, when the number is 3 digits long there is a chance for another number within the string to be 4 digits but consist of the 3 i want + an additional digit, i do not want to select this o...
by Davies
Mon Jul 03, 2017 8:47 am
Forum: Python
Topic: Python script for Multiple DS18b20
Replies: 9
Views: 2591

Re: Python script for Multiple DS18b20

Have you used the last example I sent with threading? Put your code up n I'll take a look
by Davies
Sun Jul 02, 2017 11:36 am
Forum: Python
Topic: Python script for Multiple DS18b20
Replies: 9
Views: 2591

Re: Python script for Multiple DS18b20

heres a better example using globals without unnecessary wait times. it uses 3 threads, the main thread + 2 we create. your code would potentially use 12 threads or so, essentially making a raspberry pi3 a 4 core 12 thread system for the purpose of your code. import threading import time temperature...
by Davies
Sun Jul 02, 2017 11:10 am
Forum: Python
Topic: Python script for Multiple DS18b20
Replies: 9
Views: 2591

Re: Python script for Multiple DS18b20

Your code is doing exactly the same as mine. So feel free to use my code if you want to no thanks my code closes the file it opened and is a couple of lines shorter per reading. depending on what your doing you may not need to use 11 threads, my previous example run in its own thread with a tkinter...
by Davies
Sat Jul 01, 2017 9:31 pm
Forum: Python
Topic: Python script for Multiple DS18b20
Replies: 9
Views: 2591

Re: Python script for Multiple DS18b20

you could use threading if your wanting to run simultaneous actions. i used a couple of these sensors a while back and just listed one after the next... theres probably better examples but this worked for me.. tempfile1 = open("/sys/bus/w1/devices/28-0***/w1_slave") thetext1 = tempfile1.read() tempf...
by Davies
Mon May 22, 2017 8:01 pm
Forum: Python
Topic: passing a variable (data) to a function/class
Replies: 5
Views: 617

Re: passing a variable (data) to a function/class

thinking about it, pickle would probably be best, if your wanting both files to modify the variable you can just use two pickles, that way both scripts wont try to write the same file. one script could use... import pickle import time def open_file(): global var_1, var_2, var_3 with open('sub.pickle...
by Davies
Mon May 22, 2017 5:33 pm
Forum: Python
Topic: passing a variable (data) to a function/class
Replies: 5
Views: 617

Re: passing a variable (data) to a function/class

if your using threading and want multiple elements to share a global variable within one (.py/.pyc) file, this may be of use to you... import threading import time variable = 0 print "variable = ", variable def var_change1(): global variable variable = 1 print "variable = ", variable def var_change2...
by Davies
Sun May 21, 2017 10:41 am
Forum: Python
Topic: Hanting error when use email function
Replies: 3
Views: 508

Re: Hanting error when use email function

you could wrap which ever part of the code that fails in a try: except: statement try: sendmail() except: pass you could also ping google servers or many other internet/wifi checks ping_hostname = "8.8.8.8" ping_response = os.system("ping -c 10 " + ping_hostname) if ping_response == 0: # ping respon...
by Davies
Wed May 17, 2017 3:52 pm
Forum: Python
Topic: Download from email over pop3
Replies: 5
Views: 760

Re: Download from email over pop3

thank you for explaining that further. looking back through previous scripts i can see that i have written "or" statements repeating variables multiple times, unsure why i couldnt see the error this time around (though self taught over last few years so still very much a noob) ill be using the "in" ...
by Davies
Wed May 17, 2017 3:22 pm
Forum: Python
Topic: Disable exit button
Replies: 2
Views: 1826

Re: Disable exit button

root = tk.Tk() root.overrideredirect(True) root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight())) root.resizable(width=FALSE, height=FALSE) this will disable close and window size buttons, disable screen resize and set your gui to whatever size the screen is, runni...
by Davies
Tue May 16, 2017 5:13 pm
Forum: Python
Topic: Download from email over pop3
Replies: 5
Views: 760

Re: Download from email over pop3

hippy, your awesome!.. thank you very much, thats working :)

am i correct in thinking that for example

Code: Select all

if variable == '123' or 'abc'
would be correct usage, or should normal usage actually be

Code: Select all

if variable == '123' or variable == 'abc'
by Davies
Tue May 16, 2017 4:43 pm
Forum: Python
Topic: Download from email over pop3
Replies: 5
Views: 760

Re: Download from email over pop3

strange... in "get_attachments()" if i remove ' or testing123.txt' from

Code: Select all

if name == 'test123.py' or 'testing123.txt':
the code works without issue, but running with detection of multiple files it fails each time.. can anybody see why? i assumed python would use the "or" clause like any other time...?
by Davies
Tue May 16, 2017 3:59 pm
Forum: Python
Topic: Download from email over pop3
Replies: 5
Views: 760

Download from email over pop3

hi all, im trying to download from an email with a specific subject field. the file will usually download the first time but then fail thereafter. heres the code... import poplib from email import parser frm = [email protected] password = a_password def mail_connection(): pop_conn = poplib.POP3_SSL('pop...
by Davies
Tue May 16, 2017 3:31 pm
Forum: Python
Topic: take input from mail and mark as read
Replies: 2
Views: 370

Re: take input from mail and mark as read

i use pop3 which "marks" emails as read after a successful grab and popconn.quit. apparently it doesnt make a mark that can be seen but is aware of emails already read. you could also delete the messages which have been read.. import poplib from email import parser frm = "your_email" password = "you...
by Davies
Mon Apr 10, 2017 3:40 pm
Forum: Python
Topic: use variable contents not variable name
Replies: 4
Views: 357

Re: use variable contents not variable name

thanks for the reply scotty,
i had to remove the apostrophes around varname ( globals()[varname]) to get the code to return correctly, but i was then able to use that method within my main script.

thanks again, but why wouldnt it be recommended?

Go to advanced search