Python-EFL: Fileselector 1,9 API additions.
* added property thumbnail_size * added function custom_filter_append * splitted the 3 tests in 3 different files * test rewritten to better match the C one. NOTE: custom_filter_append is leaking...need to find a proper way to unref Added a note in the TODO for this issue.
This commit is contained in:
parent
b32f95e3c4
commit
684aee077e
2
TODO
2
TODO
|
@ -3,6 +3,8 @@ BUGS
|
|||
====
|
||||
* EdjeEdit: PartState API does not work
|
||||
* Elm.Map: overlays_show segfaults, scrollers in examples are jumpy
|
||||
* Entry.markup_filter_append() and Fileselector.custom_filter_append() are
|
||||
leaking badly, fix and check all other place that have the same issue.
|
||||
|
||||
Failing unit tests
|
||||
------------------
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from efl.eina cimport Eina_Bool, const_Eina_List
|
||||
from efl.evas cimport Evas_Object, const_Evas_Object
|
||||
from efl.evas cimport Evas_Object, const_Evas_Object, Evas_Coord
|
||||
from enums cimport Elm_Fileselector_Mode, Elm_Fileselector_Sort
|
||||
from libc.string cimport const_char
|
||||
|
||||
cdef extern from "Elementary.h":
|
||||
ctypedef Eina_Bool (*Elm_Fileselector_Filter_Func)(const_char *path, Eina_Bool dir, void *data)
|
||||
|
||||
Evas_Object * elm_fileselector_add(Evas_Object *parent)
|
||||
void elm_fileselector_is_save_set(Evas_Object *obj, Eina_Bool is_save)
|
||||
Eina_Bool elm_fileselector_is_save_get(const_Evas_Object *obj)
|
||||
|
@ -23,8 +25,11 @@ cdef extern from "Elementary.h":
|
|||
const_char * elm_fileselector_selected_get(const_Evas_Object *obj)
|
||||
const_Eina_List * elm_fileselector_selected_paths_get(const_Evas_Object *obj)
|
||||
Eina_Bool elm_fileselector_mime_types_filter_append(Evas_Object *obj, const_char *mime_types, const_char *filter_name)
|
||||
Eina_Bool elm_fileselector_custom_filter_append(Evas_Object *obj, Elm_Fileselector_Filter_Func func, void *data, const_char *filter_name)
|
||||
void elm_fileselector_filters_clear(Evas_Object *obj)
|
||||
void elm_fileselector_hidden_visible_set(Evas_Object *obj, Eina_Bool visible)
|
||||
Eina_Bool elm_fileselector_hidden_visible_get(const_Evas_Object *obj)
|
||||
Elm_Fileselector_Sort elm_fileselector_sort_method_get(const_Evas_Object *obj)
|
||||
void elm_fileselector_sort_method_set(Evas_Object *obj, Elm_Fileselector_Sort method)
|
||||
void elm_fileselector_thumbnail_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
void elm_fileselector_thumbnail_size_get(const_Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
||||
|
|
|
@ -138,7 +138,7 @@ Fileselector sort method
|
|||
"""
|
||||
|
||||
|
||||
from cpython cimport PyUnicode_AsUTF8String
|
||||
from cpython cimport PyUnicode_AsUTF8String, Py_INCREF
|
||||
from libc.stdint cimport uintptr_t
|
||||
|
||||
from efl.eo cimport _object_mapping_register
|
||||
|
@ -148,6 +148,8 @@ from layout_class cimport LayoutClass
|
|||
|
||||
cimport enums
|
||||
|
||||
import traceback
|
||||
|
||||
ELM_FILESELECTOR_LIST = enums.ELM_FILESELECTOR_LIST
|
||||
ELM_FILESELECTOR_GRID = enums.ELM_FILESELECTOR_GRID
|
||||
|
||||
|
@ -165,6 +167,15 @@ def _cb_string_conv(uintptr_t addr):
|
|||
cdef const_char *s = <const_char *>addr
|
||||
return _ctouni(s) if s is not NULL else None
|
||||
|
||||
cdef Eina_Bool py_elm_fileselector_custom_filter_cb(const_char *path, Eina_Bool is_dir, void *data) with gil:
|
||||
cb_func, cb_data = <object>data
|
||||
try:
|
||||
return cb_func(_ctouni(path), is_dir, cb_data)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return 0
|
||||
|
||||
|
||||
cdef class Fileselector(LayoutClass):
|
||||
|
||||
"""This is the class that actually implements the widget."""
|
||||
|
@ -425,6 +436,7 @@ cdef class Fileselector(LayoutClass):
|
|||
.. note:: first added filter will be the default filter at the moment.
|
||||
|
||||
:seealso: :py:func:`~efl.elementary.need.need_efreet`
|
||||
:seealso: :py:meth:`custom_filter_append`
|
||||
:seealso: :py:meth:`filters_clear`
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
@ -437,6 +449,36 @@ cdef class Fileselector(LayoutClass):
|
|||
<const_char *>filter_name if filter_name is not None else NULL):
|
||||
raise RuntimeWarning
|
||||
|
||||
def custom_filter_append(self, func, data=None, filter_name=None):
|
||||
"""custom_filter_append(func, data=None, filter_name=None)
|
||||
|
||||
Append custom filter into filter list.
|
||||
|
||||
:param func: The function to call when manipulating files and directories.
|
||||
:type func: callable
|
||||
:param data: The data to be passed to the function.
|
||||
:param filter_name: The name to be displayed, "custom" will be displayed if None
|
||||
:type filter_name: string
|
||||
|
||||
.. note:: filter function signature is: func(path, is_dir, data)
|
||||
.. note:: first added filter will be the default filter at the moment.
|
||||
|
||||
:seealso: :py:meth:`mime_types_filter_append`
|
||||
:seealso: :py:meth:`filters_clear`
|
||||
|
||||
.. versionadded:: 1.9
|
||||
|
||||
"""
|
||||
cb_data = (func, data)
|
||||
# TODO: This is now a ref leak. It should be stored somewhere and
|
||||
# deleted in the remove method.
|
||||
Py_INCREF(cb_data)
|
||||
|
||||
if isinstance(filter_name, unicode): filter_name = PyUnicode_AsUTF8String(filter_name)
|
||||
elm_fileselector_custom_filter_append(self.obj,
|
||||
py_elm_fileselector_custom_filter_cb, <void *>cb_data,
|
||||
<const_char *>filter_name if filter_name is not None else NULL)
|
||||
|
||||
def filters_clear(self):
|
||||
"""
|
||||
|
||||
|
@ -478,6 +520,29 @@ cdef class Fileselector(LayoutClass):
|
|||
def hidden_visible_get(self):
|
||||
return bool(elm_fileselector_hidden_visible_get(self.obj))
|
||||
|
||||
property thumbnail_size:
|
||||
""" The size (in pixels) for the thumbnail images.
|
||||
|
||||
:type: tuple (w, h)
|
||||
|
||||
.. versionadded:: 1.9
|
||||
|
||||
"""
|
||||
def __set__(self, size):
|
||||
elm_fileselector_thumbnail_size_set(self.obj, size[0], size[1])
|
||||
|
||||
def __get__(self):
|
||||
cdef Evas_Coord w, h
|
||||
elm_fileselector_thumbnail_size_get(self.obj, &w, &h)
|
||||
return (w, h)
|
||||
|
||||
def thumbnail_size_set(self, w, h):
|
||||
elm_fileselector_thumbnail_size_set(self.obj, w, h)
|
||||
def thumbnail_size_get(self):
|
||||
cdef Evas_Coord w, h
|
||||
elm_fileselector_thumbnail_size_get(self.obj, &w, &h)
|
||||
return (w, h)
|
||||
|
||||
def callback_activated_add(self, func, *args, **kwargs):
|
||||
"""the user activated a file. This can happen by
|
||||
double-clicking or pressing Enter key. (**event_info** is a
|
||||
|
|
|
@ -186,8 +186,8 @@ items = [
|
|||
("Day Selector", "test_dayselector", "dayselector_clicked"),
|
||||
("Disk Selector", "test_diskselector", "diskselector_clicked"),
|
||||
("File Selector", "test_fileselector", "fileselector_clicked"),
|
||||
("Fileselector button", "test_fileselector", "fileselector_button_clicked"),
|
||||
("Fileselector entry", "test_fileselector", "fileselector_entry_clicked"),
|
||||
("Fileselector button", "test_fileselector_button", "fileselector_button_clicked"),
|
||||
("Fileselector entry", "test_fileselector_entry", "fileselector_entry_clicked"),
|
||||
("Flip Selector", "test_flipselector", "flipselector_clicked"),
|
||||
("Hoversel", "test_hoversel", "hoversel_clicked"),
|
||||
("Index", "test_index", "index_clicked"),
|
||||
|
|
|
@ -6,20 +6,27 @@ import os
|
|||
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||
from efl import elementary
|
||||
from efl.elementary.window import StandardWindow
|
||||
from efl.elementary.box import Box
|
||||
from efl.elementary.box import Box, ELM_BOX_LAYOUT_FLOW_HORIZONTAL
|
||||
from efl.elementary.frame import Frame
|
||||
from efl.elementary.label import Label
|
||||
from efl.elementary.button import Button
|
||||
from efl.elementary.check import Check
|
||||
from efl.elementary.list import List
|
||||
from efl.elementary.fileselector import Fileselector, ELM_FILESELECTOR_SORT_LAST
|
||||
from efl.elementary.fileselector_button import FileselectorButton
|
||||
from efl.elementary.fileselector_entry import FileselectorEntry
|
||||
from efl.elementary.hoversel import Hoversel
|
||||
from efl.elementary.radio import Radio
|
||||
from efl.elementary.slider import Slider
|
||||
from efl.elementary.separator import Separator
|
||||
from efl.elementary.fileselector import Fileselector, \
|
||||
ELM_FILESELECTOR_SORT_LAST, ELM_FILESELECTOR_LIST, ELM_FILESELECTOR_GRID, \
|
||||
ELM_FILESELECTOR_SORT_BY_FILENAME_ASC, ELM_FILESELECTOR_SORT_BY_FILENAME_DESC, \
|
||||
ELM_FILESELECTOR_SORT_BY_TYPE_ASC, ELM_FILESELECTOR_SORT_BY_TYPE_DESC, \
|
||||
ELM_FILESELECTOR_SORT_BY_SIZE_ASC, ELM_FILESELECTOR_SORT_BY_SIZE_DESC, \
|
||||
ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC, ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC
|
||||
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||
|
||||
|
||||
def fs_cb_done(fs, selected, win):
|
||||
win.delete()
|
||||
|
||||
|
@ -46,241 +53,203 @@ def ck_cb_buttons(bt, fs):
|
|||
print("Toggle buttons_ok_cancel")
|
||||
fs.buttons_ok_cancel = not fs.buttons_ok_cancel
|
||||
|
||||
def ck_cb_multi_select(bt, fs):
|
||||
print("Toggle multi_select")
|
||||
fs.multi_select = not fs.multi_select
|
||||
|
||||
def ck_cb_hidden(bt, fs):
|
||||
print("Toggle hidden_visible")
|
||||
fs.hidden_visible = not fs.hidden_visible
|
||||
|
||||
def bt_cb_sel_get(bt, fs):
|
||||
print("Get Selected:" + fs.selected_get())
|
||||
print("Get Selected:" + fs.selected)
|
||||
|
||||
def bt_cb_path_get(bt, fs):
|
||||
print("Get Path:" + fs.path_get())
|
||||
print("Get Path:" + fs.path)
|
||||
|
||||
def bt_cb_mode_cycle(bt, fs):
|
||||
mode = fs.mode + 1
|
||||
fs.mode_set(mode if mode < 2 else 0)
|
||||
def bt_cb_paths_get(bt, fs):
|
||||
print("Get Path:" + str(fs.selected_paths))
|
||||
|
||||
def bt_cb_sort_cycle(bt, fs):
|
||||
sort_method = fs.sort_method + 1
|
||||
fs.sort_method = sort_method if sort_method < ELM_FILESELECTOR_SORT_LAST else 0
|
||||
def rd_cb_mode(rd, fs):
|
||||
mode = rd.value
|
||||
fs.mode_set(mode)
|
||||
|
||||
def sl_cb_thumb_size(sl, fs):
|
||||
val = int(sl.value)
|
||||
fs.thumbnail_size = (val, val)
|
||||
|
||||
def hs_cb_sort_method(hs, item, fs, method):
|
||||
fs.sort_method = method
|
||||
|
||||
def custom_filter_all(path, is_dir, data):
|
||||
return True
|
||||
|
||||
def custom_filter_edje(path, is_dir, data):
|
||||
if is_dir or path.endswith(".edc") or path.endswith(".edj"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def fileselector_clicked(obj, item=None):
|
||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
||||
size=(240,350))
|
||||
win = StandardWindow("fileselector", "File selector test",
|
||||
autodel=True, size=(500,500))
|
||||
|
||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(vbox)
|
||||
vbox.show()
|
||||
box1 = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(box1)
|
||||
box1.show()
|
||||
|
||||
fs = Fileselector(win, is_save=True, expandable=True, folder_only=True,
|
||||
fs = Fileselector(win, is_save=True, expandable=False, folder_only=False,
|
||||
path=os.getenv("HOME"), size_hint_weight=EXPAND_BOTH,
|
||||
size_hint_align=FILL_BOTH)
|
||||
fs.callback_done_add(fs_cb_done, win)
|
||||
fs.callback_selected_add(fs_cb_selected, win)
|
||||
fs.callback_directory_open_add(fs_cb_directory_open, win)
|
||||
vbox.pack_end(fs)
|
||||
box1.pack_end(fs)
|
||||
fs.show()
|
||||
|
||||
sep = Separator(win, horizontal=True)
|
||||
vbox.pack_end(sep)
|
||||
fs.custom_filter_append(custom_filter_all, filter_name="All Files")
|
||||
fs.custom_filter_append(custom_filter_edje, filter_name="Edje Files")
|
||||
fs.mime_types_filter_append(["text/*"], "Text Files")
|
||||
fs.mime_types_filter_append(["image/*"], "Image Files")
|
||||
|
||||
|
||||
sep = Separator(win)
|
||||
box1.pack_end(sep)
|
||||
sep.show()
|
||||
|
||||
hbox = Box(win, horizontal=True)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
vbox = Box(win)
|
||||
box1.pack_end(vbox)
|
||||
vbox.show()
|
||||
|
||||
# Options frame
|
||||
fr = Frame(win, text="Options")
|
||||
vbox.pack_end(fr)
|
||||
fr.show()
|
||||
|
||||
fbox1 = Box(win)
|
||||
fr.content = fbox1
|
||||
fbox1.show()
|
||||
|
||||
fbox2 = Box(win, horizontal=True)
|
||||
fbox1.pack_end(fbox2)
|
||||
fbox2.show()
|
||||
|
||||
ck = Check(win, text="is_save", state=fs.is_save)
|
||||
ck.callback_changed_add(ck_cb_is_save, fs)
|
||||
hbox.pack_end(ck)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="folder_only", state=fs.folder_only)
|
||||
ck.callback_changed_add(ck_cb_folder_only, fs)
|
||||
hbox.pack_end(ck)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="expandable", state=fs.expandable)
|
||||
ck.callback_changed_add(ck_cb_expandable, fs)
|
||||
hbox.pack_end(ck)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
fbox2 = Box(win, horizontal=True)
|
||||
fbox1.pack_end(fbox2)
|
||||
fbox2.show()
|
||||
|
||||
ck = Check(win, text="multiple selection", state=fs. multi_select)
|
||||
ck.callback_changed_add(ck_cb_multi_select, fs)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="buttons", state=fs.buttons_ok_cancel)
|
||||
ck.callback_changed_add(ck_cb_buttons, fs)
|
||||
hbox.pack_end(ck)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="hidden", state=fs.hidden_visible)
|
||||
ck.callback_changed_add(ck_cb_hidden, fs)
|
||||
hbox.pack_end(ck)
|
||||
fbox2.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
hbox = Box(win, horizontal=True)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
# Getters frame
|
||||
fr = Frame(win, text="Getters", size_hint_align=FILL_BOTH)
|
||||
vbox.pack_end(fr)
|
||||
fr.show()
|
||||
|
||||
fbox = Box(win, horizontal=True)
|
||||
fr.content = fbox
|
||||
fbox.show()
|
||||
|
||||
bt = Button(win, text="selected_get")
|
||||
bt.callback_clicked_add(bt_cb_sel_get, fs)
|
||||
hbox.pack_end(bt)
|
||||
fbox.pack_end(bt)
|
||||
bt.show()
|
||||
|
||||
bt = Button(win, text="path_get")
|
||||
bt.callback_clicked_add(bt_cb_path_get, fs)
|
||||
hbox.pack_end(bt)
|
||||
fbox.pack_end(bt)
|
||||
bt.show()
|
||||
|
||||
bt = Button(win, text="mode cycle")
|
||||
bt.callback_clicked_add(bt_cb_mode_cycle, fs)
|
||||
hbox.pack_end(bt)
|
||||
bt = Button(win, text="selected_paths")
|
||||
bt.callback_clicked_add(bt_cb_paths_get, fs)
|
||||
fbox.pack_end(bt)
|
||||
bt.show()
|
||||
|
||||
bt = Button(win, text="sort_method cycle")
|
||||
bt.callback_clicked_add(bt_cb_sort_cycle, fs)
|
||||
hbox.pack_end(bt)
|
||||
bt.show()
|
||||
# Mode frame
|
||||
fr = Frame(win, text="Mode", size_hint_align=FILL_BOTH)
|
||||
vbox.pack_end(fr)
|
||||
fr.show()
|
||||
|
||||
win.resize(240, 350)
|
||||
win.show()
|
||||
fbox = Box(win, horizontal=True)
|
||||
fr.content = fbox
|
||||
fbox.show()
|
||||
|
||||
rdg = rd = Radio(win, text="List", state_value=ELM_FILESELECTOR_LIST)
|
||||
rd.callback_changed_add(rd_cb_mode, fs)
|
||||
fbox.pack_end(rd)
|
||||
rd.show()
|
||||
|
||||
def fileselector_button_clicked(obj, item=None):
|
||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
||||
size=(240, 350))
|
||||
rd = Radio(win, text="Grid", state_value=ELM_FILESELECTOR_GRID)
|
||||
rd.callback_changed_add(rd_cb_mode, fs)
|
||||
rd.group_add(rdg)
|
||||
fbox.pack_end(rd)
|
||||
rd.show()
|
||||
|
||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(vbox)
|
||||
vbox.show()
|
||||
# Thumbsize frame
|
||||
fr = Frame(win, text="Thumbnail size", size_hint_align=FILL_BOTH)
|
||||
vbox.pack_end(fr)
|
||||
fr.show()
|
||||
|
||||
fse = FileselectorButton(win, text="Select a file", inwin_mode=False,
|
||||
size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(fse)
|
||||
fse.show()
|
||||
sl = Slider(win, min_max=(4, 130), unit_format="%.0f px",
|
||||
value=fs.thumbnail_size[0])
|
||||
sl.callback_delay_changed_add(sl_cb_thumb_size, fs)
|
||||
fr.content = sl
|
||||
sl.show()
|
||||
|
||||
sep = Separator(win, horizontal=True)
|
||||
vbox.pack_end(sep)
|
||||
sep.show()
|
||||
# Sort method frame
|
||||
fr = Frame(win, text="Sort method", size_hint_align=FILL_BOTH)
|
||||
vbox.pack_end(fr)
|
||||
fr.show()
|
||||
|
||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
|
||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||
ck.callback_changed_add(ck_entry_cb_inwin, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||
ck.callback_changed_add(ck_entry_cb_folder_only, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="is_save", state=fse.is_save)
|
||||
ck.callback_changed_add(ck_entry_cb_is_save, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="expandable", state=fse.expandable)
|
||||
ck.callback_changed_add(ck_entry_cb_expandable, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
win.show()
|
||||
|
||||
|
||||
def ck_entry_cb_is_save(bt, fse):
|
||||
print("Toggle is save")
|
||||
fse.is_save = not fse.is_save
|
||||
|
||||
def ck_entry_cb_inwin(bt, fse):
|
||||
print("Toggle inwin mode")
|
||||
fse.inwin_mode = not fse.inwin_mode
|
||||
|
||||
def ck_entry_cb_folder_only(bt, fse):
|
||||
print("Toggle folder_only")
|
||||
fse.folder_only = not fse.folder_only
|
||||
|
||||
def ck_entry_cb_expandable(bt, fse):
|
||||
print("Toggle expandable")
|
||||
fse.expandable = not fse.expandable
|
||||
|
||||
|
||||
def fileselector_entry_clicked(obj, item=None):
|
||||
win = StandardWindow("fileselector", "File selector test", autodel=True,
|
||||
size=(240, 150))
|
||||
|
||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(vbox)
|
||||
vbox.show()
|
||||
|
||||
fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
|
||||
size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(fse)
|
||||
fse.show()
|
||||
|
||||
sep = Separator(win, horizontal=True)
|
||||
vbox.pack_end(sep)
|
||||
sep.show()
|
||||
|
||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
|
||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||
ck.callback_changed_add(ck_entry_cb_inwin, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||
ck.callback_changed_add(ck_entry_cb_folder_only, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="is_save", state=fse.is_save)
|
||||
ck.callback_changed_add(ck_entry_cb_is_save, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="expandable", state=fse.expandable)
|
||||
ck.callback_changed_add(ck_entry_cb_expandable, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
hs = Hoversel(win, text="File name (asc)")
|
||||
sorts = (
|
||||
("File name (asc)", ELM_FILESELECTOR_SORT_BY_FILENAME_ASC),
|
||||
("File name (desc)", ELM_FILESELECTOR_SORT_BY_FILENAME_DESC),
|
||||
("Type (asc)", ELM_FILESELECTOR_SORT_BY_TYPE_ASC),
|
||||
("Type (desc)", ELM_FILESELECTOR_SORT_BY_TYPE_DESC),
|
||||
("Size (asc)", ELM_FILESELECTOR_SORT_BY_SIZE_ASC),
|
||||
("Size (desc)", ELM_FILESELECTOR_SORT_BY_SIZE_DESC),
|
||||
("Modified time (asc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_ASC),
|
||||
("Modified time (desc)", ELM_FILESELECTOR_SORT_BY_MODIFIED_DESC),
|
||||
)
|
||||
for sort in sorts:
|
||||
hs.item_add(label=sort[0], callback=hs_cb_sort_method, fs=fs, method=sort[1])
|
||||
fr.content = hs
|
||||
hs.show()
|
||||
|
||||
win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
elementary.init()
|
||||
win = StandardWindow("test", "python-elementary test application",
|
||||
size=(320,520))
|
||||
win.callback_delete_request_add(lambda o: elementary.exit())
|
||||
|
||||
box0 = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(box0)
|
||||
box0.show()
|
||||
fileselector_clicked(None)
|
||||
|
||||
lb = Label(win)
|
||||
lb.text_set("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 = [("Fileselector", fileselector_clicked),
|
||||
("Fileselector Button", fileselector_button_clicked),
|
||||
("Fileselector Entry", fileselector_entry_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])
|
||||
|
||||
li.go()
|
||||
|
||||
win.show()
|
||||
elementary.run()
|
||||
elementary.shutdown()
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||
from efl import elementary
|
||||
from efl.elementary.window import StandardWindow
|
||||
from efl.elementary.box import Box
|
||||
from efl.elementary.check import Check
|
||||
from efl.elementary.fileselector_button import FileselectorButton
|
||||
from efl.elementary.separator import Separator
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||
|
||||
def toggle_is_save(bt, fsb):
|
||||
print("Toggle is save")
|
||||
fsb.is_save = not fsb.is_save
|
||||
|
||||
def toggle_inwin(bt, fsb):
|
||||
print("Toggle inwin mode")
|
||||
fsb.inwin_mode = not fsb.inwin_mode
|
||||
|
||||
def toggle_folder_only(bt, fsb):
|
||||
print("Toggle folder_only")
|
||||
fsb.folder_only = not fsb.folder_only
|
||||
|
||||
def toggle_expandable(bt, fsb):
|
||||
print("Toggle expandable")
|
||||
fsb.expandable = not fsb.expandable
|
||||
|
||||
def fileselector_button_clicked(obj, item=None):
|
||||
win = StandardWindow("fileselector", "File selector test",
|
||||
autodel=True, size=(240, 350))
|
||||
|
||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(vbox)
|
||||
vbox.show()
|
||||
|
||||
fse = FileselectorButton(win, text="Select a file", inwin_mode=False,
|
||||
size_hint_align=FILL_BOTH,
|
||||
size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(fse)
|
||||
fse.show()
|
||||
|
||||
sep = Separator(win, horizontal=True)
|
||||
vbox.pack_end(sep)
|
||||
sep.show()
|
||||
|
||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
|
||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||
ck.callback_changed_add(toggle_inwin, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||
ck.callback_changed_add(toggle_folder_only, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="is_save", state=fse.is_save)
|
||||
ck.callback_changed_add(toggle_is_save, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="expandable", state=fse.expandable)
|
||||
ck.callback_changed_add(toggle_expandable, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
elementary.init()
|
||||
|
||||
fileselector_button_clicked(None)
|
||||
|
||||
elementary.run()
|
||||
elementary.shutdown()
|
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||
from efl import elementary
|
||||
from efl.elementary.window import StandardWindow
|
||||
from efl.elementary.box import Box
|
||||
from efl.elementary.check import Check
|
||||
from efl.elementary.fileselector_entry import FileselectorEntry
|
||||
from efl.elementary.separator import Separator
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||
|
||||
|
||||
def toggle_is_save(bt, fse):
|
||||
print("Toggle is save")
|
||||
fse.is_save = not fse.is_save
|
||||
|
||||
def toggle_inwin(bt, fse):
|
||||
print("Toggle inwin mode")
|
||||
fse.inwin_mode = not fse.inwin_mode
|
||||
|
||||
def toggle_folder_only(bt, fse):
|
||||
print("Toggle folder_only")
|
||||
fse.folder_only = not fse.folder_only
|
||||
|
||||
def toggle_expandable(bt, fse):
|
||||
print("Toggle expandable")
|
||||
fse.expandable = not fse.expandable
|
||||
|
||||
|
||||
def fileselector_entry_clicked(obj, item=None):
|
||||
win = StandardWindow("fileselector", "File selector test",
|
||||
autodel=True, size=(240, 150))
|
||||
|
||||
vbox = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(vbox)
|
||||
vbox.show()
|
||||
|
||||
fse = FileselectorEntry(win, text="Select a file", inwin_mode=False,
|
||||
size_hint_align=FILL_BOTH,
|
||||
size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(fse)
|
||||
fse.show()
|
||||
|
||||
sep = Separator(win, horizontal=True)
|
||||
vbox.pack_end(sep)
|
||||
sep.show()
|
||||
|
||||
hbox = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
|
||||
vbox.pack_end(hbox)
|
||||
hbox.show()
|
||||
|
||||
ck = Check(win, text="inwin", state=fse.inwin_mode)
|
||||
ck.callback_changed_add(toggle_inwin, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="folder_only", state=fse.folder_only)
|
||||
ck.callback_changed_add(toggle_folder_only, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="is_save", state=fse.is_save)
|
||||
ck.callback_changed_add(toggle_is_save, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
ck = Check(win, text="expandable", state=fse.expandable)
|
||||
ck.callback_changed_add(toggle_expandable, fse)
|
||||
hbox.pack_end(ck)
|
||||
ck.show()
|
||||
|
||||
win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
elementary.init()
|
||||
|
||||
fileselector_entry_clicked(None)
|
||||
|
||||
elementary.run()
|
||||
elementary.shutdown()
|
Loading…
Reference in New Issue