Go to advanced search

by RogerW
Sun Feb 28, 2016 4:10 pm
Forum: Graphics programming
Topic: Tkinter root.after help
Replies: 15
Views: 8602

Re: Tkinter root.after help

To me your use of a class object does not make sense. Also root is not a keyword - just the name of a variable. A lot of sample code uses root as the name of a Tk object which "owns" the main window. This code does what I think you are trying to do. If you are using python 2 change tkinter to Tkinte...
by RogerW
Thu Feb 25, 2016 5:05 pm
Forum: General discussion
Topic: How to transfer files from host machine to raspberry pi B
Replies: 17
Views: 1765

Re: How to transfer files from host machine to raspberry pi

You can get a "cross over" ethernet cable to connect the two. You might be able to use a straight one - I am not sure. Hopefully someone with experience will come forward.
by RogerW
Wed Feb 24, 2016 5:48 pm
Forum: Off topic discussion
Topic: Learn a programming language.
Replies: 19
Views: 2661

Re: Learn a programming language.

There is quite a lot to be said for starting with C if you want to become a professional programmer. But it is not easy or quick. You also need to understand the underlying hardware and software environments. C is not for babes and innocents. You need to understand how pointers relate to hardware ad...
by RogerW
Sat Feb 20, 2016 11:34 am
Forum: Python
Topic: tkinter user modal windows
Replies: 5
Views: 1811

Re: tkinter user modal windows

This program creates a simple modal dialog. See Mainframe.on_click to see how data is transferred. # speedtrap.py # written by Roger Woollett import tkinter as tk from time import time,localtime class RegDialog(tk.Toplevel): # A dialog box to get reistration number # This is not needed unless the ca...
by RogerW
Sat Feb 20, 2016 9:19 am
Forum: Python
Topic: tkinter user modal windows
Replies: 5
Views: 1811

Re: tkinter user modal windows

You seem to have got the windows implemented ok. Remember that when a window is destroyed the python object that implements the window still exists so you can retrieve data from it.
by RogerW
Fri Feb 19, 2016 10:05 pm
Forum: Python
Topic: Dictionary for C struct?
Replies: 6
Views: 1174

Re: Dictionary for C struct?

Yes __init__ is a constructor. Destructors do exist but they do not work very well so tend not to be used. It is better to implement your own function and call it explicitly.
by RogerW
Fri Feb 19, 2016 4:43 pm
Forum: Python
Topic: Dictionary for C struct?
Replies: 6
Views: 1174

Re: Dictionary for C struct?

