diff options
-rw-r--r-- | activity.py | 48 | ||||
-rw-r--r-- | icons/time.svg | 79 |
2 files changed, 17 insertions, 110 deletions
diff --git a/activity.py b/activity.py index 25fb0a5..d27b7f8 100644 --- a/activity.py +++ b/activity.py @@ -43,15 +43,12 @@ weight = {'Gram': 1, 'hg': 0.01, 'dag': 0.1, 'dg': 10, 'cg': 100, 'mg': 1000, volume = {'Meter3': 1, 'Kilometer3': 0.001, 'Centimeter3': 100, 'Yard3': 1.09361, 'Foot3': 3.28084, 'Fathoms3': 0.5468, 'mm3': 1000, - 'dm3': 10, 'dam3': 0.1, 'hm3': 0.01} + 'dm3': 10, 'dam3': 0.1, 'hm3': 0.01, 'Liter': 1, 'Kiloliter': 0.001, + 'Centiliter': 100, 'ml': 1000, 'dl': 10, 'dal': 0.1, 'hl': 0.01} -time = {'Hour': 1} temp = {'Celsius': 1} -liquid = {'Liter': 1, 'Kiloliter': 0.001, 'Centiliter': 100, - 'ml': 1000, 'dl': 10, 'dal': 0.1, 'hl': 0.01} - class ConvertActivity(activity.Activity): def __init__(self, handle): @@ -60,9 +57,13 @@ class ConvertActivity(activity.Activity): self.dic = {} #Canvas + event_box_canvas = gtk.EventBox() + event_box_canvas.modify_base(gtk.STATE_NORMAL, + gtk.gdk.color_parse('white')) + self.set_canvas(event_box_canvas) self.canvas = gtk.VBox() - self.set_canvas(self.canvas) + event_box_canvas.add(self.canvas) hbox = gtk.HBox() self.canvas.pack_start(hbox, False, padding=5) @@ -86,14 +87,14 @@ class ConvertActivity(activity.Activity): spin_box.pack_start(self.spin_btn, True, False) self.canvas.pack_start(spin_box, False, False, 5) - scroll = gtk.ScrolledWindow() - scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + eventbox_label = gtk.EventBox() + self.canvas.add(eventbox_label) self.label = gtk.Label() + self.label.connect('expose-event', self.resize_label) self.label.set_text('%s ~ %s' % (str(self.spin_btn.get_value()), str(self.spin_btn.get_value()))) - self.label.modify_font(pango.FontDescription('60')) - scroll.add_with_viewport(self.label) - self.canvas.add(scroll) + eventbox_label.add(self.label) + self.label_info = gtk.Label(' Convert \n000 x 000 = 000') self.label_info.modify_font(pango.FontDescription('12')) self.canvas.pack_end(self.label_info, 0, True, 30) @@ -138,13 +139,6 @@ class ConvertActivity(activity.Activity): self._weight_btn.props.icon_name = 'weight' self._weight_btn.props.group = self._lenght_btn - self._liquid_btn = RadioToolButton() - self._liquid_btn.connect('clicked', - lambda w: self._update_combo(liquid)) - self._liquid_btn.set_tooltip('Liquid') - self._liquid_btn.props.icon_name = 'liquid' - self._liquid_btn.props.group = self._lenght_btn - self._speed_btn = RadioToolButton() self._speed_btn.connect('clicked', lambda w: self._update_combo(speed)) @@ -152,13 +146,6 @@ class ConvertActivity(activity.Activity): self._speed_btn.props.icon_name = 'speed' self._speed_btn.props.group = self._lenght_btn - self._time_btn = RadioToolButton() - self._time_btn.connect('clicked', - lambda w: self._update_combo(time)) - self._time_btn.set_tooltip('Time') - self._time_btn.props.icon_name = 'time' - self._time_btn.props.group = self._lenght_btn - self._temp_btn = RadioToolButton() self._temp_btn.connect('clicked', lambda w: self._update_combo(temp)) @@ -170,9 +157,7 @@ class ConvertActivity(activity.Activity): toolbarbox.toolbar.insert(self._volume_btn, -1) toolbarbox.toolbar.insert(self._area_btn, -1) toolbarbox.toolbar.insert(self._weight_btn, -1) - toolbarbox.toolbar.insert(self._liquid_btn, -1) toolbarbox.toolbar.insert(self._speed_btn, -1) - toolbarbox.toolbar.insert(self._time_btn, -1) toolbarbox.toolbar.insert(self._temp_btn, -1) # @@ -237,7 +222,7 @@ class ConvertActivity(activity.Activity): self._update_label_info(True, unit, to_unit) return self._round(number) else: - self._update_label_info(igual=False, text1=unit, text2=to_unit) + self._update_label_info(False, unit, to_unit) return self._round(number * self.dic[unit] * self.dic[to_unit]) def _round(self, num): @@ -246,9 +231,10 @@ class ConvertActivity(activity.Activity): then_dot = num.split('.')[1] short_num = before_dot + '.' + then_dot[:2] - print short_num return float(short_num) -# def _set_size(self): -# + def resize_label(self, widget, event): + num_label = len(self.label.get_text()) + self.label.modify_font(pango.FontDescription(str(num_label))) + print 'lechuga' diff --git a/icons/time.svg b/icons/time.svg deleted file mode 100644 index d1d390f..0000000 --- a/icons/time.svg +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - contentScriptType="text/ecmascript" - width="55px" - zoomAndPan="magnify" - contentStyleType="text/css" - height="55px" - preserveAspectRatio="xMidYMid meet" - version="1.1" - id="svg2" - inkscape:version="0.48.2 r9819" - sodipodi:docname="time.svg"> - <metadata - id="metadata22"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <defs - id="defs20" /> - <sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1200" - inkscape:window-height="804" - id="namedview18" - showgrid="false" - inkscape:zoom="4.2909091" - inkscape:cx="27.5" - inkscape:cy="27.5" - inkscape:window-x="0" - inkscape:window-y="30" - inkscape:window-maximized="1" - inkscape:current-layer="svg2" /> - <circle - d="M 50,27.5 C 50,39.926407 39.926407,50 27.5,50 15.073593,50 5,39.926407 5,27.5 5,15.073593 15.073593,5 27.5,5 39.926407,5 50,15.073593 50,27.5 z" - style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-opacity:1" - sodipodi:ry="22.5" - sodipodi:rx="22.5" - sodipodi:cy="27.5" - sodipodi:cx="27.5" - r="22.5" - cx="27.5" - cy="27.5" - id="circle4" - transform="translate(0.69915254,1.1652542)" /> - <line - x1="23.724579" - x2="32.956627" - y1="3.762712" - y2="3.762712" - id="line10" - style="stroke:#ffffff;stroke-width:4.34151602000000025;stroke-opacity:1" /> - <line - x1="27.5" - x2="21" - y1="30.529661" - y2="40.029659" - id="line14" - style="stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linecap:round;stroke-opacity:1" /> -</svg> |