[PATCH 2/2] wraplabel: code quality fixes



From 0b8dc06bd098a82483a76e634addcdb61e6a169c Mon Sep 17 00:00:00 2001
From: Sandro Bonazzola <sandro bonazzola gmail com>
Date: Sun, 28 Jul 2013 08:26:26 +0200
Subject: [PATCH 2/2] wraplabel: code quality fixes

- removed unused imports
- pep8 cleanup
- avoid redefining builtin str
- removed unused variables
---
 meld/ui/wraplabel.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/meld/ui/wraplabel.py b/meld/ui/wraplabel.py
index d40a5be..9b5504b 100644
--- a/meld/ui/wraplabel.py
+++ b/meld/ui/wraplabel.py
@@ -21,28 +21,27 @@
 # Python translation from wrapLabel.{cc|h} by Gian Mario Tagliaretti

 import gtk
-import gobject
 import pango


 class WrapLabel(gtk.Label):
     __gtype_name__ = 'WrapLabel'

-    def __init__(self, str=None):
+    def __init__(self, text=None):
         gtk.Label.__init__(self)

         self.__wrap_width = 0
         self.layout = self.get_layout()
         self.layout.set_wrap(pango.WRAP_WORD_CHAR)

-        if str != None:
-            self.set_text(str)
+        if text is not None:
+            self.set_text(text)

         self.set_alignment(0.0, 0.0)

     def do_size_request(self, requisition):
         layout = self.get_layout()
-        width, height = layout.get_pixel_size()
+        height = layout.get_pixel_size()[1]
         requisition.width = 0
         requisition.height = height

@@ -50,12 +49,12 @@ class WrapLabel(gtk.Label):
         gtk.Label.do_size_allocate(self, allocation)
         self.__set_wrap_width(allocation.width)

-    def set_text(self, str):
-        gtk.Label.set_text(self, str)
+    def set_text(self, text):
+        gtk.Label.set_text(self, text)
         self.__set_wrap_width(self.__wrap_width)

-    def set_markup(self, str):
-        gtk.Label.set_markup(self, str)
+    def set_markup(self, text):
+        gtk.Label.set_markup(self, text)
         self.__set_wrap_width(self.__wrap_width)

     def __set_wrap_width(self, width):
-- 
1.8.3.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]