def _set_path_elements(self, ycoord=None): self.remove_all_elements() i = 0 for s in self._path_list: e = Clickable(s) e.set_style("text") e.normal_params.params["font_size"] = style.PATH_FONT_SIZE e.press_params.params["font_size"] = style.PATH_FONT_SIZE e.finish() e.user_func = self._reaction_path e.user_params = {"n": i} e.set_jailed(self.father) ## e._lock_jail = True #so that in the future jail will always stay self.father self.add_elements([e]) i += 1 father = self if self.father.is_finished(): father = self.father fr = father.get_storer_rect() wtot = h_store(fr, self._elements, gap=0, xstart="auto", ycoord=ycoord) if wtot > fr.width: h_store(fr, self._elements, gap=0, ycoord=ycoord, xstart=fr.right - wtot - 2) self._n = len(self._elements)
def finish(self): Clickable.finish(self) ## self.e_color.stick_to(self, "right", "right") ## self.e_color.move((-2,0)) store(self, mode="h") self.fit_children() self._set_launcher()
def make_image_button_with_frame(img_normal, img_pressed=None, img_hover=None, alpha=255, colorkey=None, text=""): e = Clickable(text,finish=False) painter = ButtonImage(img_normal, img_pressed, img_hover, alpha, colorkey) e.set_painter(painter) e.finish() return e
def finish(self): Clickable.finish(self) ## self.e_color.stick_to(self, "right", "right") ## self.e_color.move((-2,0)) store(self, mode="h") self.fit_children() self._set_launcher()
def _get_name_element(self, name): painter = functions.obtain_valid_painter(painterstyle.DEF_PAINTER, size=style.SIZE) el = Clickable(name) el.set_painter(painter) el.finish() return el
def _get_name_element(self, name): painter = functions.obtain_valid_painter(painterstyle.DEF_PAINTER, size=style.SIZE) el = Clickable(name) el.set_painter(painter) el.finish() return el
def make_image_button(img_normal, img_pressed=None, img_hover=None, alpha=255, colorkey=None, text=""): e = Clickable(text) painter = ButtonImage(img_normal, img_pressed, img_hover, alpha, colorkey) e.set_painter(painter) e.finish() return e
def make_button(text, func=None, params=None): button = Clickable(text) button.finish() button.scale_to_title() if func: button.user_func = func if params: button.user_params = params return button
def make_image_button(img_normal, img_pressed=None, img_hover=None, alpha=255, colorkey=None, text="", force_convert_alpha=False): e = Clickable(text,finish=False) painter = ImageButton(img_normal, img_pressed, img_hover, alpha, colorkey, force_convert_alpha=force_convert_alpha) e.set_painter(painter) e.finish() return e
def get_launcher_element(self, name): size = (style.SIZE[0], style.Y_SMALL_SIZE) painter = functions.obtain_valid_painter( painterstyle.BROWSER_LAUNCHER_PAINTER, size=size) el = Clickable(name) el.set_painter(painter) el.set_style(style.STYLE_BROWSER_LAUNCHER) el.finish() return el
def make_button(text, func=None, params=None): button = Clickable(text) button.finish() button.scale_to_title() if func: button.user_func = func if params: button.user_params = params return button
def _get_name_element(self, name, namestyle): painter = functions.obtain_valid_painter( painterstyle.INSERTER_NAME_PAINTER, size=style.SIZE) el = Clickable(name, finish=False) el.set_painter(painter) if namestyle: el.set_style(namestyle) el.finish() return el
def _get_name_element(self, name, namestyle): painter = functions.obtain_valid_painter( painterstyle.INSERTER_NAME_PAINTER, size=style.SIZE) el = Clickable(name) el.set_painter(painter) if namestyle: el.set_style(namestyle) el.finish() return el
def get_launcher_element(self, name): size = (style.SIZE[0], style.Y_SMALL_SIZE) painter = functions.obtain_valid_painter( painterstyle.BROWSER_LAUNCHER_PAINTER, size=size) el = Clickable(name) el.set_painter(painter) el.set_style(style.STYLE_BROWSER_LAUNCHER) el.finish() return el
def finish(self): Clickable.finish(self) # cursor is initialized in finish because _iwriter needs self.fusionner # to initialize... while not self._iwriter._is_small_enough(self._inserted) and self._inserted: self._inserted = self._inserted[:-1] self._iwriter.refresh_img() self.cursor = _Cursor(self) self.add_elements(list([self.cursor])) self._refresh_pos() self.cursor.finish() self._name_element.user_func = self.enter
def _get_launched_el(self, els, size, storer_params): _done_element = Clickable(style.OK_TXT) _cancel_element = Clickable(style.CANCEL_TXT) _done_element.finish() _cancel_element.finish() g = Ghost([_done_element, _cancel_element]) g.finish() g.englobe_childrens() g.rank = float("inf") store(g, g.get_elements(), "h") els += [g] box = Box(elements=els, size=size, storer_params=storer_params) box.finish() #box stores its elements return box, _done_element, _cancel_element
def _get_launched_el(self, els, size, storer_params): _done_element = Clickable(style.OK_TXT) _cancel_element = Clickable(style.CANCEL_TXT) _done_element.finish() _cancel_element.finish() g = Ghost([_done_element, _cancel_element]) g.finish() g.englobe_childrens() g.rank = float("inf") store(g, g.get_elements(), "h") els += [g] box = Box(elements=els, size=size, storer_params=storer_params) box.finish() #box stores its elements return box, _done_element, _cancel_element
def finish(self): Clickable.finish(self) # cursor is initialized in finish because _iwriter needs self.fusionner # to initialize... self.make_small_enough(self._inserted) if not self._iwriter._is_small_enough(self._inserted): functions.debug_msg("Inserter is too small for value", self._inserted) if self.auto_resize: self.set_size(self._iwriter.get_rect().inflate((2,2)).size) self._iwriter.refresh_img() self.cursor = _Cursor(self) self.add_elements(list([self.cursor])) self._refresh_pos() self.cursor.finish() self._name_element.user_func = self.enter
def finish(self): Clickable.finish(self) # cursor is initialized in finish because _iwriter needs self.fusionner # to initialize... self.make_small_enough(self._inserted) if not self._iwriter._is_small_enough(self._inserted): functions.debug_msg("Inserter is too small for value", self._inserted) if self.auto_resize: self.set_size(self._iwriter.get_rect().inflate((2,2)).size) self._iwriter.refresh_img() self.cursor = _Cursor(self) self.add_elements(list([self.cursor])) self._refresh_pos() self.cursor.finish() self._name_element.user_func = self.enter
def _set_path_elements(self, ycoord=None): self.remove_all_elements() i = 0 for s in self._path_list: e = Clickable(s) e.set_style("text") e.normal_params.params["font_size"] = style.PATH_FONT_SIZE e.press_params.params["font_size"] = style.PATH_FONT_SIZE e.finish() e.user_func = self._reaction_path e.user_params = {"n" : i} e.set_jailed(self.father) ## e._lock_jail = True #so that in the future jail will always stay self.father self.add_elements([e]) i += 1 father = self if self.father.is_finished(): father = self.father fr = father.get_storer_rect() wtot = h_store(fr, self._elements, gap=0, xstart="auto", ycoord=ycoord) if wtot > fr.width: h_store(fr, self._elements, gap=0, ycoord=ycoord, xstart=fr.right - wtot-2) self._n = len(self._elements)
def finish(self): Clickable.finish(self) self.add_arrow("top")
def finish(self): Clickable.finish(self) self.add_arrow("bottom")
def finish(self): Clickable.finish(self) self.add_arrow("top")
def finish(self): Clickable.finish(self) self._set_launcher()
def finish(self): Clickable.finish(self) self._refresh_pos() self._name_element.user_func = self.check
class BrowserLauncher(_Launcher): def __init__(self, browser, name_txt="", file_txt="", launcher_txt="", normal_params=None, file_width=None, show_select=True, click_quit=False): """<browser> : the browser to be launched. Can either be a Browser instance or a BrowserLight instance. <name_txt> : the text that stands before the (optionnal) file name and the button to launch browser. <file_txt> : the default value shown to the user. <launcher_txt> : the text on the launcher button. """ file_width = style.FILE_WIDTH if file_width is None else file_width self.show_select = show_select if not self.show_select: file_txt = "" _Launcher.__init__(self, "", normal_params, click_quit) self._spawn = "center" self.file_width = file_width self._done_element = Clickable(style.OK_TXT) self._done_element.finish() self._cancel_element = Clickable(style.CANCEL_TXT) self._cancel_element.finish() g = Ghost([self._done_element, self._cancel_element]) g.finish() g.fit_children() g.rank = float("inf") store(g, g.get_elements(), "h") # to launch : must not be in self._elements! self.browser = browser box = Box(elements=[self.browser, g], storer_params=None) box.finish() self.launched_element = box self._deny_child(self.launched_element) # launcher self.launcher_el = self.get_launcher_element(launcher_txt) self.launcher_el.user_func = self.launch_box # name self._name_element = self._get_name_element(name_txt) self._name_element.user_func = self.launch_box self._file_element = self._get_file_element(file_txt) self.add_elements([self._name_element, self.launcher_el, self._file_element]) def finish(self): _Launcher.finish(self) self.launched_element.set_prison() self.browser.set_prison() self.browser._ddlf.set_prison() ## h_store(self, self.get_elements()) ## self.stick_to(self.launcher_el, "right", "left") def get_storer_rect(self): return self.get_family_rect(self.current_state_key, False) def get_launcher_element(self, name): size = (style.SIZE[0], style.Y_SMALL_SIZE) painter = functions.obtain_valid_painter( painterstyle.BROWSER_LAUNCHER_PAINTER, size=size) el = Clickable(name) el.set_painter(painter) el.set_style(style.STYLE_BROWSER_LAUNCHER) el.finish() return el def _get_file_element(self, name): painter = functions.obtain_valid_painter(painterstyle.NAME_PAINTER, size=style.SIZE) el = Element(name) el.set_painter(painter) el.set_style(style.STYLE_NAME) el.finish() return el def _refresh_pos(self): h_store(self.get_storer_rect(), self.get_elements()) def launch_box(self, done_no_save=True): self._launch(done_no_save) # ## special browserlauncher handling if self.browser._something_selected: if self.show_select: text = normpath(self.browser._selected._inserted) text = basename(text) self._file_element.set_text(text, size=(self.file_width, self.get_fus_rect().h), cut=True) helpjail = self.father self._name_element.add_basic_help(self.browser._selected._value, jail=helpjail) # ## self._unlaunch() def scale_to_title(self, margins=None, state=None): self.launcher_el.scale_to_title(margins, state) self._refresh_pos() ## def get_storer_rect(self): ## if not self.show_select: ## return self._name_element.get_storer_rect() ## else: ## return _Launcher.get_storer_rect(self)
class BrowserLauncher(_Launcher): def __init__(self, browser, name_txt, file_txt, launcher_txt, normal_params=None, file_width=None, show_select=True, click_quit=False): """<browser> : the browser to be launched. Can either be a Browser instance or a BrowserLight instance. <name_txt> : the text that stands before the (optionnal) file name and the button to launch browser. <file_txt> : the default value shown to the user. <launcher_txt> : the text on the launcher button. """ file_width = style.FILE_WIDTH if file_width is None else file_width self.show_select = show_select if not self.show_select: file_txt = "" _Launcher.__init__(self, "", normal_params, click_quit) self._spawn = "center" self.file_width = file_width self._done_element = Clickable(style.OK_TXT) self._done_element.finish() self._cancel_element = Clickable(style.CANCEL_TXT) self._cancel_element.finish() g = Ghost([self._done_element, self._cancel_element]) g.finish() g.englobe_childrens() g.rank = float("inf") store(g, g.get_elements(), "h") # to launch : must not be in self._elements! self.browser = browser box = Box(elements=[self.browser, g], storer_params=None) box.finish() self.launched_element = box self._deny_child(self.launched_element) # launcher self.launcher_el = self.get_launcher_element(launcher_txt) self.launcher_el.user_func = self.launch_box # name self._name_element = self._get_name_element(name_txt) self._name_element.user_func = self.launch_box self._file_element = self._get_file_element(file_txt) self.add_elements( [self._name_element, self.launcher_el, self._file_element]) def finish(self): _Launcher.finish(self) self.launched_element.set_prison() self.browser.set_prison() self.browser._ddlf.set_prison() ## h_store(self, self.get_elements()) ## self.stick_to(self.launcher_el, "right", "left") def get_storer_rect(self): return self.get_family_rect(self.current_state_key, False) def get_launcher_element(self, name): size = (style.SIZE[0], style.Y_SMALL_SIZE) painter = functions.obtain_valid_painter( painterstyle.BROWSER_LAUNCHER_PAINTER, size=size) el = Clickable(name) el.set_painter(painter) el.set_style(style.STYLE_BROWSER_LAUNCHER) el.finish() return el def _get_file_element(self, name): painter = functions.obtain_valid_painter(painterstyle.NAME_PAINTER, size=style.SIZE) el = Element(name) el.set_painter(painter) el.set_style(style.STYLE_NAME) el.finish() return el def _refresh_pos(self): h_store(self, self.get_elements()) def launch_box(self, done_no_save=True): self._launch(done_no_save) # ## special browserlauncher handling if self.browser._something_selected: if self.show_select: text = normpath(self.browser._selected._inserted) text = basename(text) self._file_element.set_text(text, size=(self.file_width, self.get_fus_rect().h), cut=True) helpjail = self.father self._name_element.add_basic_help(self.browser._selected._value, jail=helpjail) # ## self._unlaunch() def scale_to_title(self, margins=None, state=None): self.launcher_el.scale_to_title(margins, state) self._refresh_pos() ## def get_storer_rect(self): ## if not self.show_select: ## return self._name_element.get_storer_rect() ## else: ## return _Launcher.get_storer_rect(self)
def finish(self): Clickable.finish(self) self._refresh_pos() self._name_element.user_func = self.check
def finish(self): Clickable.finish(self) self.add_arrow("bottom")
def finish(self): Clickable.finish(self) self._set_launcher()