def sort_by_column(self, col, ascending=True): ''' utility to sort list on columns ''' 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: # ascending: _ic.text = "⬇" self.sort_column_ascending = True else: _ic.text = "⬆" self.sort_column_ascending = False # reverse=False if ascending else True self.rows.sort(key=lambda e: e[col]) if not ascending: self.rows.reverse() # Clear old data for our_list in self.lists: our_list.clear() for row in self.rows: self.add_row(row) self.sort_column = col
def addPackage(self, pak): row = [] ourCheck = Check(self) ourCheck.data['packageName'] = pak.name ourCheck.callback_changed_add(self.app.checkChange) ourCheck.show() row.append(ourCheck) ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ourName.text = pak.name ourName.data["packageDes"] = pak.candidate.description ourName.callback_pressed_add(self.packagePressed) ourName.show() row.append(ourName) ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) ourVersion.text = pak.installed.version ourVersion.show() row.append(ourVersion) newVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) newVersion.text = pak.candidate.version newVersion.show() row.append(newVersion) self.app.packagesToUpdate[pak.name] = {'check':ourCheck, 'selected':False} self.packageList.row_pack(row, sort=False)
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 self.rows.sort(key=lambda e: e[col], #reverse=False if ascending else True ) if not ascending: self.rows.reverse() #Clear old data for our_list in self.lists: our_list.clear() for row in self.rows: self.add_row(row) self.sort_column = col
def buildLoadBox(self): # build the load label loadLable = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) loadLable.text = "<b>Processing</b>" loadLable.show() # build the spinning wheel wheel = Progressbar(self, pulse_mode=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) wheel.pulse(True) wheel.show() detailsbtn = Button(self, style="anchor") detailsbtn.text_set("Details") detailsbtn.callback_pressed_add(self.innerWinShow) detailsbtn.show() # build the status label self.statusLabel = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.statusLabel.show() # put all the built objects in a vertical box box = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box.pack_end(loadLable) box.pack_end(wheel) box.pack_end(self.statusLabel) box.pack_end(detailsbtn) box.show() return box
def __init__(self, parent, session): Frame.__init__(self, parent) self.text = "Limits" self.size_hint_align = FILL_HORIZ base = 1024 units = ( "bytes/s", "KiB/s", "MiB/s", "GiB/s", "TiB/s" ) t = Table(parent) for r, values in enumerate(( ("Upload limit", session.upload_rate_limit, session.set_upload_rate_limit), ("Download limit", session.download_rate_limit, session.set_download_rate_limit), ("Upload limit for local connections", session.local_upload_rate_limit, session.set_local_upload_rate_limit), ("Download limit for local connections", session.local_download_rate_limit, session.set_local_download_rate_limit), )): title, rfunc, wfunc = values l = Label(parent) l.text = title l.size_hint_align = FILL_HORIZ t.pack(l, 0, r, 1, 1) l.show() usw = UnitSpinner(parent, base, units) usw.size_hint_weight = EXPAND_HORIZ usw.size_hint_align = FILL_HORIZ usw.set_value(rfunc()) usw.callback_changed_add(wfunc, delay=2.0) t.pack(usw, 1, r, 1, 1) usw.show() self.content = t
def __init__(self): win = StandardWindow("Testing", "Elementary Tabbed Widget") # pylint: disable=no-member win.callback_delete_request_add(lambda o: elm.exit()) tabbs = TabbedBox(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tabbs.close_cb = self.close_checks for i in range(10): lbl = Label(win) lbl.text = "Tab %s" % i lbl.show() tabbs.add(lbl, "Tab %s" % i) tabbs.disable(0) tabbs.disable(3) tabbs.show() win.resize_object_add(tabbs) win.resize(600, 400) win.show()
def __init__(self, parent, label_text, values, initial_value): Box.__init__(self, parent) self.vd = { ELM_ACTIONSLIDER_LEFT: values[0], ELM_ACTIONSLIDER_CENTER: values[1], ELM_ACTIONSLIDER_RIGHT: values[2], } self.horizontal = True self.size_hint_align = -1.0, 0.0 self.size_hint_weight = 1.0, 0.0 l = Label(parent) l.text = label_text l.show() w = self.w = Actionslider(parent) w.magnet_pos = ELM_ACTIONSLIDER_ALL w.size_hint_align = -1.0, 0.0 w.size_hint_weight = 1.0, 0.0 w.show() parts = "left", "center", "right" for i, v in enumerate(values): w.part_text_set(parts[i], str(v)) w.indicator_pos = values.index(initial_value) + 1 self.pack_end(l) self.pack_end(w)
def __init__(self): StandardWindow.__init__(self, "ex2", "Hello Elementary", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hello Elementary!" ourLabel.show() ourButton = Button(self) ourButton.size_hint_weight = EXPAND_BOTH ourButton.text = "Goodbye Elementary" ourButton.callback_clicked_add(self.buttonPressed) ourButton.show() ourBox = Box(self) ourBox.size_hint_weight = EXPAND_BOTH ourBox.pack_end(ourLabel) ourBox.pack_end(ourButton) ourBox.show() self.resize_object_add(ourBox)
def __init__(self, canvas, text): n = Notify(canvas) l = Label(canvas) l.text = text n.content = l n.timeout = 3 n.show()
def __init__(self): win = StandardWindow("Testing", "Elementary Sorted Table") # pylint: disable=no-member win.callback_delete_request_add(lambda o: elm.exit()) # Build the titles for the table. The titles is a list of tuples # with the following format: # ( <str - Header Text>, <Bool - Sortable> )''' titles = [] for i in range(COLUMNS): titles.append(("Column " + str(i), True if i != 2 else False)) # Create our sorted list object slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) # Populate the rows in our table for _i in range(ROWS): # Each row is a list with the number of elements # that must equal the number of headers row = [] for j in range(COLUMNS): # Row elements can be ANY elementary object if j == 0: # For the first column in each row, we will create a button # that will delete the row when pressed btn = Button(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) btn.text = "Delete row" btn.callback_clicked_add( lambda x, y=row: slist.row_unpack(y, delete=True)) btn.show() # Add the btn created to our row row.append(btn) else: # For each other row create a label with a random number data = random.randint(0, ROWS * COLUMNS) label = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) label.text = str(data) # For integer data we also need to assign value to "sort_data" # because otherwise things get sorted as text label.data["sort_data"] = data label.show() # Append our label to the row row.append(label) # Add the row into the SortedList slist.row_pack(row, sort=False) # Show the list slist.show() win.resize_object_add(slist) win.resize(600, 400) win.show()
def fileExists(self, filePath): self.confirmPopup = Popup(self.mainWindow, size_hint_weight=EXPAND_BOTH) # Add a table to hold dialog image and text to Popup tb = Table(self.confirmPopup, size_hint_weight=EXPAND_BOTH) self.confirmPopup.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self.confirmPopup, thumb='True') icon.standard_set('dialog-question') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self.confirmPopup, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self.confirmPopup, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) current_file = os.path.basename(filePath) dialogLabel.text = "'%s' already exists. Overwrite?<br><br>" \ % (current_file) tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Close without saving button no_btt = Button(self.mainWindow) no_btt.text = "No" no_btt.callback_clicked_add(self.closePopup, self.confirmPopup) no_btt.show() # Save the file and then close button sav_btt = Button(self.mainWindow) sav_btt.text = "Yes" sav_btt.callback_clicked_add(self.doSelected) sav_btt.callback_clicked_add(self.closePopup, self.confirmPopup) sav_btt.show() # add buttons to popup self.confirmPopup.part_content_set("button1", no_btt) self.confirmPopup.part_content_set("button3", sav_btt) self.confirmPopup.show()
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 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 __init__(self): StandardWindow.__init__(self, "ex1", "Hello Elementary", size=(300, 200)) self.callback_delete_request_add(lambda o: elm.exit()) ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hello Elementary!" ourLabel.show() self.resize_object_add(ourLabel)
def __init__(self): StandardWindow.__init__(self, "ex1", "Hello Elementary", size=(640, 480)) self.callback_delete_request_add(lambda o: elm.exit()) ourLabel = Label(self) ourLabel.size_hint_weight = EXPAND_BOTH ourLabel.text = "Hello Elementary!" ourLabel.show() self.resize_object_add(ourLabel)
def __init__( self ): win = StandardWindow("Testing", "Elementary Sorted Table") win.callback_delete_request_add(lambda o: elm.exit()) """Build the titles for the table. The titles is a list of tuples with the following format: ( <String - Header Text>, <Bool - Sortable> )""" titles = [] for i in range(COLUMNS): titles.append( ("Column " + str(i), True if i != 2 else False) ) #Create our sorted list object slist = SortedList(win, titles=titles, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) #Populate the rows in our table for i in range(ROWS): #Each row is a list with the number of elements that must equal the number of headers row = [] for j in range(COLUMNS): #Row elements can be ANY elementary object if j == 0: #For the first column in each row, we will create a button that will delete the row when pressed btn = Button(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) btn.text = "Delete row" btn.callback_clicked_add( lambda x, y=row: slist.row_unpack(y, delete=True) ) btn.show() #Add the btn created to our row row.append(btn) else: #For each other row create a label with a random number data = random.randint(0, ROWS*COLUMNS) lb = Label(slist, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) lb.text=str(data) """For integer data we also need to assign value to "sort_data" because otherwise things get sorted as text""" lb.data["sort_data"] = data lb.show() #Append our label to the row row.append(lb) #Add the row into the SortedList slist.row_pack(row, sort=False) #Show the list slist.show() win.resize_object_add(slist) win.resize(600, 400) win.show()
def addPackage(self, pak): row = [] ourCheck = Check(self) ourCheck.data['packageName'] = pak.name ourCheck.callback_changed_add(self.app.checkChange) ourCheck.show() row.append(ourCheck) ourName = Button(self, style="anchor", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) ourName.text = pak.name ourName.data["packageDes"] = pak.candidate.description ourName.callback_pressed_add(self.packagePressed) ourName.show() row.append(ourName) ourVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) ourVersion.text = pak.installed.version ourVersion.show() row.append(ourVersion) newVersion = Label(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(0.1, 0.5)) newVersion.text = pak.candidate.version newVersion.show() row.append(newVersion) self.app.packagesToUpdate[pak.name] = { 'check': ourCheck, 'selected': False } self.packageList.row_pack(row, sort=False)
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 sort_by_column(self, col, ascending=True): assert col >= 0 assert col < len(self.header_row) if self.sort_column: 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 self.rows.sort( key=lambda e: e[col], # reverse=False if ascending else True ) if not ascending: self.rows.reverse() # Clear old data for our_list in self.lists: our_list.clear() for row in self.rows: self.add_row(row) self.sort_column = col
def errorPopup(window, errorMsg): errorPopup = Popup(window, size_hint_weight=EXPAND_BOTH) errorPopup.callback_block_clicked_add(lambda obj: errorPopup.delete()) # Add a table to hold dialog image and text to Popup tb = Table(errorPopup, size_hint_weight=EXPAND_BOTH) errorPopup.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(errorPopup, thumb='True') icon.standard_set('dialog-warning') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(errorPopup, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(errorPopup, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) dialogLabel.text = errorMsg tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Ok Button ok_btt = Button(errorPopup) ok_btt.text = "Ok" ok_btt.callback_clicked_add(lambda obj: errorPopup.delete()) ok_btt.show() # add button to popup errorPopup.part_content_set("button3", ok_btt) errorPopup.show()
def __init__(self, ourParent, ourMsg, ourIcon=None, *args, **kwargs): Popup.__init__(self, ourParent, *args, **kwargs) self.callback_block_clicked_add(lambda obj: self.delete()) # Add a table to hold dialog image and text to Popup tb = Table(self, size_hint_weight=EXPAND_BOTH) self.part_content_set("default", tb) tb.show() # Add dialog-error Image to table need_ethumb() icon = Icon(self, thumb='True') icon.standard_set(ourIcon) # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: dialogImage = Image(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, file=icon.file_get()) tb.pack(dialogImage, 0, 0, 1, 1) dialogImage.show() except RuntimeError: # An error message is displayed for this same error # when aboutWin is initialized so no need to redisplay. pass # Add dialog text to table dialogLabel = Label(self, line_wrap=ELM_WRAP_WORD, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) dialogLabel.text = ourMsg tb.pack(dialogLabel, 1, 0, 1, 1) dialogLabel.show() # Ok Button ok_btt = Button(self) ok_btt.text = "Ok" ok_btt.callback_clicked_add(lambda obj: self.delete()) ok_btt.show() # add button to popup self.part_content_set("button3", ok_btt)
def __init__( self ): win = StandardWindow("Testing", "Elementary About Dialog") win.callback_delete_request_add(lambda o: elm.exit()) win.show() lbl = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) lbl.text = "This is a parent window for the About Dialog. Close when done." lbl.show() win.resize_object_add(lbl) win.resize(600, 400) win.show() AboutWindow(win, title="About Test", standardicon="dialog-information", \ version="1.0", authors=AUTHORS, \ licen=LICENSE, webaddress="https://github.com/JeffHoogland/python-elm-extensions", \ info=INFO)
def __init__( self ): win = StandardWindow("Testing", "Elementary Tabbed Widget") win.callback_delete_request_add(lambda o: elm.exit()) tabbs = TabbedBox(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) tabbs.closeCallback = self.closeChecks for i in range(10): lbl = Label(win) lbl.text = "Tab %s"%i lbl.show() tabbs.addTab(lbl, "Tab %s"%i) tabbs.disableTab(0) tabbs.disableTab(3) tabbs.show() win.resize_object_add(tabbs) win.resize(600, 400) win.show()
def __init__(self, parent, session): Frame.__init__(self, parent) self.text = "Limits" self.size_hint_align = FILL_HORIZ base = 1024 units = ("bytes/s", "KiB/s", "MiB/s", "GiB/s", "TiB/s") t = Table(parent) for r, values in enumerate(( ("Upload limit", session.upload_rate_limit, session.set_upload_rate_limit), ("Download limit", session.download_rate_limit, session.set_download_rate_limit), ("Upload limit for local connections", session.local_upload_rate_limit, session.set_local_upload_rate_limit), ("Download limit for local connections", session.local_download_rate_limit, session.set_local_download_rate_limit), )): title, rfunc, wfunc = values l = Label(parent) l.text = title l.size_hint_align = FILL_HORIZ t.pack(l, 0, r, 1, 1) l.show() usw = UnitSpinner(parent, base, units) usw.size_hint_weight = EXPAND_HORIZ usw.size_hint_align = FILL_HORIZ usw.set_value(rfunc()) usw.callback_changed_add(wfunc, delay=2.0) t.pack(usw, 1, r, 1, 1) usw.show() self.content = t
if __name__ == "__main__": elementary.init() win = StandardWindow("test", "python-elementary test application", size=(320, 520)) win.callback_delete_request_add(lambda x: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = "Please select a test from the list below<br>" \ "by clicking the test button to show the<br>" \ "test window." lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() items = [("Bg Plain", bg_plain_clicked), ("Bg Image", bg_image_clicked)] li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box0.pack_end(li) li.show() for item in items: li.item_append(item[0], callback=item[1])
def __init__(self, command=None, win=None, start_callback=None, end_callback=None, *args, **kwargs): if not win: nowindow = True win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC) win.title = "eSudo" win.borderless = True win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL win.resize(300, 200) win.callback_delete_request_add(lambda o: elementary.exit()) win.layer_set(11) #~ win.fullscreen = True win.show() win.activate() bg = Background(win) bg.size_hint_weight = 1.0, 1.0 win.resize_object_add(bg) bg.show() self.embedded = False else: nowindow = False self.embedded = True self.cmd = command self.start_cb = start_callback if callable(start_callback) else None self.end_cb = end_callback if callable(end_callback) else None self.args = args self.kwargs = kwargs #--------eSudo Window bz = Box(win) if nowindow: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 else: bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.show() if nowindow: lbl = Label(win) lbl.style = "marker" lbl.color = 170, 170, 170, 255 lbl.size_hint_align = 0.5, 0.0 lbl.scale = 2.0 lbl.text = "<b>eSudo</b>" bz.pack_end(lbl) lbl.show() sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() fr = Frame(win) fr.text = "Command:" fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0 bz.pack_end(fr) fr.show() if nowindow: sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() self.cmdline = cmdline = Entry(win) cmdline.elm_event_callback_add(self.entry_event) cmdline.single_line = True if self.cmd: cmdline.text = self.cmd cmdline.editable = False fr.content = cmdline cmdline.scrollable_set(True) cmdline.show() if nowindow: fr = Frame(win) fr.text = "Password:"******"<b>Password:</b>" lb.size_hint_align = 0.0, 0.5 bz1.pack_end(lb) lb.show() en = self.en = Entry(win) en.name = "password" en.elm_event_callback_add(self.entry_event) en.single_line = True en.password = True en.show() if nowindow: fr.content = en else: bz1.pack_end(en) sep = Separator(win) sep.horizontal = True bz.pack_end(sep) sep.show() btnb = Box(win) btnb.horizontal = True btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bz.pack_end(btnb) btnb.show() bt = Button(win) bt.text = "Cancel" bt.callback_clicked_add(self.esudo_cancel, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() bt = Button(win) bt.text = "OK" bt.callback_clicked_add(self.password_check, en) bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0 btnb.pack_end(bt) bt.show() self.iw = iw = InnerWindow(win) iw.content = bz iw.show() iw.activate() if self.cmd: en.focus = True
def __init__(self, parent, session): Table.__init__(self, parent) self.session = session s = session.status() self.padding = 5, 5 ses_pause_ic = self.ses_pause_ic = Icon(parent) ses_pause_ic.size_hint_align = -1.0, -1.0 try: if session.is_paused(): ses_pause_ic.standard = "player_pause" else: ses_pause_ic.standard = "player_play" except RuntimeError: self.log.debug("Setting session ic failed") self.pack(ses_pause_ic, 1, 0, 1, 1) ses_pause_ic.show() title_l = Label(parent) title_l.text = "<b>Session</b>" self.pack(title_l, 0, 0, 1, 1) title_l.show() d_ic = Icon(parent) try: d_ic.standard = "down" except RuntimeError: self.log.debug("Setting d_ic failed") d_ic.size_hint_align = -1.0, -1.0 self.pack(d_ic, 0, 2, 1, 1) d_ic.show() d_l = self.d_l = Label(parent) d_l.text = "{}/s".format(intrepr(s.payload_download_rate)) self.pack(d_l, 1, 2, 1, 1) d_l.show() u_ic = Icon(self) try: u_ic.standard = "up" except RuntimeError: self.log.debug("Setting u_ic failed") u_ic.size_hint_align = -1.0, -1.0 self.pack(u_ic, 0, 3, 1, 1) u_ic.show() u_l = self.u_l = Label(parent) u_l.text = "{}/s".format(intrepr(s.payload_upload_rate)) self.pack(u_l, 1, 3, 1, 1) u_l.show() peer_t = Label(parent) peer_t.text = "Peers" self.pack(peer_t, 0, 4, 1, 1) peer_t.show() peer_l = self.peer_l = Label(parent) peer_l.text = str(s.num_peers) self.pack(peer_l, 1, 4, 1, 1) peer_l.show() self.show() self.update_timer = Timer(1.0, self.update)
def notify_clicked(obj=None): win = StandardWindow("notify", "Notify", autodel=True, size=(400,400)) if obj is None: win.callback_delete_request_add(lambda x: elementary.exit()) win.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() # Notify top bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.0), content=bx) lb = Label(win, text="This position is the default.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 1, 1, 1) bt.show() # Notify bottom bx = Box(win, horizontal=True) bx.show() notify = Notify(win, allow_events=False, size_hint_weight=EXPAND_BOTH, align=(0.5, 1.0), timeout=(5.0), content=bx) notify.callback_timeout_add(lambda x: setattr(x, "timeout", 2.0)) notify.callback_block_clicked_add( lambda x: print("Notify block area clicked!!")) lb = Label(win) lb.text = ( "Bottom position. This notify uses a timeout of 5 sec.<br/>" "<b>The events outside the window are blocked.</b>" ) bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 3, 1, 1) bt.show() # Notify left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.5), timeout=10.0, content=bx) notify.callback_timeout_add(lambda x: print("Notify timed out!")) lb = Label(win) lb.text = "Left position. This notify uses a timeout of 10 sec." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 2, 1, 1) bt.show() # Notify center bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.5), timeout=10.0, content=bx) notify.callback_timeout_add(lambda x: print("Notify timed out!")) lb = Label(win) lb.text = "Center position. This notify uses a timeout of 10 sec." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Center") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 2, 1, 1) bt.show() # Notify right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.5), content=bx) lb = Label(win, text="Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 2, 1, 1) bt.show() # Notify top left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.0), content=bx) lb = Label(win, text="Top Left position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 1, 1, 1) bt.show() # Notify top right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.0), content=bx) lb = Label(win, text="Top Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 1, 1, 1) bt.show() # Notify bottom left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 1.0), content=bx) lb = Label(win, text="Bottom Left position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 3, 1, 1) bt.show() # Notify bottom right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 1.0), content=bx) lb = Label(win, text="Bottom Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close in 2s") bt.callback_clicked_add(lambda x, y=notify: setattr(y, "timeout", 2.0)) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 3, 1, 1) bt.show() # Notify top fill bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(ELM_NOTIFY_ALIGN_FILL, 0.0), timeout=5.0, content=bx) lb = Label(win) lb.text = ( "Fill top. This notify fills horizontal area.<br/>" "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 0.0)</b>" ) bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Top fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 0, 3, 1) bt.show() # Notify bottom fill bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(ELM_NOTIFY_ALIGN_FILL, 1.0), timeout=5.0, content=bx) lb = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.0, 0.5)) lb.text = ( "Fill Bottom. This notify fills horizontal area.<br/>" "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 1.0)</b>" ) bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Bottom fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 4, 3, 1) bt.show() # Notify left fill bx = Box(win) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx) lb = Label(win, text="Left fill.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Left fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 0, 1, 1, 3) bt.show() # Notify right fill bx = Box(win) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx) lb = Label(win) lb.text = "Right fill." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Right fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 4, 1, 1, 3) bt.show()
def __init__(self, parent, canvas): self._parent = parent self._canvas = canvas # Dialog Window Basics self.aboutDialog = Window("epad", ELM_WIN_DIALOG_BASIC) # self.aboutDialog.callback_delete_request_add(self.closeabout) # Set Dialog background background = Background(self.aboutDialog, size_hint_weight=EXPAND_BOTH) self.aboutDialog.resize_object_add(background) background.show() # mainBox = Box(self.aboutDialog, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.aboutDialog.resize_object_add(mainBox) mainBox.show() # need_ethumb() icon = Icon(self.aboutDialog, thumb='True') icon.standard_set('accessories-text-editor') # Using gksudo or sudo fails to load Image here # unless options specify using preserving their existing environment. # may also fail to load other icons but does not raise an exception # in that situation. # Works fine using eSudo as a gksudo alternative, # other alternatives not tested try: aboutImage = Image(self.aboutDialog, no_scale=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, file=icon.file_get()) aboutImage.aspect_fixed_set(False) mainBox.pack_end(aboutImage) aboutImage.show() except RuntimeError as msg: print("Warning: to run as root please use:\n" "\t gksudo -k or sudo -E \n" "Continuing with minor errors ...") labelBox = Box(self.aboutDialog, size_hint_weight=EXPAND_NONE) mainBox.pack_end(labelBox) labelBox.show() # Entry to hold text titleStr = '<br>ePad version <em>{0}</em><br>'.format(__version__) aboutStr = ('<br>A simple text editor written in <br>' 'python and elementary<br>') aboutLbTitle = Label(self.aboutDialog, style='marker') aboutLbTitle.text = titleStr aboutLbTitle.show() labelBox.pack_end(aboutLbTitle) sep = Separator(self.aboutDialog, horizontal=True) labelBox.pack_end(sep) sep.show() aboutText = Label(self.aboutDialog) aboutText.text = aboutStr aboutText.show() labelBox.pack_end(aboutText) aboutCopyright = Label(self.aboutDialog) aboutCopyright.text = '<b>Copyright</b> © <i>2014 Bodhi Linux</i><br>' aboutCopyright.show() labelBox.pack_end(aboutCopyright) # Dialog Buttons # Horizontal Box for Dialog Buttons buttonBox = Box(self.aboutDialog, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, padding=PADDING) buttonBox.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0) buttonBox.show() labelBox.pack_end(buttonBox) # Credits Button creditsBtn = Button(self.aboutDialog, text="Credits ", size_hint_weight=EXPAND_NONE) creditsBtn.callback_clicked_add(self.creditsPress) creditsBtn.show() buttonBox.pack_end(creditsBtn) # Close Button okBtn = Button(self.aboutDialog, text=" Close ", size_hint_weight=EXPAND_NONE) okBtn.callback_clicked_add(self.closeabout) okBtn.show() buttonBox.pack_end(okBtn) # Ensure the min height self.aboutDialog.resize(300, 100)
def __init__(self, parent_widget, defaultPath="", defaultPopulate=True, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.cancelCallback = None self.actionCallback = None self.directoryChangeCallback = None self.threadedFunction = ThreadedFunction() self._timer = ecore.Timer(0.02, self.populateFile) #Watch key presses for ctrl+l to select entry parent_widget.elm_event_callback_add(self.eventsCb) self.selectedFolder = None self.showHidden = False self.currentDirectory = None self.focusedEntry = None self.folderOnly = False self.sortReverse = False self.addingHidden = False self.pendingFiles = deque() self.currentSubFolders = [] self.currentFiles = [] #Mode should be "save" or "load" self.mode = "save" self.home = os.path.expanduser("~") self.root = "/" #Label+Entry for File Name self.filenameBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filenameBox.horizontal = True self.filenameBox.show() fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) fileLabel.text = "Filename:" fileLabel.show() self.fileEntry = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.fileEntry.single_line_set(True) self.fileEntry.scrollable_set(True) self.fileEntry.callback_changed_user_add(self.fileEntryChanged) self.fileEntry.show() self.filenameBox.pack_end(fileLabel) self.filenameBox.pack_end(self.fileEntry) sep = Separator(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sep.horizontal_set(True) sep.show() #Label+Entry for File Path self.filepathBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filepathBox.horizontal = True self.filepathBox.show() fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) fileLabel.text = "Current Folder:" fileLabel.show() self.filepathEntry = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.filepathEntry.single_line_set(True) self.filepathEntry.scrollable_set(True) self.filepathEntry.callback_changed_user_add(self.fileEntryChanged) self.filepathEntry.callback_unfocused_add(self.filepathEditDone) self.filepathEntry.callback_activated_add(self.filepathEditDone) #Wish this worked. Doesn't seem to do anything #self.filepathEntry.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE) if defaultPath and os.path.isdir(defaultPath): startPath = defaultPath else: startPath = self.home self.filepathEntry.show() self.filepathBox.pack_end(fileLabel) self.filepathBox.pack_end(self.filepathEntry) self.autocompleteHover = Hoversel(self, hover_parent=self) self.autocompleteHover.callback_selected_add(self.autocompleteSelected) #self.autocompleteHover.show() self.fileSelectorBox = Panes(self, content_left_size=0.3, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileSelectorBox.show() """Bookmarks Box contains: - Button - Up Arrow - List - Home/Root/GTK bookmarks - Box -- Button - Add Bookmark -- Button - Remove Bookmark""" self.bookmarkBox = Box(self, size_hint_weight=(0.3, EVAS_HINT_EXPAND), size_hint_align=FILL_BOTH) self.bookmarkBox.show() upIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) upIcon.standard_set("go-up") upIcon.show() self.upButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=upIcon) self.upButton.text = "Up" self.upButton.callback_pressed_add(self.upButtonPressed) self.upButton.show() self.bookmarksList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.bookmarksList.callback_activated_add(self.bookmarkDoubleClicked) self.bookmarksList.show() self.bookmarkModBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.bookmarkModBox.horizontal = True self.bookmarkModBox.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("add") con.show() self.addButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.addButton.callback_pressed_add(self.addButtonPressed) self.addButton.disabled = True self.addButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("remove") con.show() self.removeButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.removeButton.callback_pressed_add(self.removeButtonPressed) self.removeButton.disabled = True self.removeButton.show() self.bookmarkModBox.pack_end(self.addButton) self.bookmarkModBox.pack_end(self.removeButton) self.bookmarkBox.pack_end(self.upButton) self.bookmarkBox.pack_end(self.bookmarksList) self.bookmarkBox.pack_end(self.bookmarkModBox) #Directory List self.fileListBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileListBox.show() self.fileSortButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.fileSortButton.text = u"⬆ Name" self.fileSortButton.callback_pressed_add(self.sortData) self.fileSortButton.show() self.fileList = Genlist(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, homogeneous=True, mode=ELM_LIST_COMPRESS) self.fileList.callback_activated_add(self.fileDoubleClicked) self.fileList.show() self.previewImage = previewImage = Image(self) #previewImage.size_hint_weight = EXPAND_BOTH previewImage.size_hint_align = FILL_BOTH previewImage.show() self.fileListBox.pack_end(self.fileSortButton) self.fileListBox.pack_end(self.fileList) self.fileListBox.pack_end(self.previewImage) self.fileSelectorBox.part_content_set("left", self.bookmarkBox) self.fileSelectorBox.part_content_set("right", self.fileListBox) #Cancel and Save/Open button self.buttonBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1.0, 0.5)) self.buttonBox.horizontal = True self.buttonBox.show() self.actionIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.actionIcon.standard_set("document-save") self.actionIcon.show() self.actionButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=self.actionIcon) self.actionButton.text = "Save " self.actionButton.callback_pressed_add(self.actionButtonPressed) self.actionButton.show() cancelIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) cancelIcon.standard_set("exit") cancelIcon.show() self.cancelButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=cancelIcon) self.cancelButton.text = "Cancel " self.cancelButton.callback_pressed_add(self.cancelButtonPressed) self.cancelButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("gtk-find") con.show() self.toggleHiddenButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.toggleHiddenButton.text = "Toggle Hidden " self.toggleHiddenButton.callback_pressed_add(self.toggleHiddenButtonPressed) self.toggleHiddenButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("folder-new") con.show() self.createFolderButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.createFolderButton.text = "Create Folder " self.createFolderButton.callback_pressed_add(self.createFolderButtonPressed) self.createFolderButton.show() self.buttonBox.pack_end(self.createFolderButton) self.buttonBox.pack_end(self.toggleHiddenButton) self.buttonBox.pack_end(self.cancelButton) self.buttonBox.pack_end(self.actionButton) self.pack_end(self.filenameBox) self.pack_end(sep) self.pack_end(self.filepathBox) self.pack_end(self.autocompleteHover) self.pack_end(self.fileSelectorBox) self.pack_end(self.buttonBox) self.populateBookmarks() self.createPopup = Popup(self) self.createPopup.part_text_set("title,text", "Create Folder:") self.createEn = en = Entry(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.single_line_set(True) en.scrollable_set(True) en.show() self.createPopup.content = en bt = Button(self, text="Create") bt.callback_clicked_add(self.createFolder) self.createPopup.part_content_set("button1", bt) bt2 = Button(self, text="Cancel") bt2.callback_clicked_add(self.closePopup) self.createPopup.part_content_set("button2", bt2) if defaultPopulate: self.populateFiles(startPath)
def __init__(self, parent_widget, *args, default_path='', default_populate=True, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.cancel_cb = None self.action_cb = None self.cb_dir_change = None self.threaded_fn = ThreadedFunction() # pylint: disable=c-extension-no-member self._timer = ecore.Timer(0.02, self.populate_file) # Watch key presses for ctrl+l to select entry parent_widget.elm_event_callback_add(self.cb_events) self.selected_dir = None self.show_hidden = False self.cur_dir = None self.focused_entry = None self.dir_only = False self.sort_reverse = False self.adding_hidden = False self.pending_files = deque() self.cur_subdirs = [] self.cur_files = [] # Mode should be 'save' or 'load' self.mode = 'save' self.home = os.path.expanduser('~') desktop = os.environ.get('XDG_DESKTOP_DIR') if desktop: self.desktop = desktop else: self.desktop = self.home + '/Desktop' self.root = '/' # Label+Entry for File Name self.filename_bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filename_bx.horizontal = True self.filename_bx.show() file_label = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) file_label.text = 'Filename:' file_label.show() self.file_entry = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.file_entry.single_line_set(True) self.file_entry.scrollable_set(True) self.file_entry.callback_changed_user_add(self.cb_file_entry) self.file_entry.show() self.filename_bx.pack_end(file_label) self.filename_bx.pack_end(self.file_entry) sep = Separator(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sep.horizontal_set(True) sep.show() # Label+Entry for File Path self.filepath_bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filepath_bx.horizontal = True self.filepath_bx.show() file_label = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) file_label.text = 'Current Folder:' file_label.show() self.filepath_en = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.filepath_en.single_line_set(True) self.filepath_en.scrollable_set(True) self.filepath_en.callback_changed_user_add(self.cb_file_entry) self.filepath_en.callback_unfocused_add(self.cb_filepath_en) self.filepath_en.callback_activated_add(self.cb_filepath_en) # Wish this worked. Doesn't seem to do anything # Working now EFL 1.22 ? self.filepath_en.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE) if default_path and os.path.isdir(default_path): start = default_path else: start = self.home self.filepath_en.show() self.filepath_bx.pack_end(file_label) self.filepath_bx.pack_end(self.filepath_en) self.autocomplete_hover = Hoversel(self, hover_parent=self) self.autocomplete_hover.callback_selected_add(self.cb_hover) self.autocomplete_hover.show() self.file_selector_bx = Panes(self, content_left_size=0.3, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.file_selector_bx.show() # Bookmarks Box contains: # # - Button - Up Arrow # - List - Home/Desktop/Root/GTK bookmarks # - Box # -- Button - Add Bookmark # -- Button - Remove Bookmark self.bookmark_bx = Box(self, size_hint_weight=(0.3, EVAS_HINT_EXPAND), size_hint_align=FILL_BOTH) self.bookmark_bx.show() up_ic = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, order_lookup=ELM_ICON_LOOKUP_THEME) up_ic.standard_set('arrow-up') up_ic.show() self.up_btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=up_ic) self.up_btn.text = 'Up' self.up_btn.callback_pressed_add(self.cb_up_btn) self.up_btn.show() self.bookmarks_lst = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.bookmarks_lst.callback_activated_add(self.cb_bookmarks_lst) self.bookmarks_lst.show() self.bookmark_modbox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.bookmark_modbox.horizontal = True self.bookmark_modbox.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set('list-add') con.show() self.add_btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.add_btn.callback_pressed_add(self.cb_add_btn) self.add_btn.disabled = True self.add_btn.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set('list-remove') con.show() self.rm_btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.rm_btn.callback_pressed_add(self.cb_remove) self.rm_btn.disabled = True self.rm_btn.show() self.bookmark_modbox.pack_end(self.add_btn) self.bookmark_modbox.pack_end(self.rm_btn) self.bookmark_bx.pack_end(self.up_btn) self.bookmark_bx.pack_end(self.bookmarks_lst) self.bookmark_bx.pack_end(self.bookmark_modbox) # Directory List self.file_list_bx = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.file_list_bx.show() self.file_sort_btn = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.file_sort_btn.text = u'⬆ Name' self.file_sort_btn.callback_pressed_add(self.cb_sort) self.file_sort_btn.show() self.file_lst = Genlist(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, homogeneous=True, mode=ELM_LIST_COMPRESS) self.file_lst.callback_activated_add(self.cb_file_lst) self.file_lst.show() self.preview = preview = Image(self) preview.size_hint_align = FILL_BOTH preview.show() self.file_list_bx.pack_end(self.file_sort_btn) self.file_list_bx.pack_end(self.file_lst) self.file_list_bx.pack_end(self.preview) self.file_selector_bx.part_content_set('left', self.bookmark_bx) self.file_selector_bx.part_content_set('right', self.file_list_bx) # Cancel and Save/Open button self.button_bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1.0, 0.5)) self.button_bx.horizontal = True self.button_bx.show() self.action_ic = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.action_ic.standard_set('document-save') self.action_ic.show() self.action_btn = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=self.action_ic) self.action_btn.text = 'Save ' self.action_btn.callback_pressed_add(self.cb_action_btn) self.action_btn.show() cancel_ic = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) cancel_ic.standard_set('application-exit') cancel_ic.show() self.cancel_btn = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=cancel_ic) self.cancel_btn.text = 'Cancel ' self.cancel_btn.callback_pressed_add(self.cb_cancel_btn) self.cancel_btn.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set('edit-find') con.show() self.hidden_btn = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.hidden_btn.text = 'Toggle Hidden ' self.hidden_btn.callback_pressed_add(self.cb_toggle_hidden) self.hidden_btn.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set('folder-new') con.show() self.create_dir_btn = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.create_dir_btn.text = 'Create Folder ' self.create_dir_btn.callback_pressed_add(self.cb_create_dir) self.create_dir_btn.show() self.button_bx.pack_end(self.create_dir_btn) self.button_bx.pack_end(self.hidden_btn) self.button_bx.pack_end(self.cancel_btn) self.button_bx.pack_end(self.action_btn) self.pack_end(self.filename_bx) self.pack_end(sep) self.pack_end(self.filepath_bx) self.pack_end(self.autocomplete_hover) self.pack_end(self.file_selector_bx) self.pack_end(self.button_bx) self.populate_bookmarks() self.create_popup = Popup(self) self.create_popup.part_text_set('title,text', 'Create Folder:') self.create_en = Entry(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.create_en.single_line_set(True) self.create_en.scrollable_set(True) self.create_en.show() self.create_popup.content = self.create_en bt0 = Button(self, text='Create') bt0.callback_clicked_add(self.cb_create_folder) self.create_popup.part_content_set('button1', bt0) bt1 = Button(self, text='Cancel') bt1.callback_clicked_add(self.cb_close_popup) self.create_popup.part_content_set('button2', bt1) self.recent = None # keeps pylint happy: if default_populate: self.populate_files(start)
def __init__(self, parent, session): PreferencesDialog.__init__(self, "Session") # TODO: Construct and populate this with an Idler self.session = session widgets = {} elm_conf = Configuration() s = session.settings() t = Table(self, padding=(5,5), homogeneous=True, size_hint_align=FILL_BOTH) self.box.pack_end(t) t.show() i = 0 INT_MIN = -2147483648 INT_MAX = 2147483647 scale = elm_conf.scale for k in dir(s): if k.startswith("__"): continue try: a = getattr(s, k) if isinstance(a, lt.disk_cache_algo_t): w = Spinner(t) w.size_hint_align = FILL_HORIZ # XXX: lt-rb python bindings don't have all values. w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys()) for name, val in lt.disk_cache_algo_t.names.items(): w.special_value_add(val, name) w.value = a elif isinstance(a, bool): w = Check(t) w.size_hint_align = 1.0, 0.0 w.style = "toggle" w.state = a elif isinstance(a, int): w = Spinner(t) w.size_hint_align = FILL_HORIZ w.min_max = INT_MIN, INT_MAX w.value = a elif isinstance(a, float): w = Slider(t) w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.unit_format = "%1.2f" if k.startswith("peer_turnover"): w.min_max = 0.0, 1.0 else: w.min_max = 0.0, 20.0 w.value = a elif k == "peer_tos": # XXX: This is an int pair in libtorrent, # which doesn't have a python equivalent. continue elif k == "user_agent": w = Entry(t) w.size_hint_align = 1.0, 0.0 w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.editable = False w.entry = cgi.escape(a) else: w = Entry(t) w.part_text_set("guide", "Enter here") w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.entry = cgi.escape(a) l = Label(t) l.text = k.replace("_", " ").capitalize() l.size_hint_align = 0.0, 0.0 l.size_hint_weight = EXPAND_HORIZ l.show() t.pack(l, 0, i, 1, 1) #w.size_hint_min = scale * 150, scale * 25 t.pack(w, 1, i, 1, 1) w.show() widgets[k] = w i += 1 except TypeError: pass #print("Error {}".format(k)) save_btn = Button(self) save_btn.text = "Apply session settings" save_btn.callback_clicked_add(self.apply_settings, widgets, session) save_btn.show() self.box.pack_end(save_btn)
if __name__ == "__main__": elementary.init() win = StandardWindow("test", "Python EFL test application") win.callback_delete_request_add(destroy, "test1", "test2", str3="test3", str4="test4") box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = ("Please select a test from the list below by clicking<br>" "the test button to show the test window.") lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() tg = Check(win, style="toggle", text="UI-Mirroring:") tg.callback_changed_add(cb_mirroring) box0.pack_end(tg) tg.show() bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True)
def cb_filter(en, win): menu_create(en.text_get(), win) if __name__ == "__main__": elementary.init() win = StandardWindow("test", "Python EFL test application") win.callback_delete_request_add(destroy, "test1", "test2", str3="test3", str4="test4") box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = ( "Please select a test from the list below by clicking<br>" "the test button to show the test window." ) lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() tg = Check(win, style="toggle", text="UI-Mirroring:") tg.callback_changed_add(cb_mirroring) box0.pack_end(tg) tg.show() bx1 = Box(win, size_hint_weight=(EVAS_HINT_EXPAND, 0.0), size_hint_align=(EVAS_HINT_FILL, 0.0), horizontal=True) box0.pack_end(bx1)
def notify_clicked(obj=None): win = StandardWindow("notify", "Notify", autodel=True, size=(400, 400)) if obj is None: win.callback_delete_request_add(lambda x: elementary.exit()) win.show() tb = Table(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) tb.show() # Notify top bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.0), content=bx) lb = Label(win, text="This position is the default.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 1, 1, 1) bt.show() # Notify bottom bx = Box(win, horizontal=True) bx.show() notify = Notify(win, allow_events=False, size_hint_weight=EXPAND_BOTH, align=(0.5, 1.0), timeout=(5.0), content=bx) notify.callback_timeout_add(lambda x: setattr(x, "timeout", 2.0)) notify.callback_block_clicked_add( lambda x: print("Notify block area clicked!!")) lb = Label(win) lb.text = ("Bottom position. This notify uses a timeout of 5 sec.<br/>" "<b>The events outside the window are blocked.</b>") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 3, 1, 1) bt.show() # Notify left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.5), timeout=10.0, content=bx) notify.callback_timeout_add(lambda x: print("Notify timed out!")) lb = Label(win) lb.text = "Left position. This notify uses a timeout of 10 sec." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 2, 1, 1) bt.show() # Notify center bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.5, 0.5), timeout=10.0, content=bx) notify.callback_timeout_add(lambda x: print("Notify timed out!")) lb = Label(win) lb.text = "Center position. This notify uses a timeout of 10 sec." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Center") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 2, 2, 1, 1) bt.show() # Notify right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.5), content=bx) lb = Label(win, text="Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 2, 1, 1) bt.show() # Notify top left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 0.0), content=bx) lb = Label(win, text="Top Left position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 1, 1, 1) bt.show() # Notify top right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 0.0), content=bx) lb = Label(win, text="Top Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Top Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 1, 1, 1) bt.show() # Notify bottom left bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, 1.0), content=bx) lb = Label(win, text="Bottom Left position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Left") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 3, 1, 1) bt.show() # Notify bottom right bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, 1.0), content=bx) lb = Label(win, text="Bottom Right position.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close in 2s") bt.callback_clicked_add(lambda x, y=notify: setattr(y, "timeout", 2.0)) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=FILL_BOTH, text="Bottom Right") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 3, 3, 1, 1) bt.show() # Notify top fill bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(ELM_NOTIFY_ALIGN_FILL, 0.0), timeout=5.0, content=bx) lb = Label(win) lb.text = ("Fill top. This notify fills horizontal area.<br/>" "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 0.0)</b>") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Top fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 0, 3, 1) bt.show() # Notify bottom fill bx = Box(win, horizontal=True) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(ELM_NOTIFY_ALIGN_FILL, 1.0), timeout=5.0, content=bx) lb = Label(win, size_hint_weight=EXPAND_BOTH, size_hint_align=(0.0, 0.5)) lb.text = ("Fill Bottom. This notify fills horizontal area.<br/>" "<b>notify.align = (ELM_NOTIFY_ALIGN_FILL, 1.0)</b>") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0.5), text="Bottom fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 1, 4, 3, 1) bt.show() # Notify left fill bx = Box(win) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(0.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx) lb = Label(win, text="Left fill.") bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Left fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 0, 1, 1, 3) bt.show() # Notify right fill bx = Box(win) bx.show() notify = Notify(win, size_hint_weight=EXPAND_BOTH, align=(1.0, ELM_NOTIFY_ALIGN_FILL), timeout=5.0, content=bx) lb = Label(win) lb.text = "Right fill." bx.pack_end(lb) lb.show() bt = Button(win, text="Close") bt.callback_clicked_add(lambda x, y=notify: y.hide()) bx.pack_end(bt) bt.show() bt = Button(win, size_hint_align=(0.5, EVAS_HINT_FILL), text="Right fill") bt.callback_clicked_add(lambda x, y=notify: y.show()) tb.pack(bt, 4, 1, 1, 3) bt.show()
def __init__(self, parent, method): Popup.__init__(self, parent) self._method = method self._param_entry = None self._return_entry = None # title self.part_text_set('title,text', 'Method: %s()' % method.name) self.show() # content is vbox vbox = Box(parent) vbox.show() self.content = vbox # params label + entry if len(method.params) > 0: label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Params: ' + method.params_str label.show() vbox.pack_end(label) en = Entry(parent) self._param_entry = en en.editable = True en.scrollable = True en.single_line = True en.entry = '' en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.show() vbox.pack_end(en) sp = Separator(win) sp.horizontal = True sp.show() vbox.pack_end(sp) # returns label + entry label = Label(parent) label.size_hint_align = 0.0, 0.5 label.text = 'Returns: ' label.text += method.returns_str if method.returns_str else 'None' label.show() vbox.pack_end(label) en = Entry(parent) self._return_entry = en en.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND en.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL en.editable = False en.scrollable = True en.disabled = True en.single_line = True # TODO this is wrong, but the only way to show the entry :/ en.entry = '<br> <br> <br>' en.show() vbox.pack_end(en) # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state ch = Check(parent) ch.size_hint_align = 0.0, 0.5 ch.text = "Prettify output (loosing type infos)" ch.state = options.pretty_output ch.callback_changed_add(pretty_output_clicked_cb) ch.show() vbox.pack_end(ch) # popup buttons btn = Button(parent) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) self.part_content_set('button1', btn) btn = Button(parent) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) self.part_content_set('button2', btn) btn = Button(parent) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) self.part_content_set('button3', btn)
def __init__(self, parent_widget, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.cancelCallback = None self.actionCallback = None self.__first_run = True self.use_theme = False self.override_theme_font_size = True self.override_font_size = 14 self.theme_data = None self.default_font = 'Sans' self.default_font_style = 'Regular' self.default_font_size = 14 self.selected_font = self.default_font self.selected_font_style = self.default_font_style self.selected_font_size = self.default_font_size self.font_style_str = self.get_text_style(self.selected_font, self.selected_font_style, self.selected_font_size) self.preview_text = 'abcdefghijk ABCDEFGHIJK' # Font size min and max self.fs_min = 8 self.fs_max = 72 lb = Label(self, text="<br><hilight><i>Select Font</i></hilight>", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) lb.show() self.pack_end(lb) sp = Separator(self, horizontal=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sp.show() self.pack_end(sp) # A horizontal box to hold our font list and font styles fontBox = Box(self, horizontal=True, homogeneous=True, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) fontBox.show() self.pack_end(fontBox) # A vertical box to hold label and list of font families vBoxFL = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vBoxFL.show() fontBox.pack_end(vBoxFL) # A vertical box to hold label and list of font styles vBoxFS = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vBoxFS.show() fontBox.pack_end(vBoxFS) # Generate our needed font data #now =time.time() fonts = [] fonts_raw = self.evas.font_available_list() # populate with default font families # see elm_font_available_hash_add Function in EFL f_families = ['Sans', 'Serif', 'Monospace'] f_styles = ['Regular', 'Italic', 'Bold', 'Bold Italic'] fonts_raw += [i + ':style=' + s for i in f_families for s in f_styles] self.fonts_hash = {} for font in fonts_raw: a = font_properties_get(font) # if font name contains a '-' a.name will replace with '\\-' # This needs removed to properly display the name fn = a.name.replace('\\', '') fonts.append(fn) if fn in self.fonts_hash: self.fonts_hash.setdefault(fn, []).append(a.styles[0]) else: self.fonts_hash[fn] = [a.styles[0]] # Deal with some problematic special cases for a, s in self.fonts_hash.items(): #print(a,s) if s: if len(s) == 1: s[0] = s[0].rstrip() if s[0] == u'regular': s[0] = u'Regular' if s[0] == u'Medium Italic': self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif s[0] == u'Italic': if a != u'Romande ADF Script Std': self.fonts_hash.setdefault(a, []).append(u'Regular') self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') else: self.fonts_hash.setdefault(a, []).append(u'Italic') self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) == 2: if any(u'Oblique' in w for w in s): if a not in { u'Baskervald ADF Std Heavy', u'Latin Modern Roman Demi' }: self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault( a, []).append(u'Bold Oblique') elif any(u'Italic' in w for w in s): self.fonts_hash.setdefault(a, []).append(u'Bold') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') else: self.fonts_hash.setdefault(a, []).append(u'Italic') self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) == 3 and set(s) == { u'Bold', u'Oblique', u'Medium' }: # case GWMonospace self.fonts_hash.setdefault(a, []).append(u'Bold Oblique') elif len(s) == 3 and set(s) == { u'Italic', u'Regular', u'Bold' }: # Case Eden Mills self.fonts_hash.setdefault(a, []).append(u'Bold Italic') elif len(s) < 4: print("may need fixed Font style for %s: %s" % (a, s)) #print(self.fonts_hash) # for some strange reason many fonts are displayed multiple times. The following lines remove # all duplicates and then sort them alphabetically. # FIXME: Is this still true fonts = list(set(fonts)) fonts.sort(cmp=locale.strcoll) # Elm List for holding font options self.font_list = List(self, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_LIMIT) #self.font_list.callback_selected_add(self.__font_demo_name_set) for font in fonts: self.font_list.item_append(font.replace('\\', '')) if font == self.selected_font: font_it = self.font_list.last_item_get() #print (time.time()- now) self.font_list.go() self.font_list.show() font_family_label = Label(self) font_family_label.text = "<br><b>Font:</b>" font_family_label.show() vBoxFL.pack_end(font_family_label) vBoxFL.pack_end(self.font_list) # Elm List for hold font styles self.font_style = List(self, size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH, mode=ELM_LIST_LIMIT) #self.font_style.callback_selected_add(self.__font_demo_style_set) self.__reset_font_style_list(font_it.text_get()) self.font_style.go() self.font_style.show() font_style_label = Label(self) font_style_label.text = "<br><b>Style:</b>" font_style_label.show() vBoxFS.pack_end(font_style_label) vBoxFS.pack_end(self.font_style) # A table to hold font size Spinner and set theme default Check tb = Table(self, homogeneous=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.pack_end(tb) tb.show() # spinner to choose the font size self.font_sizer = Spinner(self) self.font_sizer.min_max_set(self.fs_min, self.fs_max) self.font_sizer.value_set(self.selected_font_size) #self.font_sizer.callback_changed_add(self.__font_demo_size_set) self.font_sizer.show() # Label for Spinner font_sizer_label = Label(self) font_sizer_label.text = "Font Size: " font_sizer_label.show() size_box = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) size_box.horizontal_set(True) size_box.pack_end(font_sizer_label) size_box.pack_end(self.font_sizer) size_box.show() tb.pack(size_box, 33, 0, 34, 34) self.use_theme_ck = Check(self, text="Theme Default ", size_hint_weight=EXPAND_HORIZ, size_hint_align=(1, 0.5)) self.use_theme_ck.callback_changed_add(self.__use_theme_checked) self.use_theme_ck.show() tb.pack(self.use_theme_ck, 67, 0, 33, 34) # Entry to hold sample text self.font_demo = Entry(self, single_line=True, editable=False, context_menu_disabled=True, text=self.preview_text, scrollable=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.font_demo.show() demo_box = Frame(self, size_hint_align=FILL_BOTH, text="Preview:", content=self.font_demo) demo_box.show() # Fixme: move this shit font_it.selected_set(True) font_it.show() # Ensure focus is on Font List self.font_list.focus_set(True) self.pack_end(demo_box) # cancel and OK buttons ok_button = Button(self) ok_button.text = "OK" ok_button.callback_pressed_add(self.__ok_button_pressed) ok_button.show() cancel_button = Button(self) cancel_button.text = "Cancel" cancel_button.callback_pressed_add(self.__cancel_button_pressed) cancel_button.show() # box for buttons button_box = Box(self) button_box.horizontal_set(True) button_box.show() button_box.pack_end(cancel_button) button_box.pack_end(ok_button) self.pack_end(button_box)
def __init__(self, parent, session): PreferencesDialog.__init__(self, "Session") # TODO: Construct and populate this with an Idler self.session = session widgets = {} elm_conf = Configuration() s = session.settings() t = Table(self, padding=(5, 5), homogeneous=True, size_hint_align=FILL_BOTH) self.box.pack_end(t) t.show() i = 0 INT_MIN = -2147483648 INT_MAX = 2147483647 scale = elm_conf.scale for k in dir(s): if k.startswith("__"): continue try: a = getattr(s, k) if isinstance(a, lt.disk_cache_algo_t): w = Spinner(t) w.size_hint_align = FILL_HORIZ # XXX: lt-rb python bindings don't have all values. w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys()) for name, val in lt.disk_cache_algo_t.names.items(): w.special_value_add(val, name) w.value = a elif isinstance(a, bool): w = Check(t) w.size_hint_align = 1.0, 0.0 w.style = "toggle" w.state = a elif isinstance(a, int): w = Spinner(t) w.size_hint_align = FILL_HORIZ w.min_max = INT_MIN, INT_MAX w.value = a elif isinstance(a, float): w = Slider(t) w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.unit_format = "%1.2f" if k.startswith("peer_turnover"): w.min_max = 0.0, 1.0 else: w.min_max = 0.0, 20.0 w.value = a elif k == "peer_tos": # XXX: This is an int pair in libtorrent, # which doesn't have a python equivalent. continue elif k == "user_agent": w = Entry(t) w.size_hint_align = 1.0, 0.0 w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.editable = False w.entry = cgi.escape(a) else: w = Entry(t) w.part_text_set("guide", "Enter here") w.size_hint_align = FILL_HORIZ w.size_hint_weight = EXPAND_HORIZ w.single_line = True w.entry = cgi.escape(a) l = Label(t) l.text = k.replace("_", " ").capitalize() l.size_hint_align = 0.0, 0.0 l.size_hint_weight = EXPAND_HORIZ l.show() t.pack(l, 0, i, 1, 1) #w.size_hint_min = scale * 150, scale * 25 t.pack(w, 1, i, 1, 1) w.show() widgets[k] = w i += 1 except TypeError: pass #print("Error {}".format(k)) save_btn = Button(self) save_btn.text = "Apply session settings" save_btn.callback_clicked_add(self.apply_settings, widgets, session) save_btn.show() self.box.pack_end(save_btn)
win.show() if __name__ == "__main__": elementary.init() win = StandardWindow("test", "python-elementary test application", size=(320,520)) win.callback_delete_request_add(lambda x: elementary.exit()) box0 = Box(win, size_hint_weight=EXPAND_BOTH) win.resize_object_add(box0) box0.show() lb = Label(win) lb.text = "Please select a test from the list below<br>" \ "by clicking the test button to show the<br>" \ "test window." lb.show() fr = Frame(win, text="Information", content=lb) box0.pack_end(fr) fr.show() items = [("Bubble", bubble_clicked), ] li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box0.pack_end(li) li.show() for item in items:
def __init__(self, parent, h): if not h.is_valid(): Information(parent.win, "Invalid torrent handle.") return if not h.has_metadata(): Information(parent.win, "Torrent contains no metadata.") return i = h.get_torrent_info() InnerWindow.__init__(self, parent.win) box = Box(self) box.size_hint_align = -1.0, -1.0 box.size_hint_weight = 1.0, 1.0 tname = Label(self) tname.size_hint_align = -1.0, 0.5 tname.line_wrap = ELM_WRAP_CHAR tname.ellipsis = True tname.text = "{}".format(cgi.escape(i.name())) tname.show() box.pack_end(tname) for func in i.comment, i.creation_date, i.creator: try: w = func() except Exception as e: log.debug(e) else: if w: f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = func.__name__.replace("_", " ").capitalize() l = Label(self) l.ellipsis = True l.text = cgi.escape(str(w)) l.show() f.content = l f.show() box.pack_end(f) tpriv = Check(self) tpriv.size_hint_align = 0.0, 0.0 tpriv.text = "Private" tpriv.tooltip_text_set("Whether this torrent is private.<br> \ i.e., it should not be distributed on the trackerless network<br> \ (the kademlia DHT).") tpriv.disabled = True tpriv.state = i.priv() magnet_uri = lt.make_magnet_uri(h) f = Frame(self) f.size_hint_align = -1.0, 0.0 f.text = "Magnet URI" me_box = Box(self) me_box.horizontal = True me = Entry(self) me.size_hint_align = -1.0, 0.0 me.size_hint_weight = 1.0, 0.0 #me.editable = False me.entry = magnet_uri me_box.pack_end(me) me.show() me_btn = Button(self) me_btn.text = "Copy" if hasattr(me, "cnp_selection_set"): me_btn.callback_clicked_add( lambda x: me.top_widget.cnp_selection_set( ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text)) else: import pyperclip me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri)) me_btn.show() me_box.pack_end(me_btn) me_box.show() f.content = me_box f.show() box.pack_end(f) fl_btn = Button(self) fl_btn.text = "Files ->" fl_btn.callback_clicked_add(self.file_list_cb, h) xbtn = Button(self) xbtn.text_set("Close") xbtn.callback_clicked_add(lambda x: self.delete()) for w in tpriv, fl_btn, xbtn: w.show() box.pack_end(w) box.show() nf = self.nf = Naviframe(self) nf.item_simple_push(box) self.content_set(nf) self.activate()
def label_clicked(obj): win = StandardWindow("label", "Label test", autodel=True, size=(280, 400)) if obj is None: win.callback_delete_request_add(lambda o: elementary.exit()) vbox = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) win.resize_object_add(vbox) vbox.show() lb = Label(win, "<b>This is a small label</b>", size_hint_align=(0.0, 0.5)) vbox.pack_end(lb) lb.show() lb = Label(win, size_hint_align=(0.0, 0.5)) lb.text = "This is a larger label with newlines<br/>" \ "to make it bigger, bit it won't expand or wrap<br/>" \ "just be a block of text that can't change its<br/>" \ "formatting as it's fixed based on text<br/>" vbox.pack_end(lb) lb.show() lb = Label(win, line_wrap=ELM_WRAP_CHAR, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) lb.text = "<b>This is more text designed to line-wrap here as " \ "This object is resized horizontally. As it is " \ "resized vertically though, nothing should change. " \ "The amount of space allocated vertically should " \ "change as horizontal size changes.</b>" vbox.pack_end(lb) lb.show() lb = Label(win, text="This small label set to wrap", size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH) vbox.pack_end(lb) lb.show() sp = Separator(win, horizontal=True) vbox.pack_end(sp) sp.show() gd = Grid(win, size=(100, 100), size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) vbox.pack_end(gd) gd.show() lb = Label(win, text="Test Label Ellipsis:", size_hint_align=(0.0, 0.5)) gd.pack(lb, 5, 5, 90, 15) lb.show() rect = Rectangle(win.evas, color=(255, 125, 125, 255)) gd.pack(rect, 5, 15, 90, 15) rect.show() lb = Label(win, ellipsis=True, size_hint_align=(0.0, 0.5)) lb.text = "This is a label set to ellipsis. " \ "If set ellipsis to true and the text doesn't fit " \ "in the label an ellipsis(\"...\") will be shown " \ "at the end of the widget." gd.pack(lb, 5, 15, 90, 15) lb.show() lb = Label(win, text="Test Label Slide:", size_hint_align=(0.0, 0.5)) gd.pack(lb, 5, 30, 90, 15) lb.show() rect = Rectangle(win.evas, color=(255, 125, 125, 255)) gd.pack(rect, 5, 40, 90, 15) rect.show() lb = Label(win, slide_mode=ELM_LABEL_SLIDE_MODE_AUTO, style="slide_short", size_hint_align=(0.0, 0.5), slide_duration=15) lb.text = "This is a label set to slide. " \ "If set slide to true the text of the label " \ "will slide/scroll through the length of label." \ "This only works with the themes \"slide_short\", " \ "\"slide_long\" and \"slide_bounce\"." gd.pack(lb, 5, 40, 90, 15) lb.show() rd = Radio(win, state_value=1, text="slide_short") gd.pack(rd, 5, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() rdg = rd rd = Radio(win, state_value=2, text="slide_long") rd.group_add(rdg) gd.pack(rd, 35, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() rd = Radio(win, state_value=3, text="slide_bounce") rd.group_add(rdg) gd.pack(rd, 65, 55, 30, 15) rd.callback_changed_add(cb_slide_radio, lb) rd.show() sl_dur = Slider(win, text="Slide Duration", unit_format="%1.1f secs", min_max=(1, 40), value=15, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl_dur.callback_changed_add(cb_slider_duration, lb) gd.pack(sl_dur, 5, 70, 90, 15) sl_dur.show() sl_spd = Slider(win, text="Slide Speed", unit_format="%1.1f px/sec", min_max=(10, 300), value=10, size_hint_align=FILL_HORIZ, size_hint_weight=EXPAND_HORIZ) sl_spd.callback_changed_add(cb_slider_speed, lb) gd.pack(sl_spd, 5, 80, 90, 15) sl_spd.show() lb.data["slider_duration"] = sl_dur lb.data["slider_speed"] = sl_spd win.show()
def __init__(self, parent_widget, defaultPath="", defaultPopulate=True, *args, **kwargs): Box.__init__(self, parent_widget, *args, **kwargs) self.cancelCallback = None self.actionCallback = None self.directoryChangeCallback = None self.threadedFunction = ThreadedFunction() self._timer = ecore.Timer(0.02, self.populateFile) #Watch key presses for ctrl+l to select entry parent_widget.elm_event_callback_add(self.eventsCb) self.selectedFolder = None self.showHidden = False self.currentDirectory = None self.focusedEntry = None self.folderOnly = False self.sortReverse = False self.addingHidden = False self.pendingFiles = deque() self.currentSubFolders = [] self.currentFiles = [] #Mode should be "save" or "load" self.mode = "save" self.home = os.path.expanduser("~") self.root = "/" #Label+Entry for File Name self.filenameBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filenameBox.horizontal = True self.filenameBox.show() fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) fileLabel.text = "Filename:" fileLabel.show() self.fileEntry = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.fileEntry.single_line_set(True) self.fileEntry.scrollable_set(True) self.fileEntry.callback_changed_user_add(self.fileEntryChanged) self.fileEntry.show() self.filenameBox.pack_end(fileLabel) self.filenameBox.pack_end(self.fileEntry) sep = Separator(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) sep.horizontal_set(True) sep.show() #Label+Entry for File Path self.filepathBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.filepathBox.horizontal = True self.filepathBox.show() fileLabel = Label(self, size_hint_weight=(0.15, EVAS_HINT_EXPAND), size_hint_align=FILL_HORIZ) fileLabel.text = "Current Folder:" fileLabel.show() self.filepathEntry = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_HORIZ) self.filepathEntry.single_line_set(True) self.filepathEntry.scrollable_set(True) self.filepathEntry.callback_changed_user_add(self.fileEntryChanged) self.filepathEntry.callback_unfocused_add(self.filepathEditDone) self.filepathEntry.callback_activated_add(self.filepathEditDone) #Wish this worked. Doesn't seem to do anything #self.filepathEntry.input_hint_set(ELM_INPUT_HINT_AUTO_COMPLETE) if defaultPath and os.path.isdir(defaultPath): startPath = defaultPath else: startPath = self.home self.filepathEntry.show() self.filepathBox.pack_end(fileLabel) self.filepathBox.pack_end(self.filepathEntry) self.autocompleteHover = Hoversel(self, hover_parent=self) self.autocompleteHover.callback_selected_add(self.autocompleteSelected) #self.autocompleteHover.show() self.fileSelectorBox = Panes(self, content_left_size=0.3, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileSelectorBox.show() """Bookmarks Box contains: - Button - Up Arrow - List - Home/Root/GTK bookmarks - Box -- Button - Add Bookmark -- Button - Remove Bookmark""" self.bookmarkBox = Box(self, size_hint_weight=(0.3, EVAS_HINT_EXPAND), size_hint_align=FILL_BOTH) self.bookmarkBox.show() upIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) upIcon.standard_set("go-up") upIcon.show() self.upButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=upIcon) self.upButton.text = "Up" self.upButton.callback_pressed_add(self.upButtonPressed) self.upButton.show() self.bookmarksList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.bookmarksList.callback_activated_add(self.bookmarkDoubleClicked) self.bookmarksList.show() self.bookmarkModBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.bookmarkModBox.horizontal = True self.bookmarkModBox.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("add") con.show() self.addButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.addButton.callback_pressed_add(self.addButtonPressed) self.addButton.disabled = True self.addButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("remove") con.show() self.removeButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ, content=con) self.removeButton.callback_pressed_add(self.removeButtonPressed) self.removeButton.disabled = True self.removeButton.show() self.bookmarkModBox.pack_end(self.addButton) self.bookmarkModBox.pack_end(self.removeButton) self.bookmarkBox.pack_end(self.upButton) self.bookmarkBox.pack_end(self.bookmarksList) self.bookmarkBox.pack_end(self.bookmarkModBox) #Directory List self.fileListBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileListBox.show() self.fileSortButton = Button(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) self.fileSortButton.text = u"⬆ Name" self.fileSortButton.callback_pressed_add(self.sortData) self.fileSortButton.show() self.fileList = Genlist(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, homogeneous=True, mode=ELM_LIST_COMPRESS) self.fileList.callback_activated_add(self.fileDoubleClicked) self.fileList.show() self.previewImage = previewImage = Image(self) #previewImage.size_hint_weight = EXPAND_BOTH previewImage.size_hint_align = FILL_BOTH previewImage.show() self.fileListBox.pack_end(self.fileSortButton) self.fileListBox.pack_end(self.fileList) self.fileListBox.pack_end(self.previewImage) self.fileSelectorBox.part_content_set("left", self.bookmarkBox) self.fileSelectorBox.part_content_set("right", self.fileListBox) #Cancel and Save/Open button self.buttonBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1.0, 0.5)) self.buttonBox.horizontal = True self.buttonBox.show() self.actionIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.actionIcon.standard_set("document-save") self.actionIcon.show() self.actionButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=self.actionIcon) self.actionButton.text = "Save " self.actionButton.callback_pressed_add(self.actionButtonPressed) self.actionButton.show() cancelIcon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) cancelIcon.standard_set("dialog-cancel") cancelIcon.show() self.cancelButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=cancelIcon) self.cancelButton.text = "Cancel " self.cancelButton.callback_pressed_add(self.cancelButtonPressed) self.cancelButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("gtk-find") con.show() self.toggleHiddenButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.toggleHiddenButton.text = "Toggle Hidden " self.toggleHiddenButton.callback_pressed_add( self.toggleHiddenButtonPressed) self.toggleHiddenButton.show() con = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) con.standard_set("folder-new") con.show() self.createFolderButton = Button(self, size_hint_weight=(0.0, 0.0), size_hint_align=(1.0, 0.5), content=con) self.createFolderButton.text = "Create Folder " self.createFolderButton.callback_pressed_add( self.createFolderButtonPressed) self.createFolderButton.show() self.buttonBox.pack_end(self.createFolderButton) self.buttonBox.pack_end(self.toggleHiddenButton) self.buttonBox.pack_end(self.cancelButton) self.buttonBox.pack_end(self.actionButton) self.pack_end(self.filenameBox) self.pack_end(sep) self.pack_end(self.filepathBox) self.pack_end(self.autocompleteHover) self.pack_end(self.fileSelectorBox) self.pack_end(self.buttonBox) self.populateBookmarks() self.createPopup = Popup(self) self.createPopup.part_text_set("title,text", "Create Folder:") self.createEn = en = Entry(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.single_line_set(True) en.scrollable_set(True) en.show() self.createPopup.content = en bt = Button(self, text="Create") bt.callback_clicked_add(self.createFolder) self.createPopup.part_content_set("button1", bt) bt2 = Button(self, text="Cancel") bt2.callback_clicked_add(self.closePopup) self.createPopup.part_content_set("button2", bt2) if defaultPopulate: self.populateFiles(startPath)
def __init__(self): self.mainWindow = StandardWindow("epad", "Untitled - ePad", size=(600, 400)) self.mainWindow.callback_delete_request_add(self.closeChecks) self.mainWindow.elm_event_callback_add(self.eventsCb) icon = Icon(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) icon.standard_set('accessories-text-editor') icon.show() self.mainWindow.icon_object_set(icon.object_get()) self.mainBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.mainBox.show() self.newInstance = NEW_INSTANCE self.mainTb = ePadToolbar(self, self.mainWindow) self.mainTb.focus_allow = False self.mainTb.show() self.mainBox.pack_end(self.mainTb) # Root User Notification if os.geteuid() == 0: printErr("Caution: Root User") if NOTIFY_ROOT: notifyBox = Box(self.mainWindow, horizontal=True) notifyBox.show() notify = Notify(self.mainWindow, size_hint_weight=EXPAND_BOTH, align=(ELM_NOTIFY_ALIGN_FILL, 0.0), content=notifyBox) notifyLabel = Label(self.mainWindow) notifyLabel.text = "<b><i>Root User</i></b>" notifyBox.pack_end(notifyLabel) notifyLabel.show() self.mainBox.pack_end(notifyBox) self.about = aboutWin(self, self.mainWindow) self.about.hide() # Initialize Text entry box and line label # FIXME: self.wordwrap initialized by ePadToolbar print("Word wrap Initialized: {0}".format(self.wordwrap)) self.entryInit() # Build our file selector for saving/loading files self.fileBox = Box(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileBox.show() self.fileLabel = Label(self.mainWindow, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH, text="") self.fileLabel.show() self.lastDir = os.getenv("HOME") self.fileSelector = Fileselector(self.mainWindow, is_save=False, expandable=False, folder_only=False, hidden_visible=SHOW_HIDDEN, path=self.lastDir, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.fileSelector.callback_done_add(self.fileSelected) self.fileSelector.callback_activated_add(self.fileSelected) self.fileSelector.callback_directory_open_add(self.updateLastDir) self.fileSelector.path_set(os.getcwd()) self.fileSelector.show() self.fileBox.pack_end(self.fileLabel) self.fileBox.pack_end(self.fileSelector) # Flip object has the file selector on one side # and the GUI on the other self.flip = Flip(self.mainWindow, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) self.flip.part_content_set("front", self.mainBox) self.flip.part_content_set("back", self.fileBox) self.mainWindow.resize_object_add(self.flip) self.flip.show() self.isSaved = True self.isNewFile = False self.confirmPopup = None self.fileExistsFlag = False