- Why should I have to open another window, paste, and clip out what I need?
- Why should I have to manually unescape ampersands and other HTML entities escaped by the XML generator?
- Why should I have to prepend "eg.plugins." to the result?
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
[SOLVED] Developer tool: "Copy as Python"
[SOLVED] Developer tool: "Copy as Python"
The current method of retrieving an action's corresponding Python code (Ctrl+C) has a number of pitfalls:
Last edited by blackwind on Thu Jul 07, 2016 12:45 am, edited 1 time in total.
/bw
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Developer tool: "Copy as Python"
=> 0.4.1.r1600
- Attachments
-
- CopyAsPython_1.jpg (12.7 KiB) Viewed 9328 times
-
- CopyAsPython_2.jpg (18.87 KiB) Viewed 9328 times
-
- CopyAsPython_3.jpg (11.66 KiB) Viewed 9328 times
Re: Developer tool: "Copy as Python"
Excellent !
miljbee
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
TCP Events : A Better Network Event Sender/Receiver Plugin.
The Network Event Sender/Receiver in C#
Get events in EG from Google Calendar.
Re: Developer tool: "Copy as Python"
Very nice.
Re: Developer tool: "Copy as Python"
A small bug: Copy as Python doesn't work as expected with Python Script objects.
/bw
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Developer tool: "Copy as Python"
This is weird.blackwind wrote:A small bug: Copy as Python doesn't work as expected with Python Script objects.
I tried it just now and no problem I have encountered.
Probably it will depend on the content. Can you please attach a script to which it is a problem?
Pako
Re: Developer tool: "Copy as Python"
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
<Action Name="Disable WOW64 Redirection">
EventGhost.PythonScript(u'import win32file\nwin32file.Wow64DisableWow64FsRedirection()\n')
</Action>
</EventGhost>Code: Select all
eg.plugins.sion="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
<Action Name="Disable WOW64 Redirection">
EventGhost.PythonScript(u'import win32file\nwin32file.Wow64DisableWow64FsRedirection()\n')/bw
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Developer tool: "Copy as Python"
So now it is completely clear.
The bug is not related to Python Script action, but any action that is renamed (its label in the tree is written in italics).
But it is obvious, that it happens most frequently just with Python Script
.
You can download the corrected file TreeItem.py.
Pako
The bug is not related to Python Script action, but any action that is renamed (its label in the tree is written in italics).
But it is obvious, that it happens most frequently just with Python Script
You can download the corrected file TreeItem.py.
Pako
Re: Developer tool: "Copy as Python"
Ah, that's interesting. Yep, Python Scripts are the only actions I ever rename, and I've done so for every single one in my config.
One last thing: I was thinking, wouldn't it make more sense if Python Commands and Scripts copied as their contained code rather than an eg.plugins reference? So, this:
...rather than this:
I, for one, can't think of any scenario in which I'd want the latter over the former.
One last thing: I was thinking, wouldn't it make more sense if Python Commands and Scripts copied as their contained code rather than an eg.plugins reference? So, this:
Code: Select all
import win32file
win32file.Wow64DisableWow64FsRedirection()Code: Select all
eg.plugins.EventGhost.PythonScript(u'import win32file\nwin32file.Wow64DisableWow64FsRedirection()\n')/bw
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Developer tool: "Copy as Python"
Yes, it is a good idea. It's logical.
I thought it would be very simple. But it gave me quite a hard time.
I had received ... instead of ... and long time I could not figure out how to get rid of.
But now it works. Again, you can download the new version of TreeItem.py file.
Pako
I thought it would be very simple. But it gave me quite a hard time.
I had received ...
Code: Select all
import win32file\nwin32file.Wow64DisableWow64FsRedirection()Code: Select all
import win32file
win32file.Wow64DisableWow64FsRedirection()But now it works. Again, you can download the new version of TreeItem.py file.
Pako
Re: Developer tool: "Copy as Python"
Excellent. I'd recommend removing the trailing " + chr(10)" on both lines so the code that's copied is identical to the code written, but other than that, looks good!
/bw
