def cursor2_clicked(obj, item=None): win = elementary.Window("cursors", elementary.ELM_WIN_BASIC) win.title_set("Cursors 2") win.autodel_set(True) bg = elementary.Background(win) win.resize_object_add(bg) bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bg.show() bx = elementary.Box(win) win.resize_object_add(bx) bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bx.show() tb = elementary.Toolbar(win) ti = tb.item_append("folder-new", "Bogosity", None, None) ti.cursor_set(cursors.ELM_CURSOR_BOGOSITY) ti = tb.item_append("clock", "Unset", None, None) ti.cursor_set(cursors.ELM_CURSOR_BOGOSITY) ti.cursor_unset() ti = tb.item_append("document-print", "Xterm", None, None) ti.cursor_set(cursors.ELM_CURSOR_XTERM) tb.size_hint_weight_set(0.0, 0.0) tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) bx.pack_end(tb) tb.show() lst = elementary.List(win) li = lst.item_append("cursor bogosity") li.cursor_set(cursors.ELM_CURSOR_BOGOSITY) li = lst.item_append("cursor unset") li.cursor_set(cursors.ELM_CURSOR_BOGOSITY) li.cursor_unset() li = lst.item_append("cursor xterm") li.cursor_set(cursors.ELM_CURSOR_XTERM) lst.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) lst.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) bx.pack_end(lst) lst.go() lst.show() win.resize(320, 480) win.show()
def set_menu(self, mv): if self._tb: self._tb.delete() if mv is None: return self._tb = elementary.Toolbar(self) self._tb.homogenous = False self._tb.align = 0.0 self._tb.size_hint_weight_set(0.0, 0.0) self._tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) self._ly.content_set("menubar", self._tb) for item in mv.items: if item.type is MenuItemView.CASCADE_MENU: ic = None if item.icon: #TODO pass mi = self._tb.item_add(ic, item.label) mi.menu_set(True) tm = mi.menu_get() create_menu_from_menuview(item.items, tm, None) self._tb.menu_parent_set(self) self._tb.show()
def toolbar_clicked(obj): win = elementary.Window("toolbar", elementary.ELM_WIN_BASIC) win.title_set("Toolbar") win.autodel_set(True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = elementary.Background(win) win.resize_object_add(bg) bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bg.show() bx = elementary.Box(win) win.resize_object_add(bx) bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bx.show() tb = elementary.Toolbar(win) tb.homogeneous = False tb.size_hint_weight_set(0.0, 0.0) tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) ph1 = elementary.Photo(win) ph2 = elementary.Photo(win) ph3 = elementary.Photo(win) ph4 = elementary.Photo(win) item = tb.item_append("document-print", "Hello", tb_1) item.disabled = True item = tb.item_append("clock", "World,", tb_2, ph2) item.selected_set(True) tb.item_append("folder-new", "here", tb_3, ph4) tb.item_append("clock", "comes", tb_4, ph4) tb.item_append("folder-new", "python-elementary!", tb_5, ph4) item = tb.item_append("clock", "Menu", tb_5, ph4) item.menu_set(True) tb.menu_parent_set(win) menu = item.menu_get() menu.item_add(None, "Here", "clock", tb_3, ph4) menu_item = menu.item_add(None, "Comes", "refresh", tb_4, ph4) menu.item_add(menu_item, "hey ho", "folder-new", tb_4, ph4) menu.item_add(None, "python-elementary", "document-print", tb_5, ph4) bx.pack_end(tb) tb.show() tb = elementary.Table(win) tb.size_hint_weight_set(0.0, evas.EVAS_HINT_EXPAND) tb.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) ph1.size_set(40) ph1.file_set("images/plant_01.jpg") ph1.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) ph1.size_hint_align_set(0.5, 0.5) tb.pack(ph1, 0, 0, 1, 1) ph1.show() ph2.size_set(80) ph2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) ph2.size_hint_align_set(0.5, 0.5) tb.pack(ph2, 1, 0, 1, 1) ph2.show() ph3.size_set(40) ph3.file_set("images/sky_01.jpg") ph3.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) ph3.size_hint_align_set(0.5, 0.5) tb.pack(ph3, 0, 1, 1, 1) ph3.show() ph4.size_set(60) ph4.file_set("images/sky_02.jpg") ph4.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) ph4.size_hint_align_set(0.5, 0.5) tb.pack(ph4, 1, 1, 1, 1) ph4.show() bx.pack_end(tb) tb.show() win.resize(320, 300) win.show()
def tooltip_clicked(obj): win = elementary.Window("tooltips", elementary.ELM_WIN_BASIC) win.title_set("Tooltips") win.autodel_set(True) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = elementary.Background(win) win.resize_object_add(bg) bg.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bg.show() bx = elementary.Box(win) win.resize_object_add(bx) bx.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) bx.show() tb = elementary.Toolbar(win) tb.homogeneous_set(False) tb.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0) tb.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) bx.pack_end(tb) tb.show() ti = tb.item_append("folder-new", "Open", None, None) ti.tooltip_text_set("Opens a file") ti = tb.item_append("clock", "Icon", None, None) ti.tooltip_content_cb_set(_tt_item_icon, None) ti.tooltip_style_set("transparent") bt = elementary.Button(win) bt.text_set("Simple text tooltip") bt.tooltip_text_set("Simple text tooltip") bx.pack_end(bt) bt.show() def _tt_text_replace(obj, data): value = data.get("value") if not value: value = 1 obj.tooltip_text_set("count=%d" % value) value += 1 data["value"] = value bt = elementary.Button(win) bt.text_set("Simple text tooltip, click to change") bt.tooltip_text_set("Initial") data = dict() bt.callback_clicked_add(_tt_text_replace, data) bx.pack_end(bt) bt.show() def _tt_text_replace_timer_cb(obj, data): _tt_text_replace(obj, data) return True def _tt_text_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Simple text tooltip, click to start changed timed") return data["timer"] = ecore.timer_add(1.5, _tt_text_replace_timer_cb, obj, data) obj.text_set("Simple text tooltip, click to stop changed timed") bt = elementary.Button(win) bt.text_set("Simple text tooltip, click to start changed timed") bt.tooltip_text_set("Initial") data = dict() bt.callback_clicked_add(_tt_text_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) bt = elementary.Button(win) bt.text_set("Icon tooltip") bt.tooltip_content_cb_set(_tt_icon, None) bx.pack_end(bt) bt.show() def _tt_icon_replace_timer_cb(obj, data): value = data.get("value") data["value"] = not value if value: obj.tooltip_content_cb_set(_tt_icon) else: obj.tooltip_content_cb_set(_tt_icon2) return True def _tt_icon_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Icon tooltip, click to start changed timed") return data["timer"] = ecore.timer_add(1.5, _tt_icon_replace_timer_cb, obj, data) obj.text_set("Icon tooltip, click to stop changed timed") bt = elementary.Button(win) bt.text_set("Icon tooltip, click to start changed timed") bt.tooltip_content_cb_set(_tt_icon) data = dict() bt.callback_clicked_add(_tt_icon_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) bt = elementary.Button(win) bt.text_set("Transparent Icon tooltip") bt.tooltip_content_cb_set(_tt_icon, None) bt.tooltip_style_set("transparent") bx.pack_end(bt) bt.show() def _tt_style_replace_timer_cb(obj, data): value = data.get("value") data["value"] = not value if value: obj.tooltip_style_set() else: obj.tooltip_style_set("transparent") return True def _tt_style_replace_timed(obj, data, *args, **kargs): timer = data.get("timer") if timer: timer.delete() del data["timer"] obj.text_set("Icon tooltip style, click to start changed timed") return data["timer"] = ecore.timer_add(1.5, _tt_style_replace_timer_cb, obj, data) obj.text_set("Icon tooltip, click to stop changed timed") bt = elementary.Button(win) bt.text_set("Icon tooltip style, click to start changed timed") bt.tooltip_content_cb_set(_tt_icon, None) data = dict() bt.callback_clicked_add(_tt_style_replace_timed, data) bx.pack_end(bt) bt.show() bt.on_del_add(_tt_timer_del, data) def _tt_visible_lock_toggle(obj, data, *args, **kargs): value = data.get("value") data["value"] = not value if value: obj.text_set("Unlocked tooltip visibility") obj.tooltip_hide() else: obj.text_set("Locked tooltip visibility") obj.tooltip_show() bt = elementary.Button(win) bt.text_set("Unlocked tooltip visibility") bt.tooltip_text_set( "This tooltip is unlocked visible,<br> clock the button to lock!") data = dict() bt.callback_clicked_add(_tt_visible_lock_toggle, data) bx.pack_end(bt) bt.show() en = elementary.Entry(win) en.scrollable_set(True) en.single_line_set(True) en.entry_set("Hello, some scrolled entry here!") en.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0) en.size_hint_align_set(evas.EVAS_HINT_FILL, 0.5) en.tooltip_text_set("Type something here!") bx.pack_end(en) en.show() lst = elementary.List(win) li = lst.item_append("Hello") li.tooltip_text_set("Something useful here?") li = lst.item_append("Icon Tooltip") li.tooltip_content_cb_set(_tt_item_icon, None) lst.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND) lst.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) lst.size_hint_min_set(100, 100) bx.pack_end(lst) lst.go() lst.show() win.show() win.resize(400, 500)
def build_gui (self): def destroy (obj, *args, **kargs): self.sensorTimer.delete() self.SaveConfig (self.configfile) elementary.exit () gui_items = dict () # Start elementary elementary.init () # Create main window gui_items['mainwin'] = elementary.Window ("Wax-Chooser", elementary.ELM_WIN_BASIC) gui_items['mainwin'].title_set ("Wax-Chooser") gui_items['mainwin'].callback_destroy_add (destroy) # Create background bg = elementary.Background (gui_items['mainwin']) bg.size_hint_weight_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) bg.size_hint_min_set (200,300) gui_items['mainwin'].resize_object_add (bg) bg.show () # Create main box (vertical by default) gui_items['mainbox'] = elementary.Box (gui_items['mainwin']) gui_items['mainbox'].size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) gui_items['mainbox'].size_hint_align_set (-1.0, evas.EVAS_HINT_FILL) gui_items['mainwin'].resize_object_add (gui_items['mainbox']) gui_items['mainbox'].show () # Create title label gui_items['title'] = elementary.Label (gui_items['mainwin']) gui_items['title'].text_set ("Current Conditions") gui_items['mainbox'].pack_start (gui_items['title']) gui_items['title'].size_hint_weight_set (1.0, evas.EVAS_HINT_FILL) gui_items['title'].size_hint_align_set (0.5, -1.0) gui_items['title'].show () # Create scroller to hold condition descripion items self.sc2 = elementary.Scroller(gui_items['mainwin']) self.sc2.bounce_set(0, 0) self.sc2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 1.0) self.sc2.size_hint_align_set(-1.0, evas.EVAS_HINT_FILL) gui_items['mainbox'].pack_end(self.sc2) self.sc2.show() gui_items['mainwin'].resize_object_add (self.sc2) # Create condtion description box (vertical by default) box2 = elementary.Box (gui_items['mainwin']) box2.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) box2.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) self.sc2.content_set (box2) box2.show () gui_items['rows'] = [] # Create four boxes: temperature, humidity, snow type, and buttons, set as horizonal tbox = elementary.Box (gui_items['mainwin']) #tbox.horizontal_set (1) #box1.homogenous_set (1) tbox.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) tbox.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) box2.pack_end (tbox) tbox.show () # Create temperature widget label tl = elementary.Label (gui_items['mainwin']) tl.text_set ('Temperature') tbox.pack_start( tl ) tl.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) tl.size_hint_align_set (0.4, 0.5) tl.show () # Create temperature slider gui_items['temperatureSlider'] = elementary.Slider (gui_items['mainwin']) gui_items['temperatureSlider'].size_hint_weight_set (1, 0) gui_items['temperatureSlider'].size_hint_align_set (-1, 0) if self.usingCelsius: gui_items['temperatureSlider'].min_max_set (-30.0, 10.0) gui_items['temperatureSlider'].value = 0 else: gui_items['temperatureSlider'].min_max_set (-15.0, 45.0) gui_items['temperatureSlider'].value = 32 gui_items['temperatureSlider'].unit_format_set( '%1.1f degrees' ) tbox.pack_end (gui_items['temperatureSlider']) gui_items['temperatureSlider'].show () tsbox = elementary.Box (gui_items['mainwin']) tsbox.horizontal_set (1) tsbox.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) tsbox.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) box2.pack_end (tsbox) tsbox.show () # Create Use Sensor button gui_items['sensorButton'] = elementary.Button (gui_items['mainwin']) gui_items['sensorButton']._callback_add ('clicked', self.setTemperatureFromSensor) ic = elementary.Icon(gui_items['sensorButton']) ic.file_set(os.path.join(IMAGE_DIR, "thermometer.png")) gui_items['sensorButton'].icon_set( ic) gui_items['sensorButton'].text_set( "Searching for sensor" ) gui_items['sensorButton'].size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) gui_items['sensorButton'].size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) tsbox.pack_end (gui_items['sensorButton']) if self.usingSensor: gui_items['sensorButton'].show () ######## Humidity ############ hbox = elementary.Box (gui_items['mainwin']) #box1.homogenous_set (1) hbox.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) hbox.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) box2.pack_end (hbox) hbox.show () gui_items['mainwin'].resize_object_add (hbox) #create humidity widget label hl = elementary.Label (gui_items['mainwin']) hl.text_set ('Humidity') hl.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) hl.size_hint_align_set (0.45, 0.5) hbox.pack_start (hl) hl.show () hbox2 = elementary.Box (gui_items['mainwin']) hbox2.horizontal_set (1) #box1.homogenous_set (1) hbox2.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) hbox2.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) hbox.pack_end (hbox2) gui_items['mainwin'].resize_object_add (hbox2) hbox2.show () #Create humidity toolbar rhtoolbar = elementary.Toolbar(gui_items['mainwin']) rhtoolbar.menu_parent_set(gui_items['mainwin']) rhtoolbar.homogenous_set(0) rhtoolbar.icon_size_set( 64 ) # print str( rhtoolbar.icon_size ) rhtoolbar.icon_size = ( 96 ) # print str( rhtoolbar.icon_size ) rhtoolbar.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) rhtoolbar.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) rhtoolbar.item_append(os.path.join(IMAGE_DIR, 'medrh.png'), "Normal", self.setHumidity,humidity=NORMAL_HUMIDITY) rhtoolbar.item_append(os.path.join(IMAGE_DIR, 'highrh.png'), "High", self.setHumidity,humidity=HIGH_HUMIDITY) rhtoolbar.first_item_get().selected_set(True) hbox2.pack_end( rhtoolbar ) rhtoolbar.show() ######## Snow Condition ############ sbox = elementary.Box (gui_items['mainwin']) #box1.homogenous_set (1) sbox.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) sbox.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) box2.pack_end (sbox) sbox.show () #create snow cond widget label sl = elementary.Label (gui_items['mainwin']) sl.text_set ('Snow Condition') sl.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) sl.size_hint_align_set (0.45, 0.5) sbox.pack_start (sl) sl.show () sbox2 = elementary.Box (gui_items['mainwin']) sbox2.horizontal_set (1) #box1.homogenous_set (1) sbox2.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) sbox2.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) sbox.pack_end (sbox2) sbox2.show () #Create Snow condition toolbar sctoolbar = elementary.Toolbar(gui_items['mainwin']) sctoolbar.menu_parent_set(gui_items['mainwin']) sctoolbar.homogenous_set(0) sctoolbar.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) sctoolbar.size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) sctoolbar.item_append(os.path.join(IMAGE_DIR, 'newsnow.png'), "New", self.setSnowCond,snowcond=NEW_SNOW) sctoolbar.item_append(os.path.join(IMAGE_DIR, 'transformedsnow.png'), "Transformed", self.setSnowCond,snowcond=OLD_SNOW) sctoolbar.item_append(os.path.join(IMAGE_DIR, 'corn.png'), "Corn", self.setSnowCond,snowcond=CORN_SNOW) sctoolbar.item_append(os.path.join(IMAGE_DIR, 'ice.png'), "Ice", self.setSnowCond,snowcond=ICY_SNOW) sctoolbar.first_item_get().selected_set(True) sbox2.pack_end( sctoolbar ) sctoolbar.show() # Create bottom button row (prev, next city & refresh) box3 = elementary.Box (gui_items['mainwin']) box3.horizontal_set (1) box3.homogenous_set (1) box3.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) box3.size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) gui_items['mainbox'].pack_end (box3) box3.show () # Find Wax button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Find Wax') bt._callback_add ('clicked', self.find_wax) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) # Add a prev icon to the button box3.pack_end (bt) bt.show () # Settings button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Settings') bt._callback_add ('clicked', self.settingsDialog) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) # Add a next icon to the button box3.pack_end (bt) bt.show () ##### # Create wax display box (vertical by default) gui_items['waxbox'] = elementary.Box (gui_items['mainwin']) gui_items['waxbox'].size_hint_weight_set (evas.EVAS_HINT_FILL, 1.0) gui_items['waxbox'].size_hint_align_set (evas.EVAS_HINT_FILL, -1.0) gui_items['waxLabel'] = elementary.Label(gui_items['mainwin']) gui_items['waxLabel'].text_set("Wax") gui_items['waxbox'].pack_start(gui_items['waxLabel']) gui_items['waxLabel'].show() # Create box to hold the wax picture sc = elementary.Scroller(gui_items['waxbox']) sc.bounce_set(0, 0) sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.5) sc.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) ib = elementary.Box(gui_items['mainwin']) ib.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.5) ib.size_hint_align_set(evas.EVAS_HINT_FILL, 0.5) gui_items['waxicon'] = elementary.Icon(gui_items['mainwin']) gui_items['waxicon'].size_hint_weight_set(1.0, 0.5) gui_items['waxicon'].scale_set(0.2, 0.2) gui_items['waxicon'].size_hint_align_set(0.5, 0.0) ib.pack_end(gui_items['waxicon']) gui_items['mainwin'].resize_object_add (ib) gui_items['waxicon'].show() gui_items['waxtext'] = elementary.Entry( gui_items['mainwin'] ) gui_items['waxtext'].size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) gui_items['waxtext'].size_hint_align_set(-1.0, 0.0) gui_items['waxtext'].scale_set(1) ib.pack_end(gui_items['waxtext']) gui_items['waxtext'].show() sc.content_set(ib) gui_items['waxbox'].pack_end(sc) gui_items['mainwin'].resize_object_add (sc) ib.show() sc.show() # Create bottom button row (warmer back colder) box3 = elementary.Box (gui_items['mainwin']) box3.horizontal_set (1) box3.homogenous_set (1) box3.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) box3.size_hint_align_set (evas.EVAS_HINT_FILL, 1.0) gui_items['waxbox'].pack_end (box3) box3.show () gui_items['mainwin'].resize_object_add (box3) # Create the warmer button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Warmer') bt._callback_add ('clicked', self.warmerWax) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) box3.pack_end (bt) bt.show () # Create the back button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Back') bt._callback_add ('clicked', self.closeWax) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) box3.pack_end (bt) bt.show () # Create the Colder button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Colder') bt._callback_add ('clicked', self.colderWax) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) box3.pack_end (bt) bt.show () gui_items['mainwin'].resize_object_add (gui_items['waxbox']) gui_items['waxbox'].hide () ##### # Create about box (vertical by default) gui_items['aboutbox'] = elementary.Box (gui_items['mainwin']) gui_items['aboutbox'].size_hint_weight_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) gui_items['aboutbox'].size_hint_align_set (-1.0, -1.0) al = elementary.Label(gui_items['mainwin']) al.size_hint_weight_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) al.size_hint_align_set (0.5, -1.0) al.text_set("About waxChooser") gui_items['aboutbox'].pack_start(al) al.show() sc2 = elementary.Scroller(gui_items['mainwin']) sc2.bounce_set(0, 0) sc2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 1.0) sc2.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) gui_items['aboutbox'].pack_end(sc2) gui_items['mainwin'].resize_object_add (sc2) sc2.show() ib = elementary.Box(gui_items['aboutbox']) ic = elementary.Icon(gui_items['aboutbox']) ic.size_hint_weight_set(evas.EVAS_HINT_FILL,1.0) ic.scale_set(0, 0) ic.size_hint_align_set(0.5, 0.5) gui_items['mainwin'].resize_object_add(ic) ic.file_set(os.path.join(IMAGE_DIR, "author.png")) ib.size_hint_weight_set(evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) ib.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) ib.pack_end(ic) sc2.content_set(ib) ic.show() gui_items['mainwin'].resize_object_add (ic) # Create text box with 'about' info at = elementary.Entry( gui_items['mainbox'] ) at.size_hint_weight_set(1.0, 0.0) at.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) at.scale_set(1) info = self.infoadd("waxChooser " + APP_VERSION) info += self.infoadd("Copyright (c) 2011 Benjamin Deering") info += self.infoadd("<*****@*****.**>" ) at.text_set( info ) gui_items['aboutbox'].pack_end(at) at.show() # Create bottom button row (back, about) box3 = elementary.Box (gui_items['mainwin']) box3.horizontal_set (1) box3.homogenous_set (1) box3.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) box3.size_hint_align_set (-1.0, 0.0) gui_items['aboutbox'].pack_end (box3) box3.show () # Create the back button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Back') bt._callback_add ('clicked', self.hideAbout) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_FILL) bt.size_hint_align_set (evas.EVAS_HINT_FILL, -1.0) box3.pack_end (bt) bt.show () gui_items['mainwin'].resize_object_add (gui_items['aboutbox']) ##### # Create settings box (vertical by default) gui_items['settingsbox'] = elementary.Box (gui_items['mainwin']) gui_items['settingsbox'].size_hint_weight_set (evas.EVAS_HINT_EXPAND, 1.0) gui_items['settingsbox'].size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) settingsLabel = elementary.Label(gui_items['mainwin']) settingsLabel.text_set('Settings') settingsLabel.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) settingsLabel.size_hint_align_set (0.5, -1.0) gui_items['settingsbox'].pack_start( settingsLabel) settingsLabel.show() # Create scroller to hold settings toggles items sc2 = elementary.Scroller(gui_items['mainwin']) sc2.bounce_set(0, 0) sc2.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 1.0) sc2.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) gui_items['settingsbox'].pack_end(sc2) gui_items['mainwin'].resize_object_add (sc2) sc2.show() tb = elementary.Box(gui_items['settingsbox']) ut = elementary.Check (gui_items['mainwin']) ut.text_set('Units') ut.style_set("toggle") ut.text_part_set( 'off', 'Fahrenheit' ) ut.text_part_set( 'on', 'Celsius' ) ut.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) ut.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) tb.pack_end( ut ) ut.state_set(self.usingCelsius) ut._callback_add('changed',self.setUnits) ut.show() for brand in self.brands: ut = elementary.Check (gui_items['mainwin']) ut.style_set("toggle") ut.text_set(brand) ut.text_part_set( 'on', 'enabled' ) ut.text_part_set( 'off', 'disabled' ) ut.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) ut.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) ut.state_set(eval(self.enabledBrands[brand])) tb.pack_end( ut ) ut._callback_add('changed',self.enableBrands,brand=brand) ut.show() ut = elementary.Check (gui_items['mainwin']) ut.text_set('Use MLX90614') ut.style_set("toggle") ut.text_part_set( 'on', 'Yes' ) ut.text_part_set( 'off', 'No' ) ut.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) ut.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) tb.pack_end( ut ) ut.state_set(self.usingSensor) ut._callback_add('changed',self.setSensor) ut.show() tb.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) tb.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) tb.show() #gui_items['settingsbox'].pack_end( tb ) sc2.content_set(tb) # Create bottom button row (back, about) box3 = elementary.Box (gui_items['mainwin']) box3.horizontal_set (1) box3.homogenous_set (1) box3.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) box3.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) gui_items['settingsbox'].pack_end (box3) box3.show () # Create the back button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('Back') bt._callback_add ('clicked', self.closeSettings) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) box3.pack_end (bt) bt.show () # Create the about button bt = elementary.Button (gui_items['mainwin']) bt.text_set ('About') bt._callback_add ('clicked', self.showAbout) bt.size_hint_weight_set (evas.EVAS_HINT_EXPAND, 0.0) bt.size_hint_align_set (evas.EVAS_HINT_FILL, 0.0) box3.pack_end (bt) bt.show () #self.widgets['settingsbox'].pack_start(settingsTitle) gui_items['mainwin'].resize_object_add (gui_items['settingsbox']) gui_items['settingsbox'].hide () return gui_items
def build_gui(self): def destroy(obj, *args, **kargs): try: self.pressureLabelTimer.delete() self.altitudeLabelTimer.delete() self.pressureGraphTimer.delete() self.SaveConfig(self.configfile) except: print "Exception occured on exit" elementary.exit() gui_items = dict() # Create main window gui_items['mainwin'] = elementary.Window("Barom", elementary.ELM_WIN_BASIC) gui_items['mainwin'].title_set("Barom") gui_items['mainwin'].callback_destroy_add(destroy) # Create background bg = elementary.Background(gui_items['mainwin']) bg.size_hint_weight_set(1.0, 1.0) #bg.size_hint_min_set (200,300) gui_items['mainwin'].resize_object_add(bg) bg.show() # Create main box (vertical by default) gui_items['mainbox'] = elementary.Box(gui_items['mainwin']) gui_items['mainbox'].size_hint_weight_set(1.0, 1.0) gui_items['mainbox'].size_hint_align_set(-1.0, -1.0) gui_items['mainwin'].resize_object_add(gui_items['mainbox']) gui_items['mainbox'].show() #Create top toolbar toptoolbar = elementary.Toolbar(gui_items['mainwin']) toptoolbar.menu_parent_set(gui_items['mainwin']) toptoolbar.homogenous_set(False) #toptoolbar.icon_size_set( 64 ) #toptoolbar.size_hint_align_set (evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) #toptoolbar.size_hint_weight_set (1.0, 1.0) toptoolbar.size_hint_align_set(-1.0, 0.0) toptoolbar.item_append(os.path.join(IMAGE_DIR, 'altitude.png'), "Altitude", self.altitudeDialog) toptoolbar.item_append(os.path.join(IMAGE_DIR, "weather.png"), "Weather", self.weatherDialog) toptoolbar.item_append(os.path.join(IMAGE_DIR, 'calibrate.png'), "Calibrate", self.calibrateDialog) toptoolbar.item_append(os.path.join(IMAGE_DIR, "about.png"), "About", self.aboutDialog) gui_items['mainbox'].pack_end(toptoolbar) toptoolbar.show() gui_items['pager'] = elementary.Naviframe(gui_items['mainwin']) gui_items['pager'].size_hint_weight_set(1.0, 1.0) gui_items['pager'].size_hint_align_set(-1.0, -1.0) # Create weather box (vertical by default) gui_items['weatherbox'] = elementary.Box(gui_items['mainwin']) gui_items['weatherbox'].size_hint_weight_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) gui_items['weatherbox'].size_hint_align_set(-1.0, -1.0) gui_items['pressureLabel'] = elementary.Label(gui_items['mainwin']) gui_items['pressureLabel'].text_set('weather') gui_items['pressureLabel'].scale_set(3.5) gui_items['pressureLabel'].size_hint_weight_set(1.0, 0.0) gui_items['pressureLabel'].size_hint_align_set(0.5, -1.0) gui_items['weatherbox'].pack_end(gui_items['pressureLabel']) gui_items['pressureLabel'].show() # Include the graph of past pressures gui_items['graphframe'] = elementary.Frame(gui_items['mainwin']) sc = elementary.Scroller(gui_items['mainwin']) sc.bounce_set(0, 0) sc.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 1.0) sc.size_hint_align_set(-1.0, -1.0) #gui_items['weatherbox'].pack_end(sc) gui_items['mainwin'].resize_object_add(sc) sc.show() gui_items['graphframe'].size_hint_weight_set(1.0, 1.0) gui_items['graphframe'].size_hint_align_set(-1.0, -1.0) gui_items['graphframe'].show() graphcanvas = gui_items['graphframe'].evas bg = graphcanvas.Rectangle(color=(255, 255, 255, 255)) bg.size = (460, 380) bg.layer_set(1) gui_items['graphframe'].data["bg"] = bg #print "FrameSize: " + str(gui_items['graphframe'].size) bg.show() gui_items['graphframe'].content_set(bg) sc.content_set(gui_items['graphframe']) #gb.pack_end(gui_items['graphframe']) gui_items['weatherbox'].pack_end(sc) self.pressureGraphThread = pressureGraphUpdater( self.getPressureFromSensor, gui_items['graphframe'], self.usingMetric) self.pressureLabelTimer = ecore.timer_add(2, self.PressureLabelUpdate) self.pressureGraphTimer = ecore.timer_add( 2, self.pressureGraphThread.pressureGraphUpdate) gui_items['mainwin'].resize_object_add(gui_items['weatherbox']) gui_items['pager'].item_simple_push(gui_items['weatherbox']) ##### # Create calibrate box (vertical by default) gui_items['calibratebox'] = elementary.Box(gui_items['mainwin']) gui_items['calibratebox'].size_hint_weight_set(1.0, 1.0) gui_items['calibratebox'].size_hint_align_set(-1.0, -1.0) # Create scroller to hold calibrate toggles items sc2 = elementary.Scroller(gui_items['mainwin']) sc2.bounce_set(0, 0) sc2.size_hint_weight_set(1.0, 1.0) sc2.size_hint_align_set(-1.0, -1.0) gui_items['calibratebox'].pack_end(sc2) gui_items['mainwin'].resize_object_add(sc2) sc2.show() tb = elementary.Box(gui_items['calibratebox']) tb.size_hint_weight_set(1.0, 1.0) tb.size_hint_align_set(-1.0, -1.0) ut = elementary.Check(gui_items['mainwin']) ut.style_set("toggle") ut.text_set('Units') ut.text_part_set('on', 'Metric') ut.text_part_set('off', 'Imperial') ut.size_hint_weight_set(1.0, 1.0) ut.size_hint_align_set(-1.0, 0.0) tb.pack_end(ut) ut.state_set(self.usingMetric) ut._callback_add('changed', self.setUnits) ut.show() al = elementary.Label(gui_items['mainwin']) al.text_set("Known current altitude") al.show() tb.pack_end(al) tbAlt = elementary.Box(gui_items['mainwin']) tbAlt.horizontal_set(1) gui_items['calibrateAltnumber'] = elementary.Entry( gui_items['mainwin']) gui_items['calibrateAltnumber'].single_line_set(True) gui_items['calibrateAltnumber'].entry_set('XX') gui_items['calibrateAltnumber'].scale_set(2.0) gui_items['calibrateAltnumber'].size_hint_weight_set(1, 1) gui_items['calibrateAltnumber'].callback_activated_add(self.calibrate) tbAlt.pack_end(gui_items['calibrateAltnumber']) gui_items['calibrateAltnumber'].show() gui_items['unitaltlabel'] = elementary.Label(gui_items['mainwin']) gui_items['unitaltlabel'].show() tbAlt.pack_end(gui_items['unitaltlabel']) tbAlt.show() tb.pack_end(tbAlt) pl = elementary.Label(gui_items['mainwin']) pl.text_set("Known current pressure at sea level") pl.show() tb.pack_end(pl) tbPres = elementary.Box(gui_items['mainwin']) tbPres.horizontal_set(1) gui_items['calibratePresnumber'] = elementary.Entry( gui_items['mainwin']) gui_items['calibratePresnumber'].single_line_set(True) gui_items['calibratePresnumber'].entry_set('XX') gui_items['calibratePresnumber'].scale_set(2.0) gui_items['calibratePresnumber'].size_hint_weight_set(1, 1) gui_items['calibratePresnumber'].callback_activated_add(self.calibrate) tbPres.pack_end(gui_items['calibratePresnumber']) gui_items['calibratePresnumber'].show() gui_items['unitpreslabel'] = elementary.Label(gui_items['mainwin']) gui_items['unitpreslabel'].show() tbPres.pack_end(gui_items['unitpreslabel']) tbPres.show() tb.pack_end(tbPres) if self.usingMetric: gui_items['unitaltlabel'].text_set('m') gui_items['unitpreslabel'].text_set('hpa') else: gui_items['unitaltlabel'].text_set('ft') gui_items['unitpreslabel'].text_set('in hg') # Create the calibrate button bt = elementary.Button(gui_items['mainwin']) bt.text_set('Calibrate') bt._callback_add('clicked', self.calibrate) bt.size_hint_weight_set(1.0, 1.0) bt.size_hint_align_set(-1.0, 0.0) tb.pack_end(bt) bt.show() tbFile = elementary.Box(gui_items['mainwin']) tbFile.horizontal_set(1) #create the sensor name label fl = elementary.Label(gui_items['mainwin']) fl.text_set("location of the sensor sysfs file") fl.show() tb.pack_end(fl) # Create the sensor name Entry gui_items['pressureSensorFile'] = elementary.Entry( gui_items['mainwin']) gui_items['pressureSensorFile'].single_line_set(True) gui_items['pressureSensorFile'].entry_set(self.pressureSensorFile) gui_items['pressureSensorFile'].scale_set(1.0) gui_items['pressureSensorFile'].size_hint_weight_set(1, 1) gui_items['pressureSensorFile'].callback_activated_add( self.changeSensorFile) tbFile.pack_end(gui_items['pressureSensorFile']) gui_items['pressureSensorFile'].show() tbFile.show() tb.pack_end(tbFile) sc2.content_set(tb) gui_items['mainwin'].resize_object_add(gui_items['calibratebox']) gui_items['pager'].item_simple_push(gui_items['calibratebox']) ##### # Create about box (vertical by default) gui_items['aboutbox'] = elementary.Box(gui_items['mainwin']) gui_items['aboutbox'].size_hint_weight_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) gui_items['aboutbox'].size_hint_align_set(-1.0, -1.0) al = elementary.Label(gui_items['mainwin']) al.size_hint_weight_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) al.size_hint_align_set(0.5, -1.0) al.text_set("About Barom") gui_items['aboutbox'].pack_end(al) al.show() # Create scroller to hold the author's picture sc2 = elementary.Scroller(gui_items['mainwin']) sc2.bounce_set(0, 0) sc2.size_hint_weight_set(1.0, 1.0) sc2.size_hint_align_set(evas.EVAS_HINT_FILL, -1.0) gui_items['aboutbox'].pack_end(sc2) gui_items['mainwin'].resize_object_add(sc2) sc2.show() ib = elementary.Box(gui_items['aboutbox']) ic = elementary.Icon(gui_items['aboutbox']) gui_items['mainwin'].resize_object_add(ic) ic.size_hint_weight_set(0.5, 0.5) ic.scale_set(0.5, 0.5) ic.size_hint_align_set(0.5, 0.0) ic.file_set(os.path.join(IMAGE_DIR, "author.png")) ib.size_hint_weight_set(0.5, 0.5) ib.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL) ib.pack_end(ic) sc2.content_set(ib) ic.show() # Create text box with 'about' info at = elementary.Entry(gui_items['aboutbox']) at.size_hint_weight_set(1.0, 0.0) at.size_hint_align_set(evas.EVAS_HINT_FILL, 0.0) at.scale_set(1) info = self.infoadd("Barom " + APP_VERSION) info += self.infoadd("Copyright (c) 2011 Benjamin Deering") info += self.infoadd("<*****@*****.**>") at.text_set(info) gui_items['aboutbox'].pack_end(at) at.show() gui_items['mainwin'].resize_object_add(gui_items['aboutbox']) gui_items['pager'].item_simple_push(gui_items['aboutbox']) ##### # Create altitude box (vertical by default) gui_items['altitudebox'] = elementary.Box(gui_items['mainwin']) gui_items['altitudebox'].size_hint_weight_set(1.0, 1.0) gui_items['altitudebox'].size_hint_align_set(-1.0, -1.0) gui_items['altitudeLabel'] = elementary.Label(gui_items['mainwin']) gui_items['altitudeLabel'].text_set('altitude') gui_items['altitudeLabel'].scale_set(3.5) gui_items['altitudeLabel'].size_hint_weight_set(1.0, 1.0) gui_items['altitudeLabel'].size_hint_align_set(0.5, -1.0) gui_items['altitudebox'].pack_end(gui_items['altitudeLabel']) gui_items['altitudeLabel'].show() self.altitudeLabelTimer = ecore.timer_add(2, self.AltitudeLabelUpdate) gui_items['mainwin'].resize_object_add(gui_items['altitudebox']) gui_items['pager'].item_simple_push(gui_items['altitudebox']) gui_items['pager'].show() gui_items['mainbox'].pack_end(gui_items['pager']) gui_items['pager'].item_simple_promote(gui_items['altitudebox']) return gui_items