InteractiveConsole (irc support & code completion)

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 6667 yourNickname your real name
!/join #panda3d

and join the panda3d irc channel :slight_smile:

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 :slight_smile: .

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:

  • Support for copy, cut paste
    • limits: can only copy / cut the whole line
  • Support for scrolling in the output (page-up/down)
  • Support for scrolling the last input’s (arrow-up/down)
  • Split up the components into different files
    • panda3d / commandline / irc / interactiveconsole / clipboard

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
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

in the 3d window:

enter ‘self.’

  • this should list the available functions and variables in self.

enter ‘import testAddon’
enter ‘testAddon.’

  • this should print out the first five lines of the file (if it prints some ‘import’ lines it will be fine)

enter ‘!/’

  • this should list you some possible irc commands

enter ‘!/CONNECT yourusername your real name’

  • this should print a lot of messages while connecting to the irc server
    enter ‘/quit’

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.


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 :wink: .

  • 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
    I just tried ctrl-c on the real command line and … the app was killed :laughing: .

  • 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/", line 215, in parsecmd
#     self.connect( )
#   File "/home/laurens/code/panda3d/interactiveConsole/src/", line 65, in connect
#     self.port = int( parametersList[1] )
# - '/CONNECT 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 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 :slight_smile: .

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()

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, 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 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

  • lists the available functions
    testAddon (no dot after testAddon)
  • lists the first lines of a class or a file… this should help you, if need to know the parameters of a class or a function. It should possibly list he doc string instead… (please tell me you opinion, if you would like the source or the doc)

having nothing entered and pressing prints the general help message of the console (the one on startup)

I made some small changes to and tested it under KDE and Gnome:

  • fixed self.klipper
  • dcop loads also under gnome, but throws an exception when you try to use it, so I try if it works just after defining the class.
  • test if dcop was a succes, otherwise try gtk

This is the relevant part of the code:

    import pydcop
    class clipboardClass:
      def __init__( self ):
        self.klipper = pydcop.DCOPObject("klipper", "klipper")
      def setText( self, pasteString ):
      def getText( self ):
        return self.klipper.getClipboardContents()
    # Test if we really use KDE
    print "I: using pydcop clipboard"
    found = True
  if not found:

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? :slight_smile:

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 ?