Aug 032012
 

 

Eclipse Juno looks terrible in Linux Mint 13 with the MATE desktop environment. Here’s an example of part of the screen:

Everything is big and bulky, the tool bar’s style doesn’t really match the theme’s style.

Here are the steps I’ve taken so far to correct this:

  • Create a file called gtkrc, I’ve created one in my ~/eclipse directory:
    gtk-color-scheme = "selected_text_color:#000000"
    style "compact"
    {
      GtkButton::default_border={0,0,0,0}
      GtkButton::default_outside_border={0,0,0,0}
      GtkButtonBox::child_min_width=0
      GtkButtonBox::child_min_heigth=0
      GtkButtonBox::child_internal_pad_x=0
      GtkButtonBox::child_internal_pad_y=0
      GtkMenu::vertical-padding=1
      GtkMenuBar::internal_padding=1
      GtkMenuItem::horizontal_padding=4
      GtkToolbar::internal-padding=1
      GtkToolbar::space-size=1
      GtkOptionMenu::indicator_size=0
      GtkOptionMenu::indicator_spacing=0
      GtkPaned::handle_size=4
      GtkRange::trough_border=0
      GtkRange::stepper_spacing=0
      GtkScale::value_spacing=0
      GtkScrolledWindow::scrollbar_spacing=0
      GtkExpander::expander_size=10
      GtkExpander::expander_spacing=0
      GtkTreeView::vertical-separator=0
      GtkTreeView::horizontal-separator=0
      GtkTreeView::expander-size=12
      GtkTreeView::fixed-height-mode=TRUE 
      GtkWidget::focus_padding=0 
      font_name="Liberation Sans,Sans Regular 8"
      text[SELECTED] = @selected_text_color
    }
    class "GtkWidget" style "compact"
    style "compact2"
    {
      xthickness=1
      ythickness=1
    }
    class "GtkButton" style "compact2"
    class "GtkToolbar" style "compact2"
    class "GtkPaned" style "compact2"
  • Next, in Eclipse, go to Window -> Preferences -> General -> Appearance, and under Theme, make sure GTK is selected.
  • Run eclipse like this:
    GTK2_RC_FILES=$GTK2_RC_FILES:~/eclipse/gtkrc ~/eclipse/eclipse

This ought to improve it a bit:

More to come as I figure out how to further improve this.

References:

http://xmemory.tompium.com/2012/01/make-eclipse-look-better-on-ubuntu.html

 

 

Nov 182011
 

I needed to return all the members of an object as an XML document in Python. I used the ElementTree library to do this.

The class in question is pretty basic: It has a constructor, member variables, getters and setters for the member variables, and now this new function.

Every Python class has a built-in __dict__ member, which is a dictionary ({}) of key/value pairs for all of the member variables, so I use that to get all of the variables to add to the ElementTree.

This function returns an xml.etree.ElementTree.Element object, which can be turned into a string if needed by using ElementTree’s tostring() method.

def getXML(self):
    """ Returns an XML representation of the object """
    topElem = Element("item")
    for key in self.__dict__.keys():
        elem = SubElement(topElem, key)
        elem.text = str(self.__dict__[key])
    return topElem
Jul 042009
 

The Duke URLGrabber package for Python makes it incredibly easy to retrieve files from remote servers, and it abstracts urllib2 for you in a protocol-independent way, so you can focus on your application instead of spending time working with Python’s built-in urllib2.

On Windows and Mac OSX, by default, urllib2 (and therefore URLGrabber) will use the built-in proxy settings of the system – but sometimes you don’t want that.  For example, let’s say you’re using a Windows box that’s on a domain, and proxy settings have been pushed down by group policy.  You want to access local network resources without needing to route through the proxy or authenticate to it.

With urllib2, you would simply add code like the following:

proxy_support = urllib2.ProxyHandler({})

Note the empty dictionary “{}” to specify no proxies.  Doing the same for URLGrabber was suggested on a mailing list post – and it apparently worked for the poster.  However, I wasn’t able to get it to work, so I came up with another way.  I just specified a dummy proxy for a dummy protocol, as follows:

kwargs["proxies"] = { 'nothing': 'http://nothing' }

Have fun!