-
Notifications
You must be signed in to change notification settings - Fork 0
/
treeview_demo.py
executable file
·76 lines (63 loc) · 2.52 KB
/
treeview_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2011 ~ 2012 Deepin, Inc.
# 2011 ~ 2012 Wang Yong
#
# Author: Wang Yong <lazycat.manatee@gmail.com>
# Maintainer: Wang Yong <lazycat.manatee@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
import os
app_theme = init_skin(
"deepin-ui-demo",
"1.0",
"01",
os.path.join(get_parent_dir(__file__), "skin"),
os.path.join(get_parent_dir(__file__), "app_theme"),
)
from dtk.ui.application import Application
from dtk.ui.new_treeview import TreeView
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT
from dtk.ui.file_treeview import (get_dir_items, sort_by_name, sort_by_size,
sort_by_type, sort_by_mtime)
import gtk
if __name__ == "__main__":
# Init application.
application = Application()
# Set application default size.
application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)
# Set application icon.
application.set_icon(app_theme.get_pixbuf("icon.ico"))
# Set application preview pixbuf.
application.set_skin_preview(app_theme.get_pixbuf("frame.png"))
# Add titlebar.
application.add_titlebar(
["theme", "max", "min", "close"],
app_theme.get_pixbuf("logo.png"),
"TreeView demo",
"TreeView demo",
)
# Add TreeView.
treeview = TreeView(get_dir_items(os.path.expanduser("~")))
# treeview = TreeView(get_dir_items("/"))
treeview_align = gtk.Alignment()
treeview_align.set(0.5, 0.5, 1, 1)
treeview_align.set_padding(0, 2, 2, 2)
treeview.set_column_titles(["文件名", "大小", "类型", "修改时间"],
[sort_by_name, sort_by_size, sort_by_type, sort_by_mtime])
treeview_align.add(treeview)
application.main_box.pack_start(treeview_align)
application.run()