Thursday, April 4, 2013

Installing pyside-tools on Fedora 14

I was trying to do some tinkering with pyside in Fedora 14 today, but I came across a frustrating error when trying to launch designer-qt4:


undefined symbol: gst_x_overlay_set_window_handle

I needed to downgrade to phonon 4.4.2 from 4.5
Here are the steps I used to get around it:

  1. sudo yum remove phonon
  2. Disable the yum update repo in /etc/yum.repos.d/fedora-updates.repo
  3. sudo yum install phonon
  4. Reenable the yum update repo
  5. sudo yum install pyside-tools
  6. relaunched designer-qt4 and it works as expected


Now I can continue developing in pyside...

Wednesday, February 13, 2013

Copying byte string from a C function to a Python string using ctypes


Disclaimer: I am no Python expert so if anyone has a better solution then let me know.

I was writing a script that would retrieve a byte string from a C library and copy it to a python string object.   I wanted to take those bytes and put them into a Python string object.
Per the ctypes documentation, setting the restype of the function to c_char_p would have simply returned a null-terminated string; a c_void_p is needed instead.

Sample C Function

extern "C" char* createBuffer(int* numBytes)
{
    char* myArray = new char[10000];
    //I'm just using memset to set the data.  
    //Of course your function will fill this array some other way
    memset(myArray, 0, 10000);       
    *numBytes = 10000;
    return myArray;
}

Python Code


from ctypes import *

libMyCLib = cdll.LoadLibrary('libMyCLib.so')
createBufferFunc = libMyCLib.createBuffer

createBufferFunc.restype = c_void_p
bufLen = c_int()

bufferPtr = createBufferFunc(byref(bufLen))

stringBuffer = create_string_buffer(bufLen.value)
memmove(stringBuffer, bufferPtr, bufLen.value)
bufferDataStr = stringBuffer[:]
#bufferDataStr is the python string object containing the buffer data





Wednesday, November 28, 2012

Xbox 360 Wireless Controller with XBMC on Windows

I just purchased the Xbox 360 Wireless Controller for Windows.  This controller was pretty easy to install.  I wanted to have the controller also operate XBMC.  I am running XBMC 12 with Windows 7.

When I first started up XBMC, none of the controller inputs were recognized.
The file you will need to update is

C:\Program Files (x86)\XBMC\system\keymaps\joystick.Microsoft.Xbox.360.Controller.xml

Here is the working file that I was able to simply drop in.  Hopefully this works for you as well.
joystick.Microsoft.Xbox.360.Controller.xml


Sunday, August 14, 2011

Running vmware-tools on Fedora 14

I was having some trouble installing vmware-tools.

First run uname -r to see the kernel version you're running.
Then make sure that the following packages match your kernel

kernel-headers
kernel-devel
-----------------------------------------------------------
sudo yum install kernel-headers-`uname -r`
sudo yum install kernel-devel-`uname -r`
-----------------------------------------------------------

If your kernel-headers version is more recent than your kernel, just remove it, then reinstall it specifying the version. That should do it.
Again, hope this helps someone.

Tuesday, January 25, 2011

Disabling QCombobox items

So I ran into the problem in Qt a while back of not being able to disable certain items in a QComboBox widget. Since when I was looking for it I couldn't find a solution, I figured I'd post the solution here even though nobody will probably ever read it.

You have to use the QAbstractItemModel's setFlags() method. Wait, what do you mean there's no setFlags() method? Oh, well just use the setData() method and have the role as 'Qt::UserRole - 1'. Because that makes so much sense. bleh. I hope qt fixes that.

Unfortunately I can't take a screenshot of it right now. But here's my solution anyways. Hope this helps somebody.


----------------------------------------------------------------------------------------------------------------
// Get the index of the value to disable
QModelIndex index = ui.comboBox->model()->index(1,0);

// This is the effective 'disable' flag
QVariant v(0);
//the magic

ui.comboBox->model()->setData( index, v, Qt::UserRole -1);
----------------------------------------------------------------------------------------------------------------

Wednesday, October 7, 2009

Keyboard layout all jacked up when VNC'ing into Gnome

So I got Ubuntu 9.04 installed on my wanna be HTPC. I try to VNC ( ultraVNC) into via PuTTy through my desktop windows box and when I try to type stuff it all comes out stupid. The keyboard layout was completely jacked. I hit an 's' and out comes a 'b'. So anyways looking around on them world wide internets I find a bunch of people with the same problem. I have no clue as to how it works, but it worked.

Here's the fix:


in your ~/.vnc/xstartup file, make it look like this

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
export XKL_XMODMAP_DISABLE=1 ##### <<<<<<>
/etc/X11/Xsession

It was a pain in the ass to find so I'm "e-blogging" about it. Hope this helps someone out there.

Saturday, August 29, 2009

This is my new world wide blog!

it's fantastic!