def photo_clicked(obj): win = StandardWindow("photo", "Photo test", autodel=True, size=(300, 300)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) elementary.need_ethumb() tb = Table(win, size_hint_weight=EXPAND_BOTH) tb.show() sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb) win.resize_object_add(sc) sc.show() n = 0 for j in range(12): for i in range(12): ph = Photo(win, aspect_fixed=False, size=80, editable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) name = os.path.join(img_path, images[n]) n += 1 if n >= 9: n = 0 if n == 8: ph.thumb = name else: ph.file = name if n in [2, 3]: ph.fill_inside = True ph.style = "shadow" tb.pack(ph, i, j, 1, 1) ph.show() win.show()
class PreferencesDialog(Window): """ Base class for all preferences dialogs """ def __init__(self, title): elm_conf = Configuration() scale = elm_conf.scale Window.__init__(self, title, ELM_WIN_BASIC, title=title, autodel=True) self.size = scale * 480, scale * 320 bg = Background(self, size_hint_weight=EXPAND_BOTH) self.resize_object_add(bg) bg.show() # bt = Button(self, text="Close") # bt.callback_clicked_add(lambda b: self.delete()) self.scroller = Scroller(self, policy=SCROLL_BOTH, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.resize_object_add(self.scroller) self.scroller.show() self.box = Box(self) self.box.size_hint_weight = EXPAND_BOTH self.scroller.content = self.box self.show()
def thumb_clicked(obj): if not elementary.need_ethumb(): print("Ethumb not available!") return images = ("panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg", "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg", "wood_01.jpg", "mystrale.jpg", "mystrale_2.jpg") win = StandardWindow("thumb", "Thumb", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) tb = Table(win, size_hint_weight=EXPAND_BOTH) n = 0 for j in range(12): for i in range(12): n = (n + 1) % 11 th = Thumb(win, file=os.path.join(img_path, images[n]), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, editable=True) tb.pack(th, i, j, 1, 1) th.show() sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb) win.resize_object_add(sc) tb.show() sc.show() win.show()
def __init__(self, parent_widget, titles=None, initial_sort=None, ascending=True, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.header = titles self.sort_column = initial_sort self.sort_column_ascending = ascending self.rows = [] self.header_row = [] self.header_box = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.header_box.horizontal = True self.header_box.show() scr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.list_box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.list_box.horizontal = True self.list_box.show() scr.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON) scr.content = self.list_box scr.show() self.lists = [] self.pack_end(self.header_box) self.pack_end(scr) self.show() if titles is not None: self.header_row_pack(titles)
def buildMainBox(self): # build our toolbar self.mainTb = Toolbar(self, homogeneous=False, size_hint_weight=(0.0, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.mainTb.item_append("remove", "Clear", self.clearPressed) self.mainTb.item_append("system-run", "Select All", self.selectAllPressed) self.mainTb.item_append("view-refresh", "Refresh", self.refreshPressed) self.mainTb.item_append("info", "Log", self.detailsPressed) self.mainTb.item_append("ok", "Apply", self.installUpdatesPressed) self.mainTb.show() # build our sortable list that displays packages that need updates titles = [("Upgrade", True), ("Package", True), ("Installed", True), ("Available", True)] scr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.packageList = sl.SortedList(scr, titles=titles, homogeneous=False, size_hint_weight=EXPAND_HORIZ) scr.content = self.packageList scr.show() # build the label that shows the package's description self.currentDescription = Label(self, size_hint_weight=FILL_BOTH) self.currentDescription.text = "Select a package for information" self.currentDescription.line_wrap_set(True) self.currentDescription.show() self.desFrame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.desFrame.text = "Description" self.desFrame.content = self.currentDescription self.desFrame.show() # add all of our objects to the box box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(self.mainTb) box.pack_end(scr) box.pack_end(self.desFrame) box.show() return box
def cb_item5(li, item): box = Box(li, size_hint_min=(150, 150)) sc = Scroller(li, bounce=(False, True), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.show() bt = Button(li, text="Enlightenment", size_hint_min=(140, 140)) sc.content = bt box.pack_end(sc) cp = Ctxpopup(li, content = box) (x, y) = li.evas.pointer_canvas_xy_get() cp.move(x, y) cp.show()
def __init__(self, parent_widget, *args, titles=None, initial_sort=0, ascending=True, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.header = titles self.sort_column = initial_sort self.sort_column_ascending = ascending self.rows = [] self.header_row = [] self.header_box = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.header_box.horizontal = True self.header_box.show() scr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.list_box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.list_box.horizontal = True self.list_box.show() scr.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON) scr.content = self.list_box scr.show() self.lists = [] self.pack_end(self.header_box) self.pack_end(scr) self.show() if titles is not None: self.header_row_pack(titles)
def thumb_clicked(obj): if not elementary.need_ethumb(): print("Ethumb not available!") return images = ( "panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg", "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg", "wood_01.jpg", "mystrale.jpg", "mystrale_2.jpg" ) win = StandardWindow("thumb", "Thumb", autodel=True, size=(600, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) tb = Table(win, size_hint_weight=EXPAND_BOTH) n = 0 for j in range(12): for i in range(12): n = (n + 1) % 11 th = Thumb(win, file=os.path.join(img_path, images[n]), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, editable=True) tb.pack(th, i, j, 1, 1) th.show() sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb) win.resize_object_add(sc) tb.show() sc.show() win.show()
def cb_item6(li, item): box = Box(li, size_hint_min=(200, 150)) sc = Scroller(li, bounce=(False, True), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.show() bt = Button(li, text="Ctxpop will be on the top of layer", size_hint_min=(190, 140)) bt.callback_clicked_add(cb_btn) sc.content = bt box.pack_end(sc) cp = Ctxpopup(li, content=box) cp.callback_dismissed_add(cb_dismissed) (x, y) = li.evas.pointer_canvas_xy_get() cp.move(x, y) cp.show() bt.data["ctxpopup"] = cp
en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set("guide", "Type widget name here to search.") en.callback_changed_add(cb_filter, win) bx1.pack_end(en) en.show() en.focus_set(True) sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, bounce=(False, True)) sc.show() box0.pack_end(sc) tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) sc.content_set(tbx) tbx.show() menu_create(None, win) win.resize(480, 480) win.show() elementary.run() elementary.shutdown()
class SortedList(Scroller): ''' A "spread sheet like" widget for elementary. Argument "titles" is a list, with each element being a tuple: (<Display Text>, <Sortable>) ''' def __init__(self, parent_widget, *args, titles=None, initial_sort=0, ascending=True, **kwargs): Scroller.__init__(self, parent_widget, *args, **kwargs) self.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF) self.main_box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.main_box.show() self.header = titles self.sort_column = initial_sort self.sort_column_ascending = ascending self.rows = [] self.header_row = [] header = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) header.callback_unpress_add(self.cb_resize_pane) header.show() list_pane = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) list_pane.callback_unpress_add(self.cb_resize_pane) list_pane.style_set("flush") list_pane.show() header.data["related"] = list_pane list_pane.data["related"] = header self.scroller = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.scroller.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO) self.scroller.content = list_pane self.scroller.show() self.headers = [] self.headers.append(header) self.list_panes = [] self.list_panes.append(list_pane) self.lists = [] if titles is not None: self.header_row_pack(titles) self.main_box.pack_end(header) self.main_box.pack_end(self.scroller) self.content = self.main_box self.show() def header_row_pack(self, titles): '''Takes a list (or a tuple) of tuples (string, bool, int) and packs them to the first row of the table.''' assert isinstance(titles, (list, tuple)) for _t in titles: assert isinstance(_t, tuple) assert len(_t) == 2 title, sortable = _t assert isinstance(title, str) assert isinstance(sortable, bool) def cb_sort_btn(button, col): '''Aux function''' if self.sort_column == col: self.reverse() else: self.sort_by_column(col) title_cnt = len(titles) for count, flag in enumerate(titles): title, sortable = flag btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text=title) btn.callback_clicked_add(cb_sort_btn, count) if not sortable: btn.disabled = True btn.show() self.header_row.append(btn) box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.show() if len(self.list_panes) < title_cnt: wdth = 1.0 / (title_cnt - count) self.list_panes[count].part_content_set("left", box) self.list_panes[count].content_left_size = wdth next_list = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) next_list.callback_unpress_add(self.cb_resize_pane) next_list.style_set("flush") next_list.show() self.list_panes[count].part_content_set("right", next_list) self.list_panes.append(next_list) self.headers[count].part_content_set("left", btn) self.headers[count].content_left_size = wdth next_header = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) next_header.callback_unpress_add(self.cb_resize_pane) next_header.show() self.headers[count].part_content_set("right", next_header) self.headers.append(next_header) next_list.data["related"] = next_header next_header.data["related"] = next_list else: self.list_panes[count - 1].part_content_set("right", box) self.headers[count - 1].part_content_set("right", btn) self.lists.append(box) # pylint: disable=no-self-use def cb_resize_pane(self, obj): '''Resize display pane''' left = obj.content_left_size right = obj.content_right_size related = obj.data["related"] related.content_left_size = left related.content_right_size = right def row_pack(self, row, sort=True): '''Takes a list of items and packs them to the table.''' assert len(row) == len(self.header_row), ( "The row you are trying to add to this sorted list has the wrong " "number of items! expected: %i got: %i" % (len(self.header_row), len(row))) self.rows.append(row) self.add_row(row) if sort: self.sort_by_column(self.sort_column) def add_row(self, row): '''Add Row to list''' # print("Test %s"%row) for count, item in enumerate(row): self.lists[count].pack_end(item) def row_unpack(self, row, delete=False): '''Unpacks and hides, and optionally deletes, a row of items. The argument row can either be the row itself or its index number. ''' if isinstance(row, int): row_index = row else: row_index = self.rows.index(row) + 1 # print("row index: " + str(row_index-1)) # print("length: " + str(len(self.rows))) # print("sort_data: " + str(row[self.sort_column].data["sort_data"])) row = self.rows.pop(row_index - 1) for count, item in enumerate(row): self.lists[count].unpack(item) if delete: item.delete() else: item.hide() self.sort_by_column(self.sort_column, ascending=self.sort_column_ascending) def unpack_all(self): '''Clear row''' tmplist = list(self.rows) for row in tmplist: self.row_unpack(row) def reverse(self): '''Reverse list''' rev_order = reversed(list(range(len(self.rows)))) for box in self.lists: box.unpack_all() for new_y in rev_order: self.add_row(self.rows[new_y]) label = self.header_row[self.sort_column].part_content_get("icon") if label is not None: if self.sort_column_ascending: label.text = u"⬆" self.sort_column_ascending = False else: label.text = u"⬇" self.sort_column_ascending = True self.rows.reverse() def sort_by_column(self, col, ascending=True): '''Sort column''' assert col >= 0 assert col < len(self.header_row) self.header_row[self.sort_column].icon = None btn = self.header_row[col] label = Label(btn) btn.part_content_set("labelon", label) label.show() if ascending: # sascending: label.text = u"⬇" self.sort_column_ascending = True else: label.text = u"⬆" self.sort_column_ascending = False orig_col = [ (i, x[col].data.get("sort_data", x[col].text)) for i, x in enumerate(self.rows) ] sorted_col = sorted(orig_col, key=lambda e: e[1]) new_order = [x[0] for x in sorted_col] if not ascending: new_order.reverse() for box in self.lists: box.unpack_all() for new_y in new_order: self.add_row(self.rows[new_y]) self.rows.sort(key=lambda e: e[col].data.get("sort_data", e[col].text)) self.sort_column = col def update(self): '''Update''' self.sort_by_column(self.sort_column, self.sort_column_ascending)
def focus_clicked(obj, item=None): win = StandardWindow("focus", "Focus", autodel=True, size=(800, 600)) win.focus_highlight_enabled = True tbx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tbx) tbx.show() ### Toolbar tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU, size_hint_align=(EVAS_HINT_FILL, 0.0)) tb_it = tbar.item_append("document-print", "Hello", _tb_sel) tb_it.disabled = True tb_it = tbar.item_append("folder-new", "World", _tb_sel) tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel) tb_it = tbar.item_append("mail-send", "Comes", _tb_sel) tb_it = tbar.item_append("clock", "Elementary", _tb_sel) tb_it = tbar.item_append("refresh", "Menu", _tb_sel) tb_it.menu = True tbar.menu_parent = win menu = tb_it.menu menu.item_add(None, "Shrink", "edit-cut", _tb_sel) menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel) menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel) menu.item_add(menu_it, "or to", "edit-paste", _tb_sel) menu.item_add(None, "Menu", "edit-delete", _tb_sel) tbx.pack_end(tbar) tbar.show() mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) tbx.pack_end(mainbx) mainbx.show() ## First Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>", size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() tg = Check(win, style="toggle") tg.part_text_set("on", "Yes") tg.part_text_set("off", "No") bx.pack_end(tg) tg.show() en = Entry(win, scrollable=True, single_line=True, text="This is a single line", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.pack_end(en) en.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 2)) bx2.pack_end(bt) bt.show() sc = Scroller(win, bounce=(True, True), content_min_limit=(1, 1), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(sc) sc.show() bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH) sc.content = bt bt.show() # bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx.pack_end(bt) bt.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bx3 = Box(win, size_hint_align=FILL_BOTH) bx2.pack_end(bx3) bx3.show() for j in range(3): bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() sc = Scroller(win, bounce=(False, True), content_min_limit=(1, 0), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.content_min_limit = (1, 1) bx2.pack_end(sc) sc.show() bx3 = Box(win, size_hint_align=FILL_BOTH) sc.content = bx3 bx3.show() for i in range(5): bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() ## Second Col ly = Layout(win, size_hint_weight=EXPAND_BOTH) ly.file = edj_file, "twolines" mainbx.pack_end(ly) ly.show() bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) ly.part_content_set("element1", bx2) bx2.show() for i in range(3): bt = Button(win, text="Layout", size_hint_align=FILL_BOTH) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bx2 = Box(win, size_hint_align=FILL_BOTH) ly.part_content_set("element2", bx2) bx2.show() bt = Button(win, text="Disable", size_hint_align=FILL_BOTH) bt.callback_clicked_add(lambda b: b.disabled_set(True)) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH) bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt) bx2.pack_end(bt2) bt2.show() bx2.focus_custom_chain_append(bt2) ## Third Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() fr = Frame( win, text="Frame", ) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(1): for i in range(2): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() # fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(2): for i in range(1): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() win.show()
def config_clicked(obj, data=None): siname = "_TestConfigSocketImage_" win = StandardWindow("config", "Configuration", autodel=True, size=(400,500)) global ad ad = App_Data() win.data["ad"] = ad ad.win = win ad.profiles = elm_conf.profile_list bx = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) sc = Scroller(win, content=bx, bounce=(False, True), size_hint_weight=EXPAND_BOTH) win.resize_object_add(sc) fr, bx2 = FRAME(win, bx, "Current window profile") # TODO: Add this code #ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); #supported = ecore_evas_window_profile_supported_get(ee); supported = True buf = "Virtual desktop window profile support: <b>{0}</b>".format( "Yes" if supported else "No") lb = LOG(win, buf) bx2.pack_end(lb) lb = LOG(win, "Profile: <b>N/A</b><br/>Available profiles:") bx2.pack_end(lb) win.data["lb"] = lb lb = LOG(win, "<br/>Window profile") bx2.pack_end(lb) ad.curr.rdg = radio_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_profile_set, win) bx2.pack_end(bt) bt.show() lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.curr.cks = check_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_available_profiles_set, win) bx2.pack_end(bt) bt.show() fr, bx2 = FRAME(win, bx, "Socket") if socket_add(siname): lb = LOG(win, "Starting socket image.") bx2.pack_end(lb) else: lb = LOG(win, "Failed to create socket.<br/>Please check whether another " "test configuration window is<br/>already running and providing " "socket image.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Plug") if not plug_add(win, bx2, siname): lb = LOG(win, "Failed to connect to server.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Create new window with profile") lb = LOG(win, "Window profile") bx2.pack_end(lb) ad.new.rdg = radio_add(win, bx2) lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.new.cks = check_add(win, bx2) bt = Button(win, text="Create") bt.callback_clicked_add(bt_win_add, win) bx2.pack_end(bt) bt.show() win.callback_profile_changed_add(win_profile_changed_cb) win.callback_delete_request_add(win_del_cb) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) if data: if data.available_profiles: win.available_profiles = data.available_profiles if data.profile: win.profile = data.profile profile_update(win) bx.show() sc.show() win.show()
def focus_clicked(obj, item=None): win = StandardWindow("focus", "Focus", autodel=True, size=(800,600)) win.focus_highlight_enabled = True tbx = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tbx) tbx.show() ### Toolbar tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU, size_hint_align=(EVAS_HINT_FILL,0.0)) tb_it = tbar.item_append("document-print", "Hello", _tb_sel) tb_it.disabled = True tb_it = tbar.item_append("folder-new", "World", _tb_sel) tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel) tb_it = tbar.item_append("mail-send", "Comes", _tb_sel) tb_it = tbar.item_append("clock", "Elementary", _tb_sel) tb_it = tbar.item_append("refresh", "Menu", _tb_sel) tb_it.menu = True tbar.menu_parent = win menu = tb_it.menu menu.item_add(None, "Shrink", "edit-cut", _tb_sel) menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel) menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel) menu.item_add(menu_it, "or to", "edit-paste", _tb_sel) menu.item_add(None, "Menu", "edit-delete", _tb_sel) tbx.pack_end(tbar) tbar.show() mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH) tbx.pack_end(mainbx) mainbx.show() ## First Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>", size_hint_align=FILL_BOTH) bx.pack_end(lb) lb.show() tg = Check(win, style="toggle") tg.part_text_set("on", "Yes") tg.part_text_set("off", "No") bx.pack_end(tg) tg.show() en = Entry(win, scrollable=True, single_line=True, text="This is a single line", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) bx.pack_end(en) en.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 2)) bx2.pack_end(bt) bt.show() sc = Scroller(win, bounce=(True,True), content_min_limit=(1,1), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx2.pack_end(sc) sc.show() bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH) sc.content = bt bt.show() # bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx.pack_end(bt) bt.show() # bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) bx.pack_end(bx2) bx2.show() for i in range(2): bx3 = Box(win, size_hint_align=FILL_BOTH) bx2.pack_end(bx3) bx3.show() for j in range(3): bt = Button(win, text="Box", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() sc = Scroller(win, bounce=(False, True), content_min_limit=(1,0), size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) sc.content_min_limit=(1,1) bx2.pack_end(sc) sc.show() bx3 = Box(win, size_hint_align=FILL_BOTH) sc.content = bx3 bx3.show() for i in range(5): bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH) bx3.pack_end(bt) bt.show() ## Second Col ly = Layout(win, size_hint_weight=EXPAND_BOTH) ly.file = edj_file, "twolines" mainbx.pack_end(ly) ly.show() bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH) ly.part_content_set("element1", bx2) bx2.show() for i in range(3): bt = Button(win, text="Layout", size_hint_align=FILL_BOTH) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bx2 = Box(win, size_hint_align=FILL_BOTH) ly.part_content_set("element2", bx2) bx2.show() bt = Button(win, text="Disable", size_hint_align=FILL_BOTH) bt.callback_clicked_add(lambda b: b.disabled_set(True)) bx2.pack_end(bt) bt.show() bx2.focus_custom_chain_prepend(bt) bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH) bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt) bx2.pack_end(bt2) bt2.show() bx2.focus_custom_chain_append(bt2) ## Third Col bx = Box(win, size_hint_weight=EXPAND_BOTH) mainbx.pack_end(bx) bx.show() fr = Frame(win, text="Frame", ) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(1): for i in range(2): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() # fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) bx.pack_end(fr) fr.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) fr.content = tb tb.show() for j in range(2): for i in range(1): bt = Button(win, text="Table", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) tb.pack(bt, i, j, 1, 1) bt.show() win.show()
def config_clicked(obj, data=None): siname = "_TestConfigSocketImage_" win = StandardWindow("config", "Configuration", autodel=True, size=(400, 500)) global ad ad = App_Data() win.data["ad"] = ad ad.win = win ad.profiles = elm_conf.profile_list bx = Box(win, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) sc = Scroller(win, content=bx, bounce=(False, True), size_hint_weight=EXPAND_BOTH) win.resize_object_add(sc) fr, bx2 = FRAME(win, bx, "Current window profile") # TODO: Add this code #ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); #supported = ecore_evas_window_profile_supported_get(ee); supported = True buf = "Virtual desktop window profile support: <b>{0}</b>".format( "Yes" if supported else "No") lb = LOG(win, buf) bx2.pack_end(lb) lb = LOG(win, "Profile: <b>N/A</b><br/>Available profiles:") bx2.pack_end(lb) win.data["lb"] = lb lb = LOG(win, "<br/>Window profile") bx2.pack_end(lb) ad.curr.rdg = radio_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_profile_set, win) bx2.pack_end(bt) bt.show() lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.curr.cks = check_add(win, bx2) bt = Button(win, text="Set") bt.callback_clicked_add(bt_available_profiles_set, win) bx2.pack_end(bt) bt.show() fr, bx2 = FRAME(win, bx, "Socket") if socket_add(siname): lb = LOG(win, "Starting socket image.") bx2.pack_end(lb) else: lb = LOG( win, "Failed to create socket.<br/>Please check whether another " "test configuration window is<br/>already running and providing " "socket image.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Plug") if not plug_add(win, bx2, siname): lb = LOG(win, "Failed to connect to server.") bx2.pack_end(lb) fr, bx2 = FRAME(win, bx, "Create new window with profile") lb = LOG(win, "Window profile") bx2.pack_end(lb) ad.new.rdg = radio_add(win, bx2) lb = LOG(win, "Window available profiles") bx2.pack_end(lb) ad.new.cks = check_add(win, bx2) bt = Button(win, text="Create") bt.callback_clicked_add(bt_win_add, win) bx2.pack_end(bt) bt.show() win.callback_profile_changed_add(win_profile_changed_cb) win.callback_delete_request_add(win_del_cb) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) if data: if data.available_profiles: win.available_profiles = data.available_profiles if data.profile: win.profile = data.profile profile_update(win) bx.show() sc.show() win.show()
class TabbedBox(Box): def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.tabs = [] self.currentTab = None self.tabChangedCallback = None self.closeCallback = None self.emptyCallback = None self.scr = Scroller(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) self.scr.content_min_limit(False, True) self.buttonBox = Box(self.scr, size_hint_weight=EXPAND_HORIZ, align=ALIGN_LEFT) self.buttonBox.horizontal = True self.buttonBox.show() self.scr.content = self.buttonBox self.scr.show() self.nf = Naviframe(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.nf.show() self.pack_end(self.scr) self.pack_end(self.nf) def addTab(self, widget, tabName, canClose=True, disabled=False): self.tabs.append(widget) btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT) btn.text = tabName btn.data["widget"] = widget btn.disabled = disabled btn.callback_clicked_add(self.showTab, widget) btn.show() icn = Icon(self.buttonBox) icn.standard_set("gtk-close") icn.show() cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT) cls.data["widget"] = widget cls.callback_clicked_add(self.closeTab) cls.disabled = disabled if canClose: cls.show() sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT) sep.show() self.buttonBox.pack_end(btn) self.buttonBox.pack_end(cls) self.buttonBox.pack_end(sep) #Arguments go: btn, cls, sep widget.data["close"] = cls widget.data["button"] = btn widget.data["sep"] = sep self.showTab(widget=widget) def disableTab(self, tabIndex): btn, cls = self.tabs[tabIndex].data["button"], self.tabs[ tabIndex].data["close"] btn.disabled = True cls.disabled = True def enableTab(self, tabIndex): btn, cls = self.tabs[tabIndex].data["button"], self.tabs[ tabIndex].data["close"] btn.disabled = False cls.disabled = False def showTab(self, btn=None, widget=None): if type(btn) is int: widget = self.tabs[btn] if widget != self.currentTab: if self.currentTab: self.currentTab.data["button"].style = "anchor" self.nf.item_simple_push(widget) self.currentTab = widget self.currentTab.data["button"].style = "widget" if self.tabChangedCallback: self.tabChangedCallback(self, widget) def closeTab(self, btn): if not self.closeCallback: self.deleteTab(btn.data["widget"]) else: self.closeCallback(self, btn.data["widget"]) def deleteTab(self, widget): if type(widget) is int: widget = self.tabs[widget] del self.tabs[self.tabs.index(widget)] self.buttonBox.unpack(widget.data["close"]) self.buttonBox.unpack(widget.data["button"]) self.buttonBox.unpack(widget.data["sep"]) widget.data["close"].delete() widget.data["button"].delete() widget.data["sep"].delete() widget.delete() if self.currentTab == widget and len(self.tabs): self.showTab(widget=self.tabs[0]) if not len(self.tabs) and self.emptyCallback: self.emptyCallback(self)
def mapbuf_clicked(obj, item=None): global mb_list win = Window("mapbuf", ELM_WIN_BASIC, title="Mapbuf test", autodel=True, size=(480, 600)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) bg = Background(win, file=os.path.join(img_path, "sky_04.jpg"), size_hint_weight=EXPAND_BOTH) win.resize_object_add(bg) bg.show() vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() # launcher sc = Scroller(win, bounce=(True, False), policy=SCROLL_POLICY_OFF, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH) vbox.pack_end(sc) bx = Box(win, horizontal=True, homogeneous=True) bx.show() for k in range(8): tb = Table(win, size_hint_align=ALIGN_CENTER, size_hint_weight=(0.0, 0.0)) tb.show() pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 0, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (464, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 1, 11, 5, 1) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 0, 1, 1, 10) pad = Rectangle(win.evas, color=(255, 255, 0, 255)) pad.size_hint_min = (4, 4) pad.size_hint_weight = (0.0, 0.0) pad.size_hint_align = (EVAS_HINT_FILL, EVAS_HINT_FILL) pad.show() tb.pack(pad, 6, 1, 1, 10) mb = Mapbuf(win, content=tb) mb.point_color_set(k % 4, 255, 0, 0, 255) mb_list.append(mb) bx.pack_end(mb) mb.show() n = m = 0 for j in range(5): for i in range(5): ic = Icon(win, scale=0.5, file=os.path.join(img_path, "icon_%02d.png" % (n)), resizable=(False, False), size_hint_weight=EXPAND_BOTH, size_hint_align=ALIGN_CENTER) tb.pack(ic, 1 + i, 1 + (j * 2), 1, 1) ic.show() lb = Label(win, style="marker", text=names[m]) tb.pack(lb, 1 + i, 1 + (j * 2) + 1, 1, 1) lb.show() n = n + 1 if n < 23 else 0 m = m + 1 if m < 15 else 0 sc.content = bx sc.page_relative_set(1.0, 1.0) sc.show() # controls hbox = Box(win, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) vbox.pack_start(hbox) hbox.show() ck = Check(win, text="Map", state=False) ck.callback_changed_add(cb_ck_map) hbox.pack_end(ck) ck.show() ck = Check(win, text="Alpha", state=True) ck.callback_changed_add(cb_ck_alpha) hbox.pack_end(ck) ck.show() ck = Check(win, text="Smooth", state=True) ck.callback_changed_add(cb_ck_smooth) hbox.pack_end(ck) ck.show() ck = Check(win, text="FS", state=False) ck.callback_changed_add(cb_ck_fs, win) hbox.pack_end(ck) ck.show() bt = Button(win, text="Close", size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_close, win) hbox.pack_end(bt) bt.show() win.show()
def multibuttonentry_clicked(obj, item=None): win = StandardWindow("multibuttonentry", "MultiButtonEntry test", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() mbe = MultiButtonEntry(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, text="To: ") mbe.callback_item_selected_add(cb_item_selected) mbe.part_text_set("guide", "Tap to add recipient") mbe.filter_append(cb_filter1) mbe.show() sc = Scroller(win, bounce=(False, True), policy=SCROLL_POLICY_VERT, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, content=mbe) vbox.pack_end(sc) sc.show() print(mbe.entry) hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="item_append", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_append, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_prepend", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_prepend, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_insert_after", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_insert_after, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_insert_before", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_insert_before, mbe) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="delete selected item", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: mbe.selected_item.delete()) hbox.pack_end(bt) bt.show() bt = Button(win, text="clear", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda bt: mbe.clear()) hbox.pack_end(bt) bt.show() bt = Button(win, text="clear2", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_clear2, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="toggle expand", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: mbe.expanded_set(not mbe.expanded_get())) hbox.pack_end(bt) bt.show() bt = Button(win, text="print", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_print, mbe) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Change format function", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda b: mbe.format_function_set(custom_format_func)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Unset format function", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda b: mbe.format_function_set(None)) hbox.pack_end(bt) bt.show() mbe.focus = True win.show()
class TabbedBox(Box): '''A TabbedBox class.''' def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.tabs = [] self.current = None self.tab_changed_cb = None self.close_cb = None self.empty_cb = None self.scr = Scroller(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) self.scr.content_min_limit(False, True) self.button_bx = Box(self.scr, size_hint_weight=EXPAND_HORIZ, align=ALIGN_LEFT) self.button_bx.horizontal = True self.button_bx.show() self.scr.content = self.button_bx self.scr.show() self.nav_fr = Naviframe(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.nav_fr.show() self.pack_end(self.scr) self.pack_end(self.nav_fr) def add(self, widget, name, can_close=True, disabled=False): '''Add a tab to the tabbed box''' self.tabs.append(widget) btn = Button(self.button_bx, style="anchor", size_hint_align=ALIGN_LEFT) btn.text = name btn.data["widget"] = widget btn.disabled = disabled btn.callback_clicked_add(self.show_tab, widget) btn.show() icn = Icon(self.button_bx) icn.standard_set("gtk-close") icn.show() cls = Button(self.button_bx, content=icn, style="anchor", size_hint_align=ALIGN_LEFT) cls.data["widget"] = widget cls.callback_clicked_add(self.cb_close_btn) cls.disabled = disabled if can_close: cls.show() sep = Separator(self.button_bx, size_hint_align=ALIGN_LEFT) sep.show() self.button_bx.pack_end(btn) self.button_bx.pack_end(cls) self.button_bx.pack_end(sep) # Arguments go: btn, cls, sep widget.data["close"] = cls widget.data["button"] = btn widget.data["sep"] = sep self.show_tab(widget=widget) def disable(self, index): '''Disable a tab''' btn, cls = self.tabs[index].data["button"], self.tabs[index].data[ "close"] btn.disabled = True cls.disabled = True def enable(self, index): '''Enable a tab''' btn, cls = self.tabs[index].data["button"], self.tabs[index].data[ "close"] btn.disabled = False cls.disabled = False def show_tab(self, btn=None, widget=None): '''Show tab''' # pylint: disable=unidiomatic-typecheck # This is as clear as any alternative to me if type(btn) is int: widget = self.tabs[btn] if widget != self.current: if self.current: self.current.data["button"].style = "anchor" self.nav_fr.item_simple_push(widget) self.current = widget self.current.data["button"].style = "widget" if self.tab_changed_cb: # pylint: disable=not-callable self.tab_changed_cb(self, widget) def cb_close_btn(self, btn): '''Close tab''' # pylint: disable=not-callable if not self.close_cb: self.delete_tab(btn.data["widget"]) else: self.close_cb(self, btn.data["widget"]) def delete_tab(self, widget): '''Delete tab''' # pylint: disable=unidiomatic-typecheck # This is as clear as any alternative to me if type(widget) is int: widget = self.tabs[widget] del self.tabs[self.tabs.index(widget)] self.button_bx.unpack(widget.data["close"]) self.button_bx.unpack(widget.data["button"]) self.button_bx.unpack(widget.data["sep"]) widget.data["close"].delete() widget.data["button"].delete() widget.data["sep"].delete() widget.delete() if self.current == widget and self.tabs: self.show_tab(widget=self.tabs[0]) if not self.tabs and self.empty_cb: # pylint: disable=not-callable self.empty_cb(self)
class SortedList(Scroller): """ A "spread sheet like" widget for elementary. Argument "titles" is a list, with each element being a tuple: (<Display Text>, <Sortable>) """ def __init__(self, parent_widget, titles=None, initial_sort=0, ascending=True, *args, **kwargs): Scroller.__init__(self, parent_widget, *args, **kwargs) self.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF) self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.header = titles self.sort_column = initial_sort self.sort_column_ascending = ascending self.rows = [] self.header_row = [] headerPane = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) headerPane.callback_unpress_add(self.paneResized) headerPane.show() listPane = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) listPane.callback_unpress_add(self.paneResized) listPane.style_set("flush") listPane.show() headerPane.data["related"] = listPane listPane.data["related"] = headerPane self.mainScr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainScr.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO) self.mainScr.content = listPane self.mainScr.show() self.headerPanes = [] self.headerPanes.append(headerPane) self.listPanes = [] self.listPanes.append(listPane) self.lists = [] #self.pack_end(self.header_box) if titles is not None: self.header_row_pack(titles) self.mainBox.pack_end(headerPane) self.mainBox.pack_end(self.mainScr) self.content = self.mainBox self.show() def header_row_pack(self, titles): """Takes a list (or a tuple) of tuples (string, bool, int) and packs them to the first row of the table.""" assert isinstance(titles, (list, tuple)) for t in titles: assert isinstance(t, tuple) assert len(t) == 2 title, sortable = t try: assert isinstance(title, basestring) except: assert isinstance(title, str) assert isinstance(sortable, bool) def sort_btn_cb(button, col): if self.sort_column == col: self.reverse() else: self.sort_by_column(col) titleCount = len(titles) for count, t in enumerate(titles): title, sortable = t btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text=title) btn.callback_clicked_add(sort_btn_cb, count) if not sortable: btn.disabled = True btn.show() self.header_row.append(btn) bx = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.show() if len(self.listPanes) < titleCount: wdth = 1.0 / (titleCount - count) self.listPanes[count].part_content_set("left", bx) self.listPanes[count].content_left_size = wdth nextList = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) nextList.callback_unpress_add(self.paneResized) nextList.style_set("flush") nextList.show() self.listPanes[count].part_content_set("right", nextList) self.listPanes.append(nextList) self.headerPanes[count].part_content_set("left", btn) self.headerPanes[count].content_left_size = wdth nextHeader = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) nextHeader.callback_unpress_add(self.paneResized) nextHeader.show() self.headerPanes[count].part_content_set("right", nextHeader) self.headerPanes.append(nextHeader) nextList.data["related"] = nextHeader nextHeader.data["related"] = nextList else: self.listPanes[count - 1].part_content_set("right", bx) self.headerPanes[count - 1].part_content_set("right", btn) self.lists.append(bx) def paneResized(self, obj): leftSize = obj.content_left_size rightSize = obj.content_right_size related = obj.data["related"] related.content_left_size = leftSize related.content_right_size = rightSize def row_pack(self, row, sort=True): """Takes a list of items and packs them to the table.""" assert len(row) == len(self.header_row), ( "The row you are trying to add to this sorted list has the wrong " "number of items! expected: %i got: %i" % (len(self.header_row), len(row))) self.rows.append(row) self.add_row(row) if sort: self.sort_by_column(self.sort_column) def add_row(self, row): #print("Test %s"%row) for count, item in enumerate(row): self.lists[count].pack_end(item) def row_unpack(self, row, delete=False): """Unpacks and hides, and optionally deletes, a row of items. The argument row can either be the row itself or its index number. """ if isinstance(row, int): row_index = row else: row_index = self.rows.index(row) + 1 # print("row index: " + str(row_index-1)) # print("length: " + str(len(self.rows))) # print("sort_data: " + str(row[self.sort_column].data["sort_data"])) row = self.rows.pop(row_index - 1) for count, item in enumerate(row): self.lists[count].unpack(item) if delete: item.delete() else: item.hide() self.sort_by_column(self.sort_column, ascending=self.sort_column_ascending) def unpack_all(self): tmplist = list(self.rows) for rw in tmplist: self.row_unpack(rw) def reverse(self): rev_order = reversed(list(range(len(self.rows)))) for bx in self.lists: bx.unpack_all() for new_y in rev_order: self.add_row(self.rows[new_y]) lb = self.header_row[self.sort_column].part_content_get("icon") if lb is not None: if self.sort_column_ascending: lb.text = u"⬆" self.sort_column_ascending = False else: lb.text = u"⬇" self.sort_column_ascending = True self.rows.reverse() def sort_by_column(self, col, ascending=True): assert col >= 0 assert col < len(self.header_row) self.header_row[self.sort_column].icon = None btn = self.header_row[col] ic = Label(btn) btn.part_content_set("icon", ic) ic.show() if ascending == True: #ascending: ic.text = u"⬇" self.sort_column_ascending = True else: ic.text = u"⬆" self.sort_column_ascending = False orig_col = [ (i, x[col].data.get("sort_data", x[col].text)) \ for i, x in enumerate(self.rows) ] sorted_col = sorted(orig_col, key=lambda e: e[1]) new_order = [x[0] for x in sorted_col] # print(new_order) if not ascending: new_order.reverse() # print(new_order) for bx in self.lists: bx.unpack_all() for new_y in new_order: self.add_row(self.rows[new_y]) self.rows.sort(key=lambda e: e[col].data.get("sort_data", e[col].text), #reverse=False if ascending else True ) self.sort_column = col def update(self): self.sort_by_column(self.sort_column, self.sort_column_ascending)
def scroller_clicked(obj): win = StandardWindow("scroller", "Scroller", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) tb = Table(win, size_hint_weight=EXPAND_BOTH) img = ["panel_01.jpg", "plant_01.jpg", "rock_01.jpg", "rock_02.jpg", "sky_01.jpg", "sky_02.jpg", "sky_03.jpg", "sky_04.jpg", "wood_01.jpg"] n = 0 for j in range(12): for i in range(12): bg2 = Background(win, file=os.path.join(img_path, img[n]), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, size_hint_min=(318, 318)) n = n + 1 if n >= 9: n = 0 tb.pack(bg2, i, j, 1, 1) bg2.show() sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb, page_relative=(1.0, 1.0)) sc.callback_edge_top_add(cb_edges, "top") sc.callback_edge_bottom_add(cb_edges, "bottom") sc.callback_edge_left_add(cb_edges, "left") sc.callback_edge_right_add(cb_edges, "right") sc.callback_scroll_drag_start_add(cb_drags, "start") sc.callback_scroll_drag_stop_add(cb_drags, "stop") sc.callback_scroll_anim_start_add(cb_anims, "start") sc.callback_scroll_anim_stop_add(cb_anims, "stop") win.resize_object_add(sc) tb.show() sc.show() tb2 = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb2) bt = Button(win, text="to 300 300", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.1, 0.1)) bt.callback_clicked_add(my_scroller_go_300_300, sc) tb2.pack(bt, 0, 0, 1, 1) bt.show() bt = Button(win, text="to 900 300", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.1)) bt.callback_clicked_add(my_scroller_go_900_300, sc) tb2.pack(bt, 1, 0, 1, 1) bt.show() bt = Button(win, text="to 300 900", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.1, 0.9)) bt.callback_clicked_add(my_scroller_go_300_900, sc) tb2.pack(bt, 0, 1, 1, 1) bt.show() bt = Button(win, text="to 900 900", size_hint_weight=EXPAND_BOTH, size_hint_align=(0.9, 0.9)) bt.callback_clicked_add(my_scroller_go_900_900, sc) tb2.pack(bt, 1, 1, 1, 1) bt.show() tb2.show() win.show()
class SortedList(Scroller): """ A "spread sheet like" widget for elementary. Argument "titles" is a list, with each element being a tuple: (<Display Text>, <Sortable>) """ def __init__(self, parent_widget, titles=None, initial_sort=0, ascending=True, *args, **kwargs): Scroller.__init__(self, parent_widget, *args, **kwargs) self.policy_set(ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF) self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.header = titles self.sort_column = initial_sort self.sort_column_ascending = ascending self.rows = [] self.header_row = [] headerPane = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) headerPane.callback_unpress_add(self.paneResized) headerPane.show() listPane = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) listPane.callback_unpress_add(self.paneResized) listPane.style_set("flush") listPane.show() headerPane.data["related"] = listPane listPane.data["related"] = headerPane self.mainScr = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainScr.policy_set(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO) self.mainScr.content = listPane self.mainScr.show() self.headerPanes = [] self.headerPanes.append(headerPane) self.listPanes = [] self.listPanes.append(listPane) self.lists = [] #self.pack_end(self.header_box) if titles is not None: self.header_row_pack(titles) self.mainBox.pack_end(headerPane) self.mainBox.pack_end(self.mainScr) self.content = self.mainBox self.show() def header_row_pack(self, titles): """Takes a list (or a tuple) of tuples (string, bool, int) and packs them to the first row of the table.""" assert isinstance(titles, (list, tuple)) for t in titles: assert isinstance(t, tuple) assert len(t) == 2 title, sortable = t try: assert isinstance(title, basestring) except: assert isinstance(title, str) assert isinstance(sortable, bool) def sort_btn_cb(button, col): if self.sort_column == col: self.reverse() else: self.sort_by_column(col) titleCount = len(titles) for count, t in enumerate(titles): title, sortable = t btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, text=title) btn.callback_clicked_add(sort_btn_cb, count) if not sortable: btn.disabled = True btn.show() self.header_row.append(btn) bx = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) bx.show() if len(self.listPanes) < titleCount: wdth = 1.0 / (titleCount - count) self.listPanes[count].part_content_set("left", bx) self.listPanes[count].content_left_size = wdth nextList = Panes(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) nextList.callback_unpress_add(self.paneResized) nextList.style_set("flush") nextList.show() self.listPanes[count].part_content_set("right", nextList) self.listPanes.append(nextList) self.headerPanes[count].part_content_set("left", btn) self.headerPanes[count].content_left_size = wdth nextHeader = Panes(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) nextHeader.callback_unpress_add(self.paneResized) nextHeader.show() self.headerPanes[count].part_content_set("right", nextHeader) self.headerPanes.append(nextHeader) nextList.data["related"] = nextHeader nextHeader.data["related"] = nextList else: self.listPanes[count - 1].part_content_set("right", bx) self.headerPanes[count - 1].part_content_set("right", btn) self.lists.append(bx) def paneResized(self, obj): leftSize = obj.content_left_size rightSize = obj.content_right_size related = obj.data["related"] related.content_left_size = leftSize related.content_right_size = rightSize def row_pack(self, row, sort=True): """Takes a list of items and packs them to the table.""" assert len(row) == len(self.header_row), ( "The row you are trying to add to this sorted list has the wrong " "number of items! expected: %i got: %i" % ( len(self.header_row), len(row) ) ) self.rows.append(row) self.add_row(row) if sort: self.sort_by_column(self.sort_column) def add_row(self, row): #print("Test %s"%row) for count, item in enumerate(row): self.lists[count].pack_end(item) def row_unpack(self, row, delete=False): """Unpacks and hides, and optionally deletes, a row of items. The argument row can either be the row itself or its index number. """ if isinstance(row, int): row_index = row else: row_index = self.rows.index(row)+1 # print("row index: " + str(row_index-1)) # print("length: " + str(len(self.rows))) # print("sort_data: " + str(row[self.sort_column].data["sort_data"])) row = self.rows.pop(row_index-1) for count, item in enumerate(row): self.lists[count].unpack(item) if delete: item.delete() else: item.hide() self.sort_by_column(self.sort_column, ascending=self.sort_column_ascending) def unpack_all(self): tmplist = list(self.rows) for rw in tmplist: self.row_unpack(rw) def reverse(self): rev_order = reversed(list(range(len(self.rows)))) for bx in self.lists: bx.unpack_all() for new_y in rev_order: self.add_row(self.rows[new_y]) lb = self.header_row[self.sort_column].part_content_get("icon") if lb is not None: if self.sort_column_ascending: lb.text = u"⬆" self.sort_column_ascending = False else: lb.text = u"⬇" self.sort_column_ascending = True self.rows.reverse() def sort_by_column(self, col, ascending=True): assert col >= 0 assert col < len(self.header_row) self.header_row[self.sort_column].icon = None btn = self.header_row[col] ic = Label(btn) btn.part_content_set("icon", ic) ic.show() if ascending == True: #ascending: ic.text = u"⬇" self.sort_column_ascending = True else: ic.text = u"⬆" self.sort_column_ascending = False orig_col = [ (i, x[col].data.get("sort_data", x[col].text)) \ for i, x in enumerate(self.rows) ] sorted_col = sorted(orig_col, key=lambda e: e[1]) new_order = [x[0] for x in sorted_col] # print(new_order) if not ascending: new_order.reverse() # print(new_order) for bx in self.lists: bx.unpack_all() for new_y in new_order: self.add_row(self.rows[new_y]) self.rows.sort( key=lambda e: e[col].data.get("sort_data", e[col].text), #reverse=False if ascending else True ) self.sort_column = col def update(self): self.sort_by_column(self.sort_column, self.sort_column_ascending)
lb = Label(win, text="Filter:") bx1.pack_end(lb) lb.show() en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) en.part_text_set("guide", "Type widget name here to search.") en.callback_changed_add(cb_filter, win) bx1.pack_end(en) en.show() en.focus_set(True) sc = Scroller(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, bounce=(False, True)) sc.show() box0.pack_end(sc) tbx = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) sc.content_set(tbx) tbx.show() menu_create(None, win) win.resize(480, 480) win.show() elementary.run() elementary.shutdown()
def multibuttonentry_clicked(obj, item=None): win = StandardWindow("multibuttonentry", "MultiButtonEntry test", autodel=True, size=(320, 320)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(vbox) vbox.show() mbe = MultiButtonEntry(win, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, text="To: ") mbe.callback_item_selected_add(cb_item_selected) mbe.part_text_set("guide", "Tap to add recipient") mbe.filter_append(cb_filter1) mbe.show() sc = Scroller(win, bounce=(False, True), policy=SCROLL_POLICY_VERT, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, content=mbe) vbox.pack_end(sc) sc.show() print(mbe.entry) hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="item_append", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_append, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_prepend", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_prepend, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_insert_after", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_insert_after, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="item_insert_before", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_item_insert_before, mbe) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="delete selected item", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda btn: mbe.selected_item.delete()) hbox.pack_end(bt) bt.show() bt = Button(win, text="clear", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda bt: mbe.clear()) hbox.pack_end(bt) bt.show() bt = Button(win, text="clear2", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_btn_clear2, mbe) hbox.pack_end(bt) bt.show() bt = Button(win, text="toggle expand", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add( lambda btn: mbe.expanded_set(not mbe.expanded_get())) hbox.pack_end(bt) bt.show() bt = Button(win, text="print", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(cb_print, mbe) hbox.pack_end(bt) bt.show() hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_HORIZ) vbox.pack_end(hbox) hbox.show() bt = Button(win, text="Change format function", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add( lambda b: mbe.format_function_set(custom_format_func)) hbox.pack_end(bt) bt.show() bt = Button(win, text="Unset format function", size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) bt.callback_clicked_add(lambda b: mbe.format_function_set(None)) hbox.pack_end(bt) bt.show() mbe.focus = True win.show()
class ConjectureGUI(object): def __init__(self, windowGrid, name): offset = 0 if (name == 'Yau'): offset = 50 self.BaseBox = Box(windowGrid, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL)) windowGrid.pack(self.BaseBox, offset, 0, 50, 100) self.BaseBox.show() self.frame = Frame(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL), text=name) self.BaseBox.pack_end(self.frame) self.frame.show() self.FrameBox = Box(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL)) self.frame.content_set(self.FrameBox) self.FrameBox.show() self.FrameCheck = Check(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), text="{0} Frame Check".format(name)) self.FrameBox.pack_end(self.FrameCheck) self.FrameCheck.show() self.FrameSeparator = Separator(self.BaseBox, horizontal=True, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5)) self.FrameBox.pack_end(self.FrameSeparator) self.FrameSeparator.show() self.FrameScroller = Scroller( self.BaseBox, content_min_limit=(True, False), size_hint_weight=(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), size_hint_align=(EVAS_HINT_FILL, EVAS_HINT_FILL), scrollbar_policy=(ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF)) self.FrameBox.pack_end(self.FrameScroller) self.FrameScroller.show() self.FrameTable = Table(self.BaseBox, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0)) self.FrameScroller.content_set(self.FrameTable) self.FrameTable.show() self.BaseLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Base:") self.FrameTable.pack(self.BaseLabel, 0, 0, 1, 1) self.BaseLabel.show() self.BaseEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.BaseEntry, 1, 0, 1, 1) self.BaseEntry.show() self.SecretLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Secret:") self.FrameTable.pack(self.SecretLabel, 2, 0, 1, 1) self.SecretLabel.show() self.SecretEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.SecretEntry, 3, 0, 1, 1) self.SecretEntry.show() self.SignalLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Signal:") self.FrameTable.pack(self.SignalLabel, 4, 0, 1, 1) self.SignalLabel.show() self.SignalEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.SignalEntry, 5, 0, 1, 1) self.SignalEntry.show() self.ChannelLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Channel:") self.FrameTable.pack(self.ChannelLabel, 0, 1, 1, 1) self.ChannelLabel.show() self.ChannelEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ChannelEntry, 1, 1, 1, 1) self.ChannelEntry.show() self.PoleLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Pole:") self.FrameTable.pack(self.PoleLabel, 2, 1, 1, 1) self.PoleLabel.show() self.PoleEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.PoleEntry, 3, 1, 1, 1) self.PoleEntry.show() self.IdentityLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Identity:") self.FrameTable.pack(self.IdentityLabel, 4, 1, 1, 1) self.IdentityLabel.show() self.IdentityEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.IdentityEntry, 5, 1, 1, 1) self.IdentityEntry.show() self.FoundationLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Foundation:") self.FrameTable.pack(self.FoundationLabel, 0, 2, 1, 1) self.FoundationLabel.show() self.FoundationEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.FoundationEntry, 1, 2, 1, 1) self.FoundationEntry.show() self.ElementLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Element:") self.FrameTable.pack(self.ElementLabel, 2, 2, 1, 1) self.ElementLabel.show() self.ElementEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ElementEntry, 3, 2, 1, 1) self.ElementEntry.show() self.DynamoLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Dynamo:") self.FrameTable.pack(self.DynamoLabel, 4, 2, 1, 1) self.DynamoLabel.show() self.DynamoEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.DynamoEntry, 5, 2, 1, 1) self.DynamoEntry.show() self.ManifoldLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Manifold:") self.FrameTable.pack(self.ManifoldLabel, 0, 3, 1, 1) self.ManifoldLabel.show() self.ManifoldEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.ManifoldEntry, 1, 3, 1, 1) self.ManifoldEntry.show() self.RingLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Ring:") self.FrameTable.pack(self.RingLabel, 2, 3, 1, 1) self.RingLabel.show() self.RingEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.RingEntry, 3, 3, 1, 1) self.RingEntry.show() self.BarnLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Barn:") self.FrameTable.pack(self.BarnLabel, 4, 3, 1, 1) self.BarnLabel.show() self.BarnEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.BarnEntry, 5, 3, 1, 1) self.BarnEntry.show() self.VoltpereLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Voltpere:") self.FrameTable.pack(self.VoltpereLabel, 0, 4, 1, 1) self.VoltpereLabel.show() self.VoltpereEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.VoltpereEntry, 1, 4, 5, 1) self.VoltpereEntry.show() self.AmpereLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Ampere:") self.FrameTable.pack(self.AmpereLabel, 0, 5, 1, 1) self.AmpereLabel.show() self.AmpereEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.AmpereEntry, 1, 5, 2, 1) self.AmpereEntry.show() self.HenryLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Henry:") self.FrameTable.pack(self.HenryLabel, 0, 6, 1, 1) self.HenryLabel.show() self.HenryEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.HenryEntry, 1, 6, 2, 1) self.HenryEntry.show() self.MaxwellLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Maxwell:") self.FrameTable.pack(self.MaxwellLabel, 0, 7, 1, 1) self.MaxwellLabel.show() self.MaxwellEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.MaxwellEntry, 1, 7, 2, 1) self.MaxwellEntry.show() self.FermatLabel = Label(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Fermat:") self.FrameTable.pack(self.FermatLabel, 0, 8, 1, 1) self.FermatLabel.show() self.FermatEntry = Entry(self.FrameTable, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.5), single_line=True, scrollable=True, text="") self.FrameTable.pack(self.FermatEntry, 1, 8, 2, 1) self.FermatEntry.show() self.PropelButton = Button(self.FrameTable, size_hint_weight=(0.0, 0.0), size_hint_align=(0.0, 0.5), text="Propel") self.FrameTable.pack(self.PropelButton, 4, 8, 1, 1) self.PropelButton.show() self.PropelButton.callback_clicked_add(self.propelClicked) def propelClicked(self, obj): print("clicked")
class TabbedBox(Box): def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.tabs = [] self.currentTab = None self.tabChangedCallback = None self.closeCallback = None self.emptyCallback = None self.scr = Scroller(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) self.scr.content_min_limit(False, True) self.buttonBox = Box(self.scr, size_hint_weight=EXPAND_HORIZ, align=ALIGN_LEFT) self.buttonBox.horizontal = True self.buttonBox.show() self.scr.content = self.buttonBox self.scr.show() self.nf = Naviframe(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.nf.show() self.pack_end(self.scr) self.pack_end(self.nf) def addTab(self, widget, tabName, canClose=True, disabled=False): self.tabs.append(widget) btn = Button(self.buttonBox, style="anchor", size_hint_align=ALIGN_LEFT) btn.text = tabName btn.data["widget"] = widget btn.disabled = disabled btn.callback_clicked_add(self.showTab, widget) btn.show() icn = Icon(self.buttonBox) icn.standard_set("gtk-close") icn.show() cls = Button(self.buttonBox, content=icn, style="anchor", size_hint_align=ALIGN_LEFT) cls.data["widget"] = widget cls.callback_clicked_add(self.closeTab) cls.disabled = disabled if canClose: cls.show() sep = Separator(self.buttonBox, size_hint_align=ALIGN_LEFT) sep.show() self.buttonBox.pack_end(btn) self.buttonBox.pack_end(cls) self.buttonBox.pack_end(sep) #Arguments go: btn, cls, sep widget.data["close"] = cls widget.data["button"] = btn widget.data["sep"] = sep self.showTab(widget=widget) def disableTab(self, tabIndex): btn, cls = self.tabs[tabIndex].data["button"], self.tabs[tabIndex].data["close"] btn.disabled = True cls.disabled = True def enableTab(self, tabIndex): btn, cls = self.tabs[tabIndex].data["button"], self.tabs[tabIndex].data["close"] btn.disabled = False cls.disabled = False def showTab(self, btn=None, widget=None): if type(btn) is int: widget = self.tabs[btn] if widget != self.currentTab: if self.currentTab: self.currentTab.data["button"].style="anchor" self.nf.item_simple_push(widget) self.currentTab = widget self.currentTab.data["button"].style="widget" if self.tabChangedCallback: self.tabChangedCallback(self, widget) def closeTab(self, btn): if not self.closeCallback: self.deleteTab(btn.data["widget"]) else: self.closeCallback(self, btn.data["widget"]) def deleteTab(self, widget): if type(widget) is int: widget = self.tabs[tabIndex] del self.tabs[self.tabs.index(widget)] self.buttonBox.unpack(widget.data["close"]) self.buttonBox.unpack(widget.data["button"]) self.buttonBox.unpack(widget.data["sep"]) widget.data["close"].delete() widget.data["button"].delete() widget.data["sep"].delete() widget.delete() if self.currentTab == widget and len(self.tabs): self.showTab(widget=self.tabs[0]) if not len(self.tabs) and self.emptyCallback: self.emptyCallback(self)