473,770 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to do a callback from externally triggered event

I am using PIL to make images that I need to display in a sequence.
The image needs to change when a an event happens from a serial port.

I call the following function to display the image, but then the
application is waiting for an event. I need to return to the main
code which is sending commands to a serial port and waiting for data
to return then displaying the next chart.

def display(R,G,B):
img = Image.new('RGB' ,(1000,1000),(2 4,24,24))
draw = ImageDraw.Draw( img)
draw.rectangle( (400,400,600,60 0), fill=(R,G,B))

root = Tkinter.Tk()
photo = ImageTk.PhotoIm age(img)
label = Tkinter.Label(r oot, image=photo)
label.pack()
root.mainloop()
Here is the (very)rough program
#!/usr/local/bin/pythonw

# Import needed modules
import Tkinter, ImageTk
import Image, ImageDraw
import time, serial

def measure():
ser.write("M\n" )
line = ser.readline()
print line,

def display(R,G,B):
img = Image.new('RGB' ,(1000,1000),(2 4,24,24))
draw = ImageDraw.Draw( img)
draw.rectangle( (400,400,600,60 0), fill=(R,G,B))

root = Tkinter.Tk()
photo = ImageTk.PhotoIm age(img)
label = Tkinter.Label(r oot, image=photo)
label.pack()
root.mainloop()
def setup_comm():
ser = serial.Serial('/dev/tty.KeySerial1' )
ser.write("PR70 1\n")
time.sleep(.2)
ser.flushOutput ()
line = ser.readline()
print line
# Program Starts here

setup_comm()
display(0, 255, 255)
measure()
display(255, 0, 255)
measure()
display(255, 255, 0)
measure()
Feb 17 '08 #1
0 916

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2055
by: ma740988 | last post by:
// file sltest.h #ifndef SLTEST_H #define SLTEST_H class CallbackBase // herb shutters gotW source .. { public: virtual void operator()() const { }; virtual ~CallbackBase() = 0; };
3
1389
by: Marten Van Keer | last post by:
Hello; I have an application that waits for TCP packets to arrive on a network stream. A callback function(using an asynccallback delegate) is implemented to tell the application some packets have arrived. At the same time the application uses the Timer object. The Tick-event of this timer is set to 50 seconds. The problem is when the callback function is triggered the timer tick-event
2
1770
by: Marten Van Keer | last post by:
Hi; I have two applications A and B *** Application B listens on a network stream with a callback function:
1
10448
by: Abel Chan | last post by:
Hi there, I was trying to write a simple NT services using .NET 2.0 and fileSystemWatcher control. The goal is to poll documents from a watch directory and ftp them to a remote web site. I created a Windows Services project using VS2005. Drag a fileSystemWatcher control to the designer and added the following code. Here is what I found out when I create a new file under the watch directory: 1) Using notepad - OnCreate event...
2
620
by: Wizzard | last post by:
I have a repeater with and imagebutton on a page useing VS2005 ASP.Net 2.0 <asp:Repeater ID="Repeater1" runat="server" > <ItemTemplate> <div> <asp:ImageButton ImageUrl="button.gif" ID="ImageButton1" runat="server" /> <p><%# Eval("Name") %></p> </div> </ItemTemplate>
0
1457
by: skberen | last post by:
Issue: We have a web user control on a web page (aspx) that uses the new ASP.Net 2 feature Client Callback. The web user control is using a CheckBoxList control and button control to allow the user to select multiple values for displaying data on the page. When the user clicks on the button control the client callback is triggered. The Client Callback works great. I have no issues with the actual callback processing. The issue is...
5
6862
by: jason.neo | last post by:
Hi all experts, I am going nuts with this Invalid postback or callback argument thingy with .Net 2.0 I am building a file attachment module which relays on a Datatable stored in session (yeah i know its unhealthy, but its the only "clean" approach which I can think of to avoid tranfering temp files onto the server) to maintain the list of attached files before the "commit" action is done to transfer all the files onto the server.
1
1724
by: FordPrefect | last post by:
I am using a 3rd party dll (not COM). One of the dll functions requires a callback function. I have used either DllImport or Declare to properly (I think) declare the function. The function requires a pointer to a function for the call back, and a pointer to a data duffer. I am using a delegate to define the callback function. The callback is triggered correctly and I am able to print the result of the callback to Debug.Write. I can...
0
2115
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via callback.setHandler1(callback1) this only seems to affect pythons ability to trigger an "event" in c. PyObject *Handler is always NULL even after I call Register_Handler(...). I thought there was some magic here that was assigning the pointer *Handler to my python...
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.