HZGN.COM
welcome to my space
X
Feng Shui | Graphic Design | Cosmetics | Causes and Organizations | Regulatory Compliance | Gadgets and Gizmos | Computer Forensics | Tools and Equipment | Related articles
Welcome to:hzgn.com
Search:  
 HOME   Python Development Documentations (outdated)

Python Development Documentations (outdated)

Published by: admin 2009-01-07

  • in the cvs, doc folder, pythonreadme.txt
    that's all the doc available for now.
    i planned to write one but it's too boring and if i suceeded to code python on xbox without documentation, other people can too!


  • i never found any info on how the get drive free space, so i'm posting this for others who need it. please let me know if there is any better way (i realize some of the code in the ftp part could be done better, but i wrote it when i was first learning, and i'm too lazy to fix it =] )

    this code first tries to use the httpapi (available after july 21, 05) and then defaults to getting it via ftp. if you don't want to support older versions, you can modify this to use the httpapi inteface only.

    hope this helps someone

    ruuk

    # returns number of full megabytes

    def free(drive,ip,user,password):
    return space(drive,ip,user,password)

    ftpmode = false
    try:
    from xbmc import executehttpapi
    except:
    ftpmode = true

    space = none
    if not ftpmode:
    def space(drive,ip,user,password):
    drives = {'c':'115',
    'e':'117',
    'f':'118',
    'g':'119'}
    free = executehttpapi('getsysteminfo(' + drives[drive] + ')')
    val = free.split(drive + ': ',1)[1]
    val , type = val.split(' ',1)
    type = type[:2].upper()
    return convert_value(val,type)
    else:
    def space(drive,ip,user,password):
    try:
    from ftplib import ftp
    ftp = ftp(ip,user,password)
    space_line = ftp.retrlines('list', blah)
    ftp.quit()
    bits = space_line.split(drive + ':\\ ')
    last = bits.pop()
    final = last.split(' ')
    amount = float(final[0])
    type_get = final[1]
    bits = type_get.split(']')
    type = bits[0]
    return convert_value(amount,type)
    except:
    return 0

    def blah(line):
    pass

    def convert_value(val,type):
    if type == 'mb':
    return int(val)
    elif type == 'gb':
    return int(float(val) * 1024)
    else:
    return 0


  • @alx5962 has your scripting tutorial moved somewhere else ?


  • i'm not alex5962. he leaved python scene.
    it's scripting tutorial was on alexpoet server, but seems to be offline....

    anyway, you can get its tutorial on xbmc online manual :
    http://manual.xboxmediacenter.de/wakka.p....g&v=vr9 (http://manual.xboxmediacenter.de/wakka.php?wakka=pythonscripting&v=vr9)


  • good job


  • jmarshallnz has added so we can execute every builtin function :)
    for example execute a xbe
    start a slideshow
    the options are endless!

    the online doc i have on my website is updated to that.
    xbmc.html (http://home.no.net/thor918/xbmc/xbmc.html?nocach=2)
    xbmcgui.html (http://home.no.net/thor918/xbmc/xbmcgui.html?nocach=2)


    look here see all thing we can execute!
    http://manual.xboxmediacenter.de/wakka.p....s&v=98v (http://manual.xboxmediacenter.de/wakka.php?wakka=builtinfunctions&v=98v)
  • FNWiki Feedback - Forum Nokia Wiki::
    ja työkalut Appareils, documentations et outils Geräte, Dokumentationen That way people would not find outdated information pretending to be the real deal.
    http://wiki.forum.nokia.com/index.php/FNWiki_Feedback
    HOME


  • sounds like you haven't updated xbmc.


  • thor918's more recent python docs


    xbmc.html (http://home.no.net/thor918/xbmc/xbmc.html)

    xbmcgui.html (http://home.no.net/thor918/xbmc/xbmcgui.html)


  • it's in the online manual as well (a bit easier on the eyes)

    cheers,
    jonathan


  • documentation updated!

    added new functions, corrected bugs and also added new tutorials.

    get it here (http://members.cox.net/alexpoet/downloads/docs/)


  • a great python reference for those who have programming experience but not in python is

    python 2.3 quick reference guide (http://rgruet.free.fr/pqr2.3.html)

    it brought me up to speed with how things are done in python land very quickly without being bogged down with the basics of programming.

    -asteron


  • i have added a new file to cvs called makedoc.py in the scripts directory. it will generate html files of xbmc and xbmcgui which will be placed in q:\\doc\\python.


  • hi,
    i couldn't find any documentation of the supported constances and values for windows.
    finally i found them in the sources...
    here are they:

    // analogue - don't change order
    #define key_button_a 256
    #define key_button_b 257
    #define key_button_x 258
    #define key_button_y 259
    #define key_button_black 260
    #define key_button_white 261
    #define key_button_left_trigger 262
    #define key_button_right_trigger 263

    #define key_button_left_thumb_stick 264
    #define key_button_right_thumb_stick 265

    #define key_button_right_thumb_stick_up 266 // right thumb stick directions
    #define key_button_right_thumb_stick_down 267 // for defining different actions per direction
    #define key_button_right_thumb_stick_left 268
    #define key_button_right_thumb_stick_right 269

    // digital - don't change order
    #define key_button_dpad_up 270
    #define key_button_dpad_down 271
    #define key_button_dpad_left 272
    #define key_button_dpad_right 273

    #define key_button_start 274
    #define key_button_back 275

    #define key_button_left_thumb_button 276
    #define key_button_right_thumb_button 277

    #define key_button_left_analog_trigger 278
    #define key_button_right_analog_trigger 279

    #define key_invalid 0xffff

    // actions that we have defined...
    #define action_none 0
    #define action_move_left 1
    #define action_move_right 2
    #define action_move_up 3
    #define action_move_down 4
    #define action_page_up 5
    #define action_page_down 6
    #define action_select_item 7
    #define action_highlight_item 8
    #define action_parent_dir 9
    #define action_previous_menu 10
    #define action_show_info 11

    #define action_pause 12
    #define action_stop 13
    #define action_next_item 14
    #define action_prev_item 15
    #define action_forward 16
    #define action_rewind 17

    #define action_show_gui 18 // toggle between gui and movie or gui and visualisation.
    #define action_aspect_ratio 19 // toggle quick-access zoom modes. can b used in videofullscreen.zml window id=2005
    #define action_step_forward 20 // seek +1% in the movie. can b used in videofullscreen.xml window id=2005
    #define action_step_back 21 // seek -1% in the movie. can b used in videofullscreen.xml window id=2005
    #define action_big_step_forward 22 // seek +10% in the movie. can b used in videofullscreen.xml window id=2005
    #define action_big_step_back 23 // seek -10% in the movie. can b used in videofullscreen.xml window id=2005
    #define action_show_osd 24 // show/hide osd. can b used in videofullscreen.xml window id=2005
    #define action_show_subtitles 25 // turn subtitles on/off. can b used in videofullscreen.xml window id=2005
    #define action_next_subtitle 26 // switch to next subtitle of movie. can b used in videofullscreen.xml window id=2005
    #define action_show_codec 27 // show information about file. can b used in videofullscreen.xml window id=2005 and in slideshow.xml window id=2007
    #define action_next_picture 28 // show next picture of slideshow. can b used in slideshow.xml window id=2007
    #define action_prev_picture 29 // show previous picture of slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_out 30 // zoom in picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_in 31 // zoom out picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_toggle_source_dest 32 // used to toggle between source view and destination view. can be used in myfiles.xml window id=3
    #define action_show_playlist 33 // used to toggle between current view and playlist view. can b used in all mymusic xml files
    #define action_queue_item 34 // used to queue a item to the playlist. can b used in all mymusic xml files
    #define action_remove_item 35 // not used anymore
    #define action_show_fullscreen 36 // not used anymore
    #define action_zoom_level_normal 37 // zoom 1x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_1 38 // zoom 2x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_2 39 // zoom 3x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_3 40 // zoom 4x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_4 41 // zoom 5x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_5 42 // zoom 6x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_6 43 // zoom 7x picture during slideshow. can b used in slideshow.xml window id=2007
    os.cqu.edu.au/usr/share/doc/gnome-applets-2.16.0.1/ChangeLog::
    POTFILES.in: - add translatable files * m4/acinclude.m4: * m4/python.m4: - add This is the HEAD branch, which is unfrozen for development towards G12.
    http://os.cqu.edu.au/usr/share/doc/gnome-applets-2.16.0.1/ChangeLog
    HOME
    #define action_zoom_level_7 44 // zoom 8x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_8 45 // zoom 9x picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_zoom_level_9 46 // zoom 10x picture during slideshow. can b used in slideshow.xml window id=2007

    #define action_calibrate_swap_arrows 47 // select next arrow. can b used in: settingsscreencalibration.xml windowid=11
    #define action_calibrate_reset 48 // reset calibration to defaults. can b used in: settingsscreencalibration.xml windowid=11/settingsuicalibration.xml windowid=10
    #define action_analog_move 49 // analog thumbstick move. can b used in: slideshow.xml window id=2007/settingsscreencalibration.xml windowid=11/settingsuicalibration.xml windowid=10
    #define action_rotate_picture 50 // rotate current picture during slideshow. can b used in slideshow.xml window id=2007
    #define action_close_dialog 51 // action for closing the dialog. can b used in any dialog
    #define action_subtitle_delay_min 52 // decrease subtitle/movie delay. can b used in videofullscreen.xml window id=2005
    #define action_subtitle_delay_plus 53 // increase subtitle/movie delay. can b used in videofullscreen.xml window id=2005
    #define action_audio_delay_min 54 // increase avsync delay. can b used in videofullscreen.xml window id=2005
    #define action_audio_delay_plus 55 // decrease avsync delay. can b used in videofullscreen.xml window id=2005
    #define action_audio_next_language 56 // select next language in movie. can b used in videofullscreen.xml window id=2005
    #define action_change_resolution 57 // switch 2 next resolution. can b used during screen calibration settingsscreencalibration.xml windowid=11


    #define remote_0 58 // remote keys 0-9. are used by multiple windows
    #define remote_1 59 // for example in videofullscreen.xml window id=2005 you can
    #define remote_2 60 // enter time (mmss) to jump to particular point in the movie
    #define remote_3 61
    #define remote_4 62 // with spincontrols you can enter 3digit number to quickly set
    #define remote_5 63 // spincontrol to desired value
    #define remote_6 64
    #define remote_7 65
    #define remote_8 66
    #define remote_9 67

    #define action_play 68 // play current movie. unpauses movie and sets playspeed to 1x. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_left 69 // move left in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_right 70 // move right in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_up 71 // move up in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_down 72 // move down in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_select 73 // toggle/select option in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_value_plus 74 // increase value of current option in osd. can b used in videofullscreen.xml window id=2005
    #define action_osd_show_value_min 75 // decrease value of current option in osd. can b used in videofullscreen.xml window id=2005
    #define action_small_step_back 76 // jumps a few seconds back during playback of movie. can b used in videofullscreen.xml window id=2005

    #define action_music_forward 77 // ff in current song. global action, can be used anywhere
    #define action_music_rewind 78 // rw in current song. global action, can be used anywhere
    #define action_music_play 79 // play current song. unpauses song and sets playspeed to 1x. global action, can be used anywhere

    #define action_delete_item 80 // delete current selected item. can be used in myfiles.xml window id=3 and in myvideotitle.xml window id=25
    #define action_copy_item 81 // copy current selected item. can be used in myfiles.xml window id=3
    #define action_move_item 82 // move current selected item. can be used in myfiles.xml window id=3
    #define action_show_mplayer_osd 83 // toggles mplayers osd. can be used in videofullscreen.xml window id=2005
    #define action_osd_hidesubmenu 84 // removes an osd sub menu. can be used in videoosd.xml window id=2901
    #define action_take_screenshot 85 // take a screenshot
    #define action_powerdown 86 // restart
    #define action_rename_item 87 // rename item

    #define action_volume_up 88
    #define action_volume_down 89

    #define action_mouse 90

    #define action_mouse_click 100
    #define action_mouse_left_click 100
    #define action_mouse_right_click 101
    #define action_mouse_middle_click 102
    #define action_mouse_xbutton1_click 103
    #define action_mouse_xbutton2_click 104

    #define action_mouse_double_click 105
    #define action_mouse_left_double_click 105
    #define action_mouse_right_double_click 106
    #define action_mouse_middle_double_click 107
    #define action_mouse_xbutton1_double_click 108
    #define action_mouse_xbutton2_double_click 109

    #define action_backspace 110
    #define action_scroll_up 111
    #define action_scroll_down 112
    #define action_analog_forward 113
    #define action_analog_rewind 114

    #define action_move_item_up 115 // move item up in playlist
    #define action_move_item_down 116 // move item down in playlist
    #define action_context_menu 117 // pops up the context menu

    // window id defines to make the code a bit more readable
    #define window_invalid 9999
    #define window_home 10000
    #define window_programs 10001
    #define window_pictures 10002
    #define window_files 10003
    #define window_settings_menu 10004
    #define window_music 10005
    #define window_videos 10006
    #define window_system_information 10007
    #define window_settings_general 10008
    #define window_settings_myvideos 10009
    #define window_ui_calibration 10010
    #define window_movie_calibration 10011
    #define window_settings_mypictures 10012
    #define window_settings_filter 10013
    #define window_settings_mymusic 10014
    #define window_settings_subtitles 10015
    #define window_settings_screensaver 10016
    #define window_settings_myweather 10017
    #define window_settings_osd 10018
    #define window_settings_skin 10019
    #define window_scripts 10020
    #define window_video_genre 10021
    #define window_video_actor 10022
    #define window_video_year 10023
    #define window_settings_myprograms 10024
    #define window_video_title 10025
    #define window_settings_cache 10026
    #define window_settings_autorun 10027
    #define window_video_playlist 10028
    #define window_settings_lcd 10029

    // new windows for settings screens
    #define window_settings_ui 10030
    #define window_settings_audio 10031


    #define window_dialog_yes_no 10100
    #define window_dialog_progress 10101
    #define window_dialog_invite 10102
    #define window_dialog_keyboard 10103
    #define window_dialog_volume_bar 10104
    #define window_dialog_sub_menu 10105
    #define window_dialog_context_menu 10106
    #define window_music_playlist 10500
    #define window_music_files 10501
    #define window_music_album 10502
    #define window_music_artist 10503
    #define window_music_genre 10504
    #define window_music_top100 10505
    #define window_virtual_keyboard 11000
    #define window_dialog_select 12000
    #define window_music_info 12001
    #define window_dialog_ok 12002
    #define window_video_info 12003
    #define window_scripts_info 12004
    #define window_fullscreen_video 12005
    #define window_visualisation 12006
    #define window_slideshow 12007
    #define window_dialog_filestacking 12008
    #define window_weather 12600
    #define window_buddies 12700
    #define window_screensaver 12900
    #define window_osd 12901

    // window_id's from 13000 to 13099 reserved for python

    #define window_python_start 13000
    #define window_python_end 13099


    i hope this is the right place to post this, if not tremove it :)


  • sounds like you haven't updated xbmc.
    i have xbmc with an april 6th release. still no luck (my favorite feature is now gone as well :sniffle: reboot via the joystick), falling back now :d


  • for what it's worth, my personal website is back up again. thanks to everyone who hosted the files elsewhere while it was down.


  • it is a good idea to make your scripts handle errors nicely, so they atleast doesn't freeze the box... this trick written below goes alot of the way to avoid that the user is forced to reboot, while still providing debug output.


    import sys, traceback
    import xbmc, xbmcgui
    try: emulating = xbmcgui.emulating
    except: emulating = false

    #get actioncodes from keymap.xml
    action_previous_menu = 10
    action_select_item = 7
    action_parent_dir = 9
    class myclass(xbmcgui.window):
    * * * *def (self):
    * * * * * * * *if emulating: xbmcgui.window.(self)
    * * * * * * * *self.addcontrol(xbmcgui.controlimage(0,0,720,480, "q:\\scripts\\tutorial\\background.gif"))
    * * * * * * * *self.stractioninfo = xbmcgui.controllabel(100, 200, 200, 200, "", "font13", "0xffff00ff")
    * * * * * * * *self.addcontrol(self.stractioninfo)
    * * * * * * * *self.stractioninfo.setlabel("push back to quit, a to display text and b to erase it")
    * * * *def onaction(self, action):
    * * * * * * * *try:
    * * * * * * * * * * * *if action == action_previous_menu:
    * * * * * * * * * * * * * * * *self.close()
    * * * * * * * * * * * *if action == action_select_item:
    * * * * * * * * * * * * * * * *self.straction = xbmcgui.controllabel(300, 300, 200, 200, "", "font14", "0xff00ff00")
    * * * * * * * * * * * * * * * *self.addcontrol(self.straction)
    * * * * * * * * * * * * * * * *self.straction.setlabel("hello world")
    * * * * * * * * * * * *if action == action_parent_dir:
    * * * * * * * * * * * * * * * *self.removecontrol(self.straction)
    * * * * * * * *except:
    * * * * * * * * * * * *self.close() * * * * *#<-------------------------- look here!
    * * * * * * * * * * * *e=sys.exc_info()
    * * * * * * * * * * * *traceback.print_exception(e[0],e[1],e[2])

    mydisplay = myclass()
    mydisplay.domodal()
    del mydisplay



    also, if you are using progress bars. you should encapsulate the creation in a try block and close them in the finally block. that way you ensure that the progressbar is closed if your script chrashes. example:

    * * * * * * * *try:
    * * * * * * * * * * * *self.progressbar=xbmcgui.dialogprogress()
    * * * * * * * * * * * *self.progressbar.create("downloading...")
    * * * * * * * * * * * *
    * * * * * * * * * * * *... do stuff ...
    * * * * * * * *finally:
    * * * * * * * * * * * *self.progressbar.close()




    another thing you want to do is to have timeouts on all your downloads... that is automatic if you use cachedhttp from http://www.xbmcscripts.com . but if you are using urllib or urllib2 you should do like this:

    import socket
    socket.setdefaulttimeout(7.0) #seconds


  • thor918's more recent python docs


    xbmc.html (http://home.no.net/thor918/xbmc/xbmc.html)

    xbmcgui.html (http://home.no.net/thor918/xbmc/xbmcgui.html)
    that documentation describes the:

    class controllist(control)
    * *controllist class.

    controllist(
    * x, y, width, height, font, textcolor,
    * buttontexture, buttonfocustexture,
    * selectedcolor, imagewidth, imageheight,
    * itemtextxoffset, itemtextyoffset,
    * itemheight, space, alignmenty )

    x * * * * * * * * *: integer x coordinate of control
    y * * * * * * * * *: integer y coordinate of control
    width * * * * * * *: integer width of control
    height * * * * * * : integer height of control
    font * * * * * * * : font used for label text e.g. 'font13' (opt)
    textcolor * * * * *: color of item text e.g. '0xffffffff' (opt)
    buttontexture * * *: texture filename for item (opt)
    buttonfocustexture : texture filename for focused item (opt)
    selectedcolor * * *: color of selected item text e.g. '0xffffffff' (opt)
    imagewidth * * * * : integer width of item icon or thumbnail (opt)
    imageheight * * * *: integer height of item icon or thumbnail (opt)
    itemtextxoffset * *: integer x offset of item label (opt)
    itemtextyoffset * *: integer y offset of item label (opt)
    itemheight * * * * : integer height item (opt)
    space * * * * * * *: integer space between items (opt)
    alignmenty * * * * : integer y-axis alignment - see xbfont.h (opt)


    how do i make use of the "selectedcolor" ? once i add some of the properties, i get debug error stating that i am passing too many arguments to the controllist. i am confused with this stuff, as some stuff can be set separately (eg. self.list.setitemheight) but cannot be passed at the time of creation of the control ?
    pls enlighten me *:bomb:


  • python docs (http://members.cox.net/alexpoet/downloads/docs/)

    i started to write this documentation but i need a volunteer to correct my english grammar mistakes *;)
    it's a beginner's guide so everyone is welcome to help out with writting it.


  • there is a new version of the tutorial available on my website (linked below). this is a complete revision, but it still covers primarily the same material.

    so if you've already read alx5962's tutorial and understood it, you probably won't get much more out of the new version.

    but, if you're new to python scripting for the xbox, i think it will be a little easier to read, and it also now comes with a script template to make starting new scripts a little faster/easier.

    hope you enjoy. as always, feedback is welcome.





  • Red Hat's Rough Recovery From CFO Exit
    Windows Live Finds a New, Pre-installed Home

    PRINT Add to favorites
    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Python Development Documentations (outdated) , Please add it free.
     Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 hzgn.com        Site made:CFZ