Go to advanced search

by RogerW
Wed Apr 15, 2015 4:52 pm
Forum: C/C++
Topic: IDE for C++
Replies: 12
Views: 28344

Re: IDE for C++

Opinions will differ. I would be very reluctant to give up using an IDE for C++ development. For many years I used Visual Studio. I retired 14 years ago and only recently came back to programming. The ability to have multiple files open on different tabs, see the header file definition of an identif...
by RogerW
Thu Apr 09, 2015 4:40 pm
Forum: Python
Topic: Best programming environment
Replies: 15
Views: 3425

Re: Best programming environment

I use Eclipse (with PyDev) on the PC and geany on the pi. I have samba running on the pi so can use normal explorer to transfer files. A good alternative for file transfer is FileZilla.

Roger Woollett
by RogerW
Wed Apr 08, 2015 3:41 pm
Forum: Graphics programming
Topic: Best way to accomplish 2 gauges
Replies: 5
Views: 10428

Re: Best way to accomplish 2 gauges

You can create a gauge class by inheriting tkinter.Canvas. Then you can have as many as you like.
This link shows one way to do this
http://www.raspberrypi.org/forums/viewt ... 65#p733365
The design may not suit you but you could modify the code.

Roger Woollett
by RogerW
Sat Apr 04, 2015 8:21 am
Forum: Beginners
Topic: Simple graphic design for a dashboard
Replies: 8
Views: 4881

Re: Simple graphic design for a dashboard

Yes the files do need to be in the same directory - I should have said. As it stands the meter is fairly basic but should provide a base that you can modify should you need. You can call the fuction blob to change the colour of the blob over the needle axis. I thought this might be good as a warning...
by RogerW
Fri Apr 03, 2015 4:13 pm
Forum: Beginners
Topic: Simple graphic design for a dashboard
Replies: 8
Views: 4881

Re: Simple graphic design for a dashboard

I don't know if you can use python. If you can this is a simple class to show a circular meter. import tkinter as tk import tkinter.font as tkf import math # class to show a gauge or panel meter class Meter(tk.Canvas): def __init__(self,master,*args,**kwargs): super(Meter,self).__init__(master,*args...
by RogerW
Fri Apr 03, 2015 8:44 am
Forum: Python
Topic: Python GUI?
Replies: 21
Views: 6075

Re: Python GUI?

This is yet another attempt to give some starting point code for a GUI. It has a menu which you can delete if you do not need it and one button. Clearly you can add more widgets.

http://www.raspberrypi.org/forums/viewt ... 2&t=105749

Roger Woollett
by RogerW
Tue Mar 31, 2015 4:45 pm
Forum: Python
Topic: PYTHON Loop for servo control?
Replies: 12
Views: 3255

Re: PYTHON Loop for servo control?

I get a syntax error and a pointer at line 12
Missing colon?

Roger Woollett
by RogerW
Tue Mar 31, 2015 2:01 pm
Forum: General discussion
Topic: Poor choice of mounting holes: should be 3 mm, not 2.9 mm !
Replies: 29
Views: 27049

Re: Poor choice of mounting holes: should be 3 mm, not 2.9 m

These guys do nice nylon M2.5 screws
http://www.hobbytronics.co.uk/hardware/nuts-bolts

and this company do good stainless M2.5 fasteners
http://www.accuscrews.co.uk/5-precision-screws

Both are reasonably priced in my opinion.

Roger Woollett
by RogerW
Sun Mar 29, 2015 2:23 pm
Forum: Python
Topic: Python/tkinter template
Replies: 3
Views: 3091

Re: Python/tkinter template

After my first post I discovered that my code worked when started by Eclipse (on a PC) or Geany (on a Pi) but not when started by idle. I have changed the code to use destroy() rather than quit(). Would anyone care to comment on the "correct" way to close an app. import tkinter as tk import tkinter....
by RogerW
Sun Mar 29, 2015 11:30 am
Forum: Python
Topic: Python/tkinter template
Replies: 3
Views: 3091

Python/tkinter template

I have been teaching myself Python mostly in order to write GUI code using tkinter. I have found a wide variety of styles in the sample code I have seen and have been trying to develop a consistent approach. To this end I have written a "template" app to use as a starting point for future programs. ...
by RogerW
Sun Mar 22, 2015 3:04 pm
Forum: Python
Topic: Problem with threads
Replies: 7
Views: 939

Re: Problem with threads

pass is essentially a null operation so what you had was an endless cpu loop. I see you are using a Pi2 so you might expect your two threads to run on two cores and not have a problem. However from comments elsewhere Python does not do this. Perhaps someone more knowledgable can give the details. Ro...
by RogerW
Sun Mar 22, 2015 2:45 pm
Forum: Python
Topic: Problem with threads
Replies: 7
Views: 939

