browse by category or date

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

    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)

    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            

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

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

1 Trackback


No Comment

Add Your Comment