本文整理汇总了Python中thorpy.miscgui.functions.obtain_valid_painter函数的典型用法代码示例。如果您正苦于以下问题:Python obtain_valid_painter函数的具体用法?Python obtain_valid_painter怎么用?Python obtain_valid_painter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了obtain_valid_painter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup
def _setup(self, height=None, dragsize=None):
height = style.SLIDER_THICK if height is None else height
dragsize = style.SLIDERX_DRAG_SIZE if dragsize is None else dragsize
self._height = height
size = (self._length + dragsize[0] + style.SLIDER_MARGINS[0], height)
painter = functions.obtain_valid_painter(
painterstyle.DEF_PAINTER,
pressed=True,
color=style.DEF_COLOR2,
size=size)
self.set_painter(painter)
dp = functions.obtain_valid_painter(
painterstyle.DEF_PAINTER,
pressed=False,
size=dragsize)
try:
drag_x = self.val_to_pix(self.initial_value,
self.get_fus_topleft()[0]) + 1
self._drag_element.change_painter(dp, autopress=False)
self._drag_element.set_center((drag_x, self.get_fus_center()[1]))
except AttributeError:
drag_x = self.val_to_pix(self.initial_value,
self.get_ghost_topleft()[0]) + 1
self._drag_element.set_painter(dp, autopress=False)
self._drag_element.set_center((drag_x, self.get_ghost_center()[1]))
self._drag_element.set_free(y=False)
self.englobe_childrens()
示例2: _gen_painter
def _gen_painter(self):
if self._type == "checkbox":
return functions.obtain_valid_painter(
painterstyle.CHECKBOX_PAINTER,
color=style.DEF_COLOR2,
size=style.CHECK_SIZE,
pressed=True)
elif self._type == "radio":
return functions.obtain_valid_painter(
painterstyle.RADIO_PAINTER,
size=style.CHECK_SIZE, pressed=True)
示例3: set_standard_style
def set_standard_style(self):
from thorpy.painting.fusionner import _Fusionner
for e in self.get_elements():
painter = functions.obtain_valid_painter(painterstyle.BASIC_PAINTER,
size=e.get_fus_rect().size)
fusionner = _Fusionner(painter, e.get_title())
e.set_image(fusionner.img)
示例4: __init__
def __init__(self,
size,
titles,
elements=None,
normal_params=None,
heavy=False,
folders=None,
margins=None,
has_lift=True):
margins = style.DDL_MARGINS if margins is None else margins
self._clicked = None
Element.__init__(self, elements=elements, normal_params=normal_params)
painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
pressed=True,
## color=style.DEF_COLOR2,
size=size,
radius=style.BOX_RADIUS)
self.set_painter(painter)
self._margins = margins
self._heavy = heavy
self._dv = self._get_dirviewer(titles, size, folders)
reac_motion= Reaction(MOUSEMOTION,
self._reaction_motion,
reac_name=constants.REAC_MOTION)
self.add_reaction(reac_motion)
self._cursor_pos = (-1, -1)
self._has_lift = has_lift
self._menu = None
self._set_selecter()
self._force_lift = False
示例5: _setup
def _setup(self, width=style.LIFT_BUTTON_SIZE[0],
dragsize=style.LIFT_DRAG_SIZE):
self._drag_element = DraggerLiftY(self)
self._height = width
painter = functions.obtain_valid_painter(
painterstyle.DEF_PAINTER,
pressed=True,
color=style.DEF_COLOR2,
size=(
width,
self._length +
dragsize[1] +
style.LIFT_MARGINS[1] +
1))
self.set_painter(painter)
self._drag_element.set_painter(
painterstyle.DEF_PAINTER(
size=dragsize),
autopress=False)
try:
self._drag_element.set_center((self.get_fus_center()[0], None))
except AttributeError: # state is ghost state, and has no fusionner
self._drag_element.set_center((self.get_ghost_center()[0], None))
self._drag_element.set_free(y=False)
self.englobe_childrens()
示例6: _get_name_element
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
示例7: _get_file_element
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
示例8: __init__
def __init__(self,
path="./",
ddl_size=None,
normal_params=None,
folders=True,
files=True,
file_types=None,
text=""):
"""File and folder browser.
<path>: the path of the folder in which browser browse files.
<ddl_size>: if not None, force the size of the dropdown list of files.
<folders>: if True, displays folders to user.
<files>: if True, displays file to user.
<file_types>: if not None, pass a list of files formats that you wand to
be valid for user choice.
<text>: title text of the browser.
"""
ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
super(BrowserLight, self).__init__(normal_params=normal_params)
self.path = path
self._ddl_size = ddl_size
if not hasattr(file_types, "__iter__") and file_types is not None:
raise ValueError("Files types must be a sequence.")
self.file_types = file_types
# DropDownListFast
actual_folders, actual_files = self._get_folders_and_files()
actual_files = self._filter_files(actual_files)
if not folders:
actual_folders = None
if not files:
actual_files = []
self._ddlf = DropDownListFast(size=self._ddl_size, titles=actual_files,
folders=actual_folders)
# selection button
inserter_width = 3 * ddl_size[0] // 4
## if inserter_width > style.MAX_INSERTER_WIDTH:
## inserter_width = style.MAX_INSERTER_WIDTH
self._selected = Inserter("Selected : ", size=(inserter_width, None))
self._selected.finish()
if isinstance(text, str):
self.text_element = OneLineText(text)
self.text_element.finish()
else:
self.text_element = text
self.add_elements([self.text_element, self._ddlf, self._selected])
reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
self._reaction_press,
reac_name=constants.REAC_PRESSED)
self._ddlf.finish()
self.add_reaction(reac_pressed)
self._clicked = None
self._something_selected = False
painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
pressed=True,
## color=style.DEF_COLOR2,
radius=style.BOX_RADIUS)
self.set_painter(painter)
self._refresh_ddlf_lift()
示例9: _get_value_element
def _get_value_element(self, valuestyle):
painter = functions.obtain_valid_painter(
painterstyle.CHECKER_VALUE_PAINTER,
size=style.CHECK_SIZE)
el = Element(str(self.get_value()))
el.set_painter(painter)
if valuestyle:
el.set_style(valuestyle)
el.finish()
return el
示例10: _get_name_element
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
示例11: get_launcher_element
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
示例12: __init__
def __init__(self,
name="",
elements=None,
normal_params=None,
press_params=None,
value="",
size=(None, None),
namestyle=None,
varlink_func=None,
quit_on_click=False,
value_type=str):
"""<to_set> : either None or a function which must take one argument"""
namestyle=style.STYLE_INSERTER_NAME if namestyle is None else namestyle
if size[0] is None:
s0 = style.SIZE[0]
else:
s0 = size[0]
if size[1] is None:
s1 = style.Y_SMALL_SIZE
else:
s1 = size[1]
size = (s0, s1)
self.cursor = None
super(Inserter, self).__init__("", elements, normal_params,
press_params)
self._name_element = self._get_name_element(name, namestyle)
self.add_elements([self._name_element])
self._iwriter = _InsertWriter(value)
self._iwriter.finish()
self.add_elements([self._iwriter])
self.quit_on_click = quit_on_click
self._value_type = value_type
painter = functions.obtain_valid_painter(painterstyle.INSERTER_PAINTER,
color=style.DEF_COLOR2,
pressed=True,
size=(s0,s1))
self.set_painter(painter)
self.normal_params.polite_set("states hover",
[constants.STATE_NORMAL,
constants.STATE_PRESSED])
self.press_params.polite_set("states hover",
[constants.STATE_NORMAL,
constants.STATE_PRESSED])
self._activated = False
self._value = value
self._inserted = self._value
self._cursor_index = len(self._inserted)
reac_keypress = Reaction(KEYDOWN, self._reaction_keydown,
reac_name=constants.REAC_KEYPRESS)
self.add_reaction(reac_keypress)
self._keyer = Keyer()
self._hide_mouse = self.normal_params.params.get("hide mouse", False)
self._varlink_func = varlink_func
self.repeat_delay = parameters.KEY_DELAY
self.repeat_interval = parameters.KEY_INTERVAL
示例13: __init__
def __init__(self,
path="./",
ddl_size=None,
normal_params=None,
folders=True,
files=True,
file_types=None,
text=""):
ddl_size = style.BROWSERLIGHT_DDL_SIZE if ddl_size is None else ddl_size
super(BrowserLight, self).__init__(normal_params=normal_params)
self.path = path
self._ddl_size = ddl_size
self.file_types = file_types
self.folders = folders
self.files = files
# DropDownListFast
actual_folders, actual_files = self._get_folders_and_files()
actual_files = self._filter_files(actual_files)
if not folders:
actual_folders = None
if not files:
actual_files = []
self._ddlf = DropDownListFast(self._ddl_size, titles=actual_files,
folders=actual_folders, has_lift=True)
## self._ddlf.finish()
# selection button
inserter_width = 3*ddl_size[0]//4
## if inserter_width > style.MAX_INSERTER_WIDTH:
## inserter_width = style.MAX_INSERTER_WIDTH
self._selected = Inserter("Selected : ", size=(inserter_width, None))
self._selected.finish()
if isinstance(text, str):
self.text_element = OneLineText(text)
self.text_element.finish()
else:
self.text_element = text
self._path_element = PathElement(self, True)
self._path_element.finish()
self.add_elements([self.text_element, self._path_element, self._ddlf,
self._selected])
reac_pressed = Reaction(parameters.BUTTON_UNPRESS_EVENT,
self._reaction_press,
name=constants.REAC_PRESSED)
## self._ddlf._force_lift = True
self._ddlf.finish()
self.add_reaction(reac_pressed)
self._clicked = None
self._something_selected = False
painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
pressed=True,
radius=style.BOX_RADIUS)
self.set_painter(painter)
self._last_click = -2 * parameters.DOUBLE_CLICK_DELAY
示例14: __init__
def __init__(self, elements=None, normal_params=None, height=None):
Element.__init__(self, "", elements, normal_params)
h = max([e.get_storer_rect().height for e in self.get_elements()]) + 2
store(self, mode="h", x=1, y=h/2, align="center")
if self.father:
w = self.father.get_storer_rect().width
else:
w = functions.get_screen_size()[0]
size = (w, h)
painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
pressed=True,
size=size,
radius=style.BOX_RADIUS)
self.set_painter(painter)
示例15: __init__
def __init__(self, bartext="", elements=None, normal_params=None,
storer_params=None, size=None, put_lift=True):
Element.__init__(self, "", elements, normal_params)
self.storer_params = storer_params
if self.storer_params is None:
self.storer_params = dict()
self._size = size
self._has_lift = False
self._put_lift = put_lift
self._bartext = bartext
painter = functions.obtain_valid_painter(painterstyle.BOX_PAINTER,
pressed=True,
size=size,
radius=style.BOX_RADIUS)
self.set_painter(painter)