i updated the code once again. trying to improve the readability, visual appearance and functionality.
i updated the code of the first post.
i updated the code once again. trying to improve the readability, visual appearance and functionality.
i updated the code of the first post.
I added a irc backend to the console
with the default settings you can enter
!/connect irc.freenode.net 6667 yourNickname your real name
!/join #panda3d
and join the panda3d irc channel
having no ! in front of a line will execute it as normal python code.
This works both from the panda3d window and the command line.
That’s really cool! I have been working on my own console, inspired by your work, but having an irq client in there is really cool .
We ought to put this into panda. Could you guys remind me in a few days? Send me an email.
another night has passed and changes have been implemented:
Download:
Under the link of the top post
If it’s really going to be added to panda3d, it would be great if ppl could test it on other platforms (im running current cvs under osx). The irc is currently using the python’s socket which might cause diffferent behavior under other platforms, i dont know if using the panda3d networking could be used for that. The clipboard has been tested under linux and osx, but not yet on windows, so i only know that the pygtk and the osx clipboard modules work.
Added some stuff:
The console is now toggled via ESC (can be changed in shared.py)
Pressing F1 will try to help you in what you are doing
Pressing Tab will try to autocomplete whatever you are writing (but will need some more improvements)
i got to ask a linux user for help, testing the basic features of the console. Interesting to me is also if you are using gnome (aka gtk) or kde, the copy paste function does depend this.
how to test the basic functions:
start the console using the test.py
in the 3d window:
enter ‘self.’
enter ‘import testAddon’
enter ‘testAddon.’
enter ‘!/’
enter ‘!/CONNECT irc.freenode.net yourusername your real name’
enter ‘something’ <press your-copy command (usually <ctrl+c>>
paste to some other application like a text editor and check if it’s the same.
copy something from anywhere (only a number of character (not multiple lines yet))
go to the panda3d window and press your paste command (usually <ctrl-v), check if the text you pasted appeared on the command line
copy multiple lines from anywhere. (do not copy some python code which would delete your harddrive)
go to the panda3d window and press you paste command.
if it has not crashed until now most stuff seems to be working fine.
You can also do the same tests on the commandline, but i have checked that already a linux box i have remote access to.
Thanks
Tested with KDE. Few points:
"enter ‘testAddon.’ " gives me a list of the available functions and variables in testAddon, not “the first 5 lines”. However, I would think that getting a list is better than a few lines of code .
Upon crtl-c, the contents of the “command line” are on the X clipboard, but not the KDE clipboard. So pasting with the mouse’s middle-button works, but ctrl-v does not.
For some reason Klipper, my clipboard manager, freezes after pressing ctrl-c in your console. It unfreezes when I quit test.py.
I just tried ctrl-c on the real command line and … the app was killed .
connecting to IRC gives this error:
# Unexpected error in ircClientClass:
# - <type 'exceptions.ValueError'>
# - invalid literal for int() with base 10: 'yourusername'
# - File "/home/laurens/code/panda3d/interactiveConsole/src/irc.py", line 215, in parsecmd
# self.connect( parsedcmd.group(2).strip() )
# File "/home/laurens/code/panda3d/interactiveConsole/src/irc.py", line 65, in connect
# self.port = int( parametersList[1] )
# - '/CONNECT irc.freenode.net yourusername your real name'
The rest seems to work ok.
Ups… Sorry i made error in my descriptions…
The connect line must be like this:
!/connect irc.freenode.net 6667 yourname your real name
Thanks for a lot for testing it.
I have already included 3 different types of clipboard types for linux (xsel, xclip and gtk). I’ll have a look if i can include the kde clipboard somehow…
Ah, yes, now IRC works.
You’re a brave person to take on all those different clipboards on Linux .
well i actually relied on quite a lot of code found on the internet which helped me implementing this code.
I have searched for a kde/qt clipboard api but didnt find anything until now. If anybody know/finds something i would be happy to add it. I’ll look further but it doesnt look promising right now.
In KDE you can call certain functions of other programs using ‘dcop’. There are python bindings for this. On Fedora Core 7 I had to install the ‘kdebindings’ package to get it. This is a short example that speaks for itself:
import pydcop
klipper = pydcop.DCOPObject("klipper", "klipper")
mystring = klipper.getClipboardContents()
klipper.setClipboardContents(mystring)
I added the code snippet you sent to the cliboard functions. However i can not really test this, so if you could check it again if it works better now, i’d be happy.
If it still does not work as desired and you feel experienced enougth you could have a look at the clipboard.py, which is actually pretty simple. It’s implementing a clipboardClass for each type of backend, with the functions getText and setText. You can also call the clipboard.py alone to test it.
The only more difficult type of class in there is the applicationFinderClass which searches the PATH variable for files, storing the name of the application and the path leading to it. You should not need to change anything in there.
I have been thinking about using multiple type of clipboards at once, which can work well on copy (copy from panda3d window). But pasting would be difficult, as determining what the last copy from the os is, is eighter time consuming (poll the current value of the clipboard all the times and use the last changed one) or not really forseeable (just take the value from 1 backend)…
Oh and one thing more…
There is the and the function…
so i made a mistake in the descriptions again…
import testAddon
testAddon.
having nothing entered and pressing prints the general help message of the console (the one on startup)
I made some small changes to clipboard.py and tested it under KDE and Gnome:
This is the relevant part of the code:
try:
import pydcop
class clipboardClass:
def __init__( self ):
self.klipper = pydcop.DCOPObject("klipper", "klipper")
def setText( self, pasteString ):
self.klipper.setClipboardContents(pasteString)
def getText( self ):
return self.klipper.getClipboardContents()
# Test if we really use KDE
clipboardClass().getText()
print "I: using pydcop clipboard"
found = True
except:
pass
if not found:
try:
Works under KDE and Gnome on my system.
About the first five lines or the doc string: I would show doc if it is there and otherwise the first few lines.
Will XFCE also be supported?
Thanks Laurens, i’ve added your changes to the code.
I’m not really sure, but i think the xfce clipboard should be working with the pygtk bindings. However if it doesnt work, there are 2 fallback types for linux, ‘xclip’ and ‘xsel’ , these should bind the default X-server clipboard.
Pro-rsoft: It would be great if you could test it under your environment as well and tell me if it works.
I have fixed a bug i found while using the console, pressing the help button (F1) caused it to crash quite often (when using invalid syntax). (download link in the first post)
If anybody uses the console, please leave a message so i know how much interest exists for it, and how much it is tested. Also post feature requests you have.
Kewl thanks for this fix!
I already use the console for one of my projects, and have planned to use it in my other project as well.
If I may request a feature, it would be 1 more interface : onscreen IDE. So I could program dynamically onscreen.
Of course, one would need a console-IDE switch too.
Once done, it would be reaaaaally cool.
What pushed me asking for this is simply because I can’t get my transparent stay-on-top IDE window to win against the underlaying 3d window. I guess that due to Windows can’t blend ordinary application and real-time rendering, including 3d render, movie, and …uhm… what else ? Audio visualizer works.
Any clue about that ? I guess it’s bcoz realtime alpha-blending for those things is simply too heavy.
How about Linux ?