473,738 Members | 5,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi layout on ControlDesk using Python [solved]

12 New Member
Hi,

I m using controDesk Developer V2.7 Unicode under Windows2000 Pack4. I do automotive mesurments with Simulink V6.3 files using a micro-autobox. it works correctly. I want to have a second layout working with the principal one that I can activate and desactivate online with a simple switch (on the principal layout). Is it possible and if yes how this can be done?

Thnaks.
Nov 8 '06 #1
22 4970
medlot
12 New Member
This is the Python code of the button located in the principal layout:

# -*- coding: cp1252 -*-


def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a()

Purpose : WriteData event handler.

Parameters : None

"""
print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_WriteDa ta called"

and this is the name of the layout I want to activate :
layout_2.py

they are located in the same directory

any questions are welcome
Thanks
Nov 8 '06 #2
bartonc
6,596 Recognized Expert Expert
This is the Python code of the button located in the principal layout:

# -*- coding: cp1252 -*-


def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a()

Purpose : WriteData event handler.

Parameters : None

"""
print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_WriteDa ta called"

and this is the name of the layout I want to activate :
layout_2.py

they are located in the same directory

any questions are welcome
Thanks
I like to import at the top of the code to show dependencies:
Expand|Select|Wrap|Line Numbers
  1. import layout_2
  2.  
Then, in your event handler, it's:
Expand|Select|Wrap|Line Numbers
  1. layout_2.SomeFunction()
  2.  
If the code has been written "in line" like most scripts, then you need to change it in to a callable like this:
Expand|Select|Wrap|Line Numbers
  1. def SomeFunction():
  2.     # Indent all the code of the script here
  3.  
  4. if __name__ == "__main__":
  5.     SomeFuntion()    # Will still run as a script
  6.  
Nov 9 '06 #3
medlot
12 New Member
Hi, thanks for the help but unfortunately I didn't succeed to do it. Taking a simple example, I have 2 layouts, layout_1 and layout_2. On the first there is an OnOffButton. In the second one, I ve got a display panel. This is what I wrote in the file _layout_1.py:

# -*- coding: cp1252 -*-

def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a()

Purpose : WriteData event handler.

Parameters : None

"""
import layout_2
print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_WriteDa ta called"

def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_Click():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_Click()

Purpose : Click event handler.

Parameters : None

"""

print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_Click called"

def SomeFunction():
# Indent all the code of the script here
if __name__ == "__main__":
SomeFuntion() # Will still run as a script
""""""""""""""" """"""""""""""" """""

This is what it is written in the _layout_2.py file:

def On_Instrumentat ion_layout_2_dS PACEDisplayCont rol_Click():
"""
Syntax : On_Instrumentat ion_layout_2_dS PACEDisplayCont rol_Click()

Purpose : Click event handler.

Parameters : None

"""
print "On_Instrumenta tion_layout_2_d SPACEDisplayCon trol_Click called"

def layout_2.SomeFu nction():
# Indent all the code of the script here

if __name__ == "__main__":
SomeFuntion() # Will still run as a script

'"""""""""""""" """"""""""" ""
You notice that I added what you have posted in your first message.
Nothing happens when I click on the button at the animation mode. I access to the Python code through the events window by editing WriteData. What I want to do is to activate and disactivate the layout2 window by clicking on the OnOffButton through the animation mode.

this is a picture of my interface: http://mederreg.lotfi. free.fr/python/event_python.JP G

Thanks
Nov 9 '06 #4
bartonc
6,596 Recognized Expert Expert
I like to import at the top of the code to show dependencies:
Expand|Select|Wrap|Line Numbers
  1. import layout_2
  2.  
Then, in your event handler, it's:
Expand|Select|Wrap|Line Numbers
  1. layout_2.SomeFunction()
  2.  
If the code has been written "in line" like most scripts, then you need to change it in to a callable like this:
Expand|Select|Wrap|Line Numbers
  1. def SomeFunction():
  2.     # Indent all the code of the script here
  3.  
  4. if __name__ == "__main__":
  5.     SomeFuntion()    # Will still run as a script
  6.  
Sorry if this wasn't very clear.. The last section describes layout2. layout 1 should look like this:
Expand|Select|Wrap|Line Numbers
  1. # -*- coding: cp1252 -*-
  2. import layout2
  3.  
  4. def
  5.    On_Instrumentation_layout_1_dSPACEPushButtonControl_WriteData():
  6.     """
  7.    Syntax : On_Instrumentation_layout_1_dSPACEPushButtonControl_WriteData()
  8.  
  9.     Purpose : WriteData event handler.
  10.  
  11.     Parameters : None
  12.  
  13.     """
  14.     print "On_Instrumentation_layout_1_dSPACEPushButtonControl_WriteData called"
  15.     layout2.somefunction()
  16.  
  17.  
Nov 9 '06 #5
bartonc
6,596 Recognized Expert Expert
Please read "posting guidelines or the gray background lettering where you create you post to learn how to use [code] tags. It helps us to help you. Thanks,
Barton


Hi, thanks for the help but unfortunately I didn't succeed to do it. Taking a simple example, I have 2 layouts, layout_1 and layout_2. On the first there is an OnOffButton. In the second one, I ve got a display panel. This is what I wrote in the file _layout_1.py:

# -*- coding: cp1252 -*-

def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_WriteDat a()

Purpose : WriteData event handler.

Parameters : None

"""
import layout_2
print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_WriteDa ta called"

def On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_Click():
"""
Syntax : On_Instrumentat ion_layout_1_dS PACEPushButtonC ontrol_Click()

Purpose : Click event handler.

Parameters : None