Re: Problem with threads

Your main thread code ends with

Code: Select all

while True:
    pass
This will soak up all the CPU cycles. Try changing to:

Code: Select all

while True:
    time.sleep(0.5)
Roger Woollett
by RogerW
Thu Mar 19, 2015 2:36 pm
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Re: Web based user interface

Thanks for that. Websockets do look interesting. Google seems to bring up several references to Python implementations. Is there a prefered one for use in the server?

Roger Woollett
by RogerW
Thu Mar 19, 2015 2:06 pm
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Re: Web based user interface

Many thanks for the comments and pointers. I would still prefer to start from scratch rather than use existing code but I hope to use these links at least for guidance.

Roger Woollett
by RogerW
Mon Mar 16, 2015 5:12 pm
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Re: Web based user interface

Thanks for that. I am without broadband ATM but will check your link when the new router arrives.

Roger Woollett
by RogerW
Fri Mar 13, 2015 3:30 pm
Forum: Java
Topic: Java Programming on pi
Replies: 6
Views: 3358

Re: Java Programming on pi

Another possibility is geany which appears to know about java.

Roger Woollett
by RogerW
Thu Mar 12, 2015 9:26 am
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Re: Web based user interface

B.Goode wrote:WebIOPi is another close match to your requirements.
Thanks for that - I don't think it is quite what I am looking for but I need to go back and look more closely.

Roger Woollett
by RogerW
Wed Mar 11, 2015 5:05 pm
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Re: Web based user interface

Thank you Laurens. I think that will help. However if I have understood correctly you control the LEDs directly from the php code. I want to use a separate Python app. Remember this is just a testbed. For the real thing the app will be far more complicated.

Roger Woollett
by RogerW
Wed Mar 11, 2015 4:44 pm
Forum: Networking and servers
Topic: Web based user interface
Replies: 13
Views: 4721

Web based user interface

I would like to write an application that uses a web page as the user interface. As a testbed I have in mind the following: A web page with a button. When the button is pressed it sends a message to a Python app which flips an LED on/off. The Python app then sends a message to the web page so it can...
by RogerW
Thu Mar 05, 2015 9:29 am
Forum: Python
Topic: Main thread not in main loop
Replies: 13
Views: 6677

Re: Main thread not in main loop

Its a fairly common situation to set up a handler fuction for a paticular event. In this case I imagine the Tk window is sent a WM_DELETE_WINDOW message when the close button is pressed. By calling the protocol function you establish your own handler function. Then when the button is pressed your fu...
by RogerW
Wed Mar 04, 2015 6:32 pm
Forum: Python
Topic: Main thread not in main loop
Replies: 13
Views: 6677

Re: Main thread not in main loop

You need to call root.protocol(WM_DELETE_WINDOW,exit_fn) from your setup code. Then when you hit the X exit_fn is called.

In exit_fn you stop the thread and call root.destroy.

My code is structured a little differently but you should see what I mean.

Roger Woollett
by RogerW
Wed Mar 04, 2015 5:19 pm
Forum: Python
Topic: Main thread not in main loop
Replies: 13
Views: 6677

Re: Main thread not in main loop

I am not at all certain but I think the problem arrises from the way you close the app. I assume you use the close (X) button on the Tk window. I suggest you intercept that - my code uses "self.protocol('WM_DELETE_WINDOW',self.quit_app)". In the handler function tell the thread to finish and wait fo...
by RogerW
Tue Mar 03, 2015 6:21 pm
Forum: Python
Topic: Main thread not in main loop
Replies: 13
Views: 6677

Re: Main thread not in main loop

The sleep was just for the benefit of the example. In your case there is no reason why you cannot loop continuously.

Roger Woollett
by RogerW
Tue Mar 03, 2015 5:36 pm
Forum: Python
Topic: Main thread not in main loop
Replies: 13
Views: 6677

Re: Main thread not in main loop

I had this problem. It happens if you call a tk object directly from a thread. The solution I found was to use a queue object. The thread puts a message on the queue and the display object periodically checks the queue. import tkinter as tk import tkinter.ttk as ttk import threading as th import tim...
by RogerW
Mon Mar 02, 2015 4:57 pm
Forum: General discussion
Topic: Can I delete a Start menu entry
Replies: 2
Views: 1238

Re: Can I delete a Start menu entry

Thats done it - thanks.

While on the subject of the start menu do other people find that the Raspberry Pi Help entry fails with "Invalid desktop entry file"

Roger Woollett

Go to advanced search