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): 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): 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, 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)
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)