Posts RSS Comments RSS 133 Posts and 258 Comments till now

Archive for the 'Ubuntu' Category

My First Python Program

Now that I have switched to Ubuntu Linux, I need a programming language where I can program simple GUI applications for fun (and profit?). I could have use C# using MonoDevelop, but I choose Python instead. It was more sentimental choice because the name Python was more connected to Monty Python (Nudge..Nudge..Wink..Wink anyone?) than to the a species of snake.

 

What I need now is a small GUI program which strip out all the dashes and white spaces and automatically copy the cleaned string to Clipboard. I used wxGlade to design the GUI and Eric as the editor for my first Python script.
wxGlade in action
If you are used to Visual Studio, designing your Form using wxGlade will be quite tricky. It will not straight forward just by drag-and-drop. You need to create containers first before you can put any Textboxes, Labels or Buttons. You will not able to position the Controls freely as the layout will depend heavily on the Containers.

Once satisfied with the layout, you then generate the XML file and the Python’s source code.

#!/usr/bin/env python
    def __set_properties(self):
        self.SetTitle("DashRemover")

    def __do_layout(self):
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(3, 3, 0, 0)
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
        sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()

    def textEvt_Handler(self, event):
        # the Clipboard class that will help you interact with the
        # GNOME/KDE/Windows clipboard
        if wx.TheClipboard.Open():     #This is a must!
            #remove any dashes or empty spaces
            cleandata = self.text_ctrl_1.Value.strip().replace('-','')
            cleandata = cleandata.replace(' ', '')
            self.text_ctrl_1.Value = cleandata
            wx.TheClipboard.Clear()
            wx.TheClipboard.SetData(wx.TextDataObject(cleandata))
            wx.TheClipboard.Close()
        event.Skip()

if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = fmDashRemover(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()

Foxit Reader on Ubuntu Linux (through Wine)

I like Foxit Reader very much. It’s fast, small and give you pretty much everything you need for a PDF Reader. Although they have the Linux version, I don’t really like it because I don’t seem to be able to automatically open a PDF file with a single click from Nautilus (although I already set ReaderLinux as the default Application).

 

Before we proceed, I am assuming you already have Wine up & running, and have installed the Windows version of Foxit Reader. What we need to do next is to associate the PDF file to Foxit Reader through Wine in Nautilus (or other File Manager that you have). If you have not install Wine, you could read the tutorial HERE.

 

After you have Wine up and running, download the Windows version of Foxit Reader HERE. Install it using the default settings.

 

First save the following script as foxit.sh in your home directory

#!/bin/bash
# Purpose: To convert Linux-style filename to Windows-style to pass as an argument
# to wine when starting Foxit Reader
Filename="z:"${1//\//\\}
#assuming you use the default installation folder for Foxit in Wine
App='eval wine "C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe" "'$Filename'"'
$App

 

Use foxit.sh as the Default Application for PDF File (select any PDF file in Nautilus, Right-Click -> Properties -> Open With -> Click [+ Add] Button -> Browse for foxit.sh located in your home folder.

 

Voila! Foxit Reader is now the default application for your PDF documents.

 

(Disclaimer: This post was based on 64-bit Ubuntu Gutsy Gibbon and Foxit Reader 2.1 Build 2023)

Switching to Ubuntu Linux

I am officially leaving Windows realm, and forced myself into the unfamiliar territory of Ubuntu Linux. Here are the list of things that I must get them running immediately, or my life will suffer :P.

  1. E-Donkey Client. You can use aMule for connecting to ED2K network
  2. BitTorrent Client. Azureus have a version that runs in Ubuntu. But emulating uTorrent through Wine also not bad.
  3. PeerGuardian for Linux. We have MoBlock, but it doesn’t offer a GUI interface. I believe a GUI development is in progress.
  4. Integrated Development Environment (IDE). So far I’m sticking myself to Eclipse for Java. WxGlade for my Python Form Designer. And Eric for Python.
  5. and many more … (frankly there are thousands of pages out there offering help on running Ubuntu)

Close
E-mail It
Socialized through Gregarious 42