"""

print "On_Instrumenta tion_layout_1_d SPACEPushButton Control_Click called"

def SomeFunction():
# Indent all the code of the script here
if __name__ == "__main__":
SomeFuntion() # Will still run as a script
""""""""""""""" """"""""""""""" """""

This is what it is written in the _layout_2.py file:

def On_Instrumentat ion_layout_2_dS PACEDisplayCont rol_Click():
"""
Syntax : On_Instrumentat ion_layout_2_dS PACEDisplayCont rol_Click()

Purpose : Click event handler.

Parameters : None

"""
print "On_Instrumenta tion_layout_2_d SPACEDisplayCon trol_Click called"

def layout_2.SomeFu nction():
# Indent all the code of the script here

if __name__ == "__main__":
SomeFuntion() # Will still run as a script

'"""""""""""""" """"""""""" ""
You notice that I added what you have posted in your first message.
Nothing happens when I click on the button at the animation mode. I access to the Python code through the events window by editing WriteData. What I want to do is to activate and disactivate the layout2 window by clicking on the OnOffButton through the animation mode.

this is a picture of my interface: http://mederreg.lotfi. free.fr/python/event_python.JP G

Thanks
Nov 9 '06 #6
medlot
12 New Member
I did, it will be ok for the next time, any help for my request?
Nov 9 '06 #7
bartonc
6,596 Recognized Expert Expert
I did, it will be ok for the next time, any help for my request?
Yep, Two posts down.
Nov 9 '06 #8
bartonc
6,596 Recognized Expert Expert
I did, it will be ok for the next time, any help for my request?
Maybe you could post layout_2 also for me to better understand.
Nov 9 '06 #9
medlot
12 New Member
I ve posted the python code of layout2 in the previous message but here it is again:

Expand|Select|Wrap|Line Numbers
  1. #  -*- coding: cp1252 -*-
  2.  
  3.  
  4. def On_Instrumentation_layout_2_dSPACEDisplayControl_Click():
  5.     """
  6.     Syntax      : On_Instrumentation_layout_2_dSPACEDisplayControl_Click()
  7.  
  8.     Purpose     : Click event handler.
  9.  
  10.     Parameters  : None
  11.  
  12.     """
  13.     print "On_Instrumentation_layout_2_dSPACEDisplayControl_Click called"
  14.  
  15. def layout_2.SomeFunction():
  16.     # Indent all the code of the script here
  17.  
  18. if __name__ == "__main__":
  19.     SomeFuntion()    # Will still run as a script
  20.  

As you can see, it is just a simple layout with a display control.
Nov 9 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3789
by: The_Incubator | last post by:
As the subject suggests, I am interested in using Python as a scripting language for a game that is primarily implemented in C++, and I am also interested in using generators in those scripts... Initially I was justing looking at using Python for some event scripting. So basically an event would trigger an object to run the appropriate Python script, which would be run in it's entirety and return control to the C++ code. After looking...
8
2112
by: Sridhar R | last post by:
Hi, I am a little experienced python programmer (2 months). I am somewhat experienced in C/C++. I am planning (now in design stage) to write an IDE in python. The IDE will not be a simple one. I had an idea of writing the IDE in C/C++, as it is a big project, bcoz of the following 1. if python is used, then the memory required for running the IDE will be high.
5
1775
by: Will | last post by:
Is there multi-media support in Python? So I can... 1 - play video in all the standard formats... windows & Mac? 2 - play flash files 3 - Power Point 4 - Standard graphic formats 5 - Sound in all the standard formats 6 - etc Please note requirements: And, on video's, flash files, Power Point, Graphic
28
5557
by: Anthony Williams | last post by:
Good morning, I'm currently designing a site, using CSS, and wish to create a variable width two-column layout, with header and footer, and one fixed-width column on the left. Previously, I would have used a table to do this, using the following code: <table width="100%">
8
4600
by: Joakim Persson | last post by:
Hello all. I am involved in a project where we have a desire to improve our software testing tools, and I'm in charge of looking for solutions regarding the logging of our software (originating from embedded devices). Currently, we are using a heavyweight, proprietary log tool developed by another part of the company. This tool contains all "standard" logging functionality, but we also need to insert "debug" log points in the software of...
29
16566
by: 63q2o4i02 | last post by:
Hi, I'm interested in using python to start writing a CAD program for electrical design. I just got done reading Steven Rubin's book, I've used "real" EDA tools, and I have an MSEE, so I know what I *want* at the end of this; I just have never taken on a programming task of this magnitude. I've seen that some are using python as a utility language for existing CAD environments, and I've also found some guy who's writing a 2d drafting...
0
1202
by: P. Adhia | last post by:
Hello, I was wondering if anyone is successfully using using Python(2.5)+DB2+pydb2. I get an error in all situations. It seems that this problem might be limited to python 2.5. A quick Google search suggests that with Python 2.5, memory model has become more stringent and mixing various types of memory calls are likely to produce this error. I am not familiar with writing Python C extensions, but from what I can tell, pydb2 extension is...
9
1907
by: dominiquevalentine | last post by:
Hello, I'm a teen trying to do my part in improving the world, and me and my pal came up with some concepts to improve the transportation system. I have googled up and down for examples of using python to create a city street but I can not find any. my objective is to replicate a section of los angeles using python, and program the street lights and cars and whatnot. Should I be looking towards 3D to do this?
14
7316
by: Nathan Pinno | last post by:
How do I factor a number? I mean how do I translate x! into proper Python code, so that it will always do the correct math? Thanks in advance, Nathan P.
0
8968
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
8787
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9259
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,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
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
6053
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
4569
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
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.