You can use a class instead of a struct and a list instead of an array. class data: def __init__(self,start_hour,start_min,stop_hour,stop_min): self.start_hour = start_hour self.start_min = start_min self.stop_hour = stop_hour self.stop_min = stop_min intervals = [data(6,30,6,35),data(7,0,7,30),data...
by RogerW
Wed Feb 17, 2016 3:09 pm
Forum: Python
Topic: Explain code example
Replies: 4
Views: 1909

Re: Explain code example

I do not know the hc595 but it would appear that data has to be latched into it. The nature of the data is up to you.
by RogerW
Tue Feb 16, 2016 9:31 am
Forum: Python
Topic: Explain code example
Replies: 4
Views: 1909

Re: Explain code example

GPIO.output(SDI, 0x80 & (dat << bit)) This is a shift and mask operation. We are dealing here with an 8 bit byte. The << operator performs a shift so dat is shifted left bit times. If bit is 7 the bottom bit of dat will be shifted to the top. The & operator performs a bitwise AND. That is if a bit i...
by RogerW
Sun Feb 07, 2016 3:13 pm
Forum: Python
Topic: Spidev and second bus
Replies: 1
Views: 451

Spidev and second bus

I am running a recently updated Raspbian Jessie. I would like to use the second (auxilliary) SPI bus. I can do this using pigpio by setting the A bit in the call to spi_open. Using spidev if I call open(1,2) it gives a file not found error. I suspect it is looking for /dev/spidev1.2. I think the spi...
by RogerW
Sat Feb 06, 2016 9:17 am
Forum: Troubleshooting
Topic: 16x2 LCD screen Not Working
Replies: 6
Views: 2069

Re: 16x2 LCD screen Not Working

You could try my code.
/www.raspberrypi.org/forums/viewtopic.p ... 34#p898534

In the second fiile change
lcd = LCD(23,24,25,26,27,22)
to
lcd = LCD(22,21,17,23,25,24)

see the comments in lcd.py
by RogerW
Wed Feb 03, 2016 2:51 pm
Forum: Python
Topic: LCD 16x2 control
Replies: 12
Views: 1649

Re: LCD 16x2 control

A bit late in the day I am afraid but here is a class that controls an LCD display. 16 or 20 character, 2 or 4 lines. # lcd.py # written by Roger Woollett import RPi.GPIO as gp from time import sleep class LCD(): # class to control a Hitachi type LCD display # It should work for 16 or 20 character b...
by RogerW
Tue Feb 02, 2016 2:28 pm
Forum: General discussion
Topic: register if the person is still in bed
Replies: 13
Views: 1556

Re: register if the person is still in bed

Another possibility. Put a pressure sensor under one or more of the bed legs. Then work out if your weight is in the bed.
by RogerW
Tue Feb 02, 2016 1:59 pm
Forum: Graphics, sound and multimedia
Topic: Speedometer for cars using Pi
Replies: 8
Views: 6462

Re: Speedometer for cars using Pi

if you want to use tkinter this may be of use. # meter.py # class to show a gauge or panel meter # written by Roger Woollett from sys import version_info if version_info[0] < 3: import Tkinter as tk import tkFont as tkf else: import tkinter as tk import tkinter.font as tkf import math class Meter(tk...
by RogerW
Sun Jan 31, 2016 2:16 pm
Forum: Python
Topic: help in tkinter
Replies: 9
Views: 1080

Re: help in tkinter

I suggest you learn how to use the python debugger and then step through your code.
by RogerW
Sun Jan 31, 2016 12:33 pm
Forum: Python
Topic: help in tkinter
Replies: 9
Views: 1080

Re: help in tkinter

You still need to give the buttons names that are not function names.

Also you need to call
win.mainloop()
at the end
by RogerW
Sat Jan 30, 2016 5:43 pm
Forum: Python
Topic: help in tkinter
Replies: 9
Views: 1080

Re: help in tkinter

I suspect its not the main problem but you cannot have a variable called start and a function called start.

The Buttons need to have win as their first parameter and you need to call pack() for them if they are to be visible.
by RogerW
Mon Jan 25, 2016 3:07 pm
Forum: Python
Topic: Tkinter -- cursor invisible
Replies: 7
Views: 4651

Re: Tkinter -- cursor invisible

You can call config for any window. This code hides the cursor for the main window but you could hide it for a frame or individual widget. The cursor is still there and does work but you cannot see it. # Trythings.py # written by Roger Woollett import tkinter as tk class Frame(tk.Frame): # class inh...
by RogerW
Fri Jan 22, 2016 6:47 pm
Forum: Python
Topic: Is there a way to change label fg colour with Tk?
Replies: 9
Views: 2646

Re: Is there a way to change label fg colour with Tk?

You can use the configure fuction on the label instead of the button.
by RogerW
Fri Jan 22, 2016 9:47 am
Forum: Python
Topic: Is there a way to change label fg colour with Tk?
Replies: 9
Views: 2646

Re: Is there a way to change label fg colour?

You need to call the cofigure method of the button. Try this: from tkinter import * CounterValue = 0 class Application(Frame): def __init__(self, master): super(Application, self).__init__(master) self.grid() self.counter = IntVar() self.colour = StringVar() self.counter.set(0) self.colour.set("blac...
by RogerW
Tue Jan 19, 2016 8:11 pm
Forum: Python
Topic: Syntax problem, help
Replies: 18
Views: 2695

Re: Syntax problem, help

In a Python 3.4.2 shell (so I assume I am running Python 3.4.2) I have the following Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "copyright", "credits" or "license ()" for more information >>> #!/usr/bin/env python my entry >>> print ("Hello, World!") my entry saved prog...
by RogerW
Tue Jan 19, 2016 5:50 pm
Forum: Python
Topic: Syntax problem, help
Replies: 18
Views: 2695

Re: Syntax problem, help

Since you are typing python all.py at the command prompt the shebang line should be irrelavent. You are already invoking the python interpreter directly the line print ("Hello all") should work with any version of python, 2.7 effectively ignores the brackets. Since the error message refers to the op...
by RogerW
Thu Jan 14, 2016 9:29 am
Forum: Troubleshooting
Topic: tkinter program does not start on RPi - but works on WIN7
Replies: 1
Views: 380

Re: tkinter program does not start on RPi - but works on WIN

Change the last line to
Gui.mainloop()

The brackets are missing. I am not sure how it runs on windows but it does for me too.

Also the class Hauptseite is repeated.
by RogerW
Wed Jan 13, 2016 1:33 pm
Forum: C/C++
Topic: GUI with C
Replies: 9
Views: 3548

Re: GUI with C

I am not sure if this will help but it might. https://github.com/RogerWoollett/PyView This is a python/tkinter program that shows different aspects of system performance (a bit like task manager). It does this by switching windows. In this case I use a menu but you might be able to use the same idea...

Go to advanced search