本文整理汇总了Python中wx.ImageList方法的典型用法代码示例。如果您正苦于以下问题:Python wx.ImageList方法的具体用法?Python wx.ImageList怎么用?Python wx.ImageList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.ImageList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, w, h):
wx.ImageList.__init__(self, w, h)
self.list={}
data=["%d %d 1 1" % (w,h), " c None"]
empty=""
for _i in range(w):
empty += " "
for _i in range(h):
data.append(empty)
self.Add(wx.BitmapFromXPMData(data))
self.list['']=0
data=["%d %d 1 1" % (w,h), " c #FFFFFF"]
empty=""
for _i in range(w):
empty += " "
for _i in range(h):
data.append(empty)
self.Add(wx.BitmapFromXPMData(data))
self.list['white']=1
示例2: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self,
parent,
ID=wx.NewId(),
pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=0,
clientpanel=None):
"""Constructor. Initializes a smartcard or reader tree control."""
wx.TreeCtrl.__init__(
self, parent, ID, pos, size, wx.TR_SINGLE | wx.TR_NO_BUTTONS)
self.clientpanel = clientpanel
self.parent = parent
isz = (16, 16)
il = wx.ImageList(isz[0], isz[1])
self.capindex = il.Add(
wx.ArtProvider_GetBitmap(wx.ART_HELP_BOOK, wx.ART_OTHER, isz))
self.fldrindex = il.Add(
wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz))
self.fldropenindex = il.Add(
wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz))
if None != ICO_SMARTCARD:
self.cardimageindex = il.Add(
wx.Bitmap(ICO_SMARTCARD, wx.BITMAP_TYPE_ICO))
if None != ICO_READER:
self.readerimageindex = il.Add(
wx.Bitmap(ICO_READER, wx.BITMAP_TYPE_ICO))
self.il = il
self.SetImageList(self.il)
示例3: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, wx.ID_ANY, style=wx.LC_REPORT)
ContextMenuMixin.__init__(self)
self.il = wx.ImageList(self.icon_size, self.icon_size)
# TODO: use a real icon
self.il.Add(self.draw_blank())
self.il.Add(self.draw_sort_arrow('up'))
self.il.Add(self.draw_sort_arrow('down'))
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
self.update_enabled_columns()
for i, name in enumerate(self.enabled_columns):
column = self.columns[name]
column.SetColumn(i)
self.InsertColumnItem(i, column)
self.itemData_to_row = {}
self.index_to_itemData = {}
self.selected_column = None
self.SelectColumn(self.enabled_columns[0])
cmenu = wx.Menu()
for name in self.column_order:
column = self.columns[name]
id = wx.NewId()
cmenu.AppendCheckItem(id, column.GetText())
cmenu.Check(id, column.enabled)
self.Bind(wx.EVT_MENU,
lambda e, c=column, id=id: self.toggle_column(c, id, e),
id=id)
self.SetColumnContextMenu(cmenu)
ColumnSorterMixin.__init__(self, len(self.enabled_columns))
self._last_scrollpos = 0
if sys.platform != "darwin":
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.default_rect = wx.Rect(0,0)
示例4: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, application):
style = wx.TR_DEFAULT_STYLE|wx.TR_HAS_VARIABLE_ROW_HEIGHT
style |= wx.TR_EDIT_LABELS
if wx.Platform == '__WXGTK__': style |= wx.TR_NO_LINES|wx.TR_FULL_ROW_HIGHLIGHT
elif wx.Platform == '__WXMAC__': style &= ~wx.TR_ROW_LINES
wx.TreeCtrl.__init__(self, parent, -1, style=style)
self.cur_widget = None # reference to the selected widget
self.root = application
image_list = wx.ImageList(21, 21)
image_list.Add(wx.Bitmap(os.path.join(config.icons_path, 'application.xpm'), wx.BITMAP_TYPE_XPM))
for w in WidgetTree.images:
WidgetTree.images[w] = image_list.Add(misc.get_xpm_bitmap(WidgetTree.images[w]))
self.AssignImageList(image_list)
application.item = self.AddRoot(_('Application'), 0)
self._SetItemData(application.item, application)
self.skip_select = 0 # avoid an infinite loop on win32, as SelectItem fires an EVT_TREE_SEL_CHANGED event
self.drop_target = clipboard.DropTarget(self, toplevel=True)
self.SetDropTarget(self.drop_target)
self._drag_ongoing = False
self.auto_expand = True # this control the automatic expansion of nodes: it is set to False during xml loading
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_change_selection)
self.Bind(wx.EVT_RIGHT_DOWN, self.popup_menu)
self.Bind(wx.EVT_LEFT_DCLICK, self.on_left_dclick)
self.Bind(wx.EVT_LEFT_DOWN, self.on_left_click) # allow direct placement of widgets
self.Bind(wx.EVT_MENU, self.on_menu) # for handling the selection of the first item
self._popup_menu_widget = None # the widget for the popup menu
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.begin_drag)
self.Bind(wx.EVT_LEAVE_WINDOW, self.on_leave_window)
self.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_events)
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.begin_edit_label)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.end_edit_label)
#self.Bind(wx.EVT_KEY_DOWN, misc.on_key_down_event)
self.Bind(wx.EVT_KEY_DOWN, self.on_key_down_event)
#self.Bind(wx.EVT_CHAR_HOOK, self.on_char) # on wx 2.8 the event will not be delivered to the child
self.Bind(wx.EVT_TREE_DELETE_ITEM, self.on_delete_item)
示例5: _GetDisabledIndex
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def _GetDisabledIndex(self):
"""
Creates a version of the icon with a "disabled" mark overlayed and
returns its index inside the global wx.ImageList.
"""
image = self.pil.copy()
image.paste(DISABLED_PIL, None, DISABLED_PIL)
return gImageList.Add(PilToBitmap(image))
示例6: _GetFolderIndex
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def _GetFolderIndex(self):
"""
Creates a folder icon with a small version of the icon overlayed and
returns its index inside the global wx.ImageList.
"""
small = self.pil.resize((12, 12), Image.BICUBIC)
image = FOLDER_PIL.copy()
image.paste(small, (4, 4), small)
return gImageList.Add(PilToBitmap(image))
示例7: _GetIndex
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def _GetIndex(self):
"""
Return the index of this icon inside the global wx.ImageList.
"""
return gImageList.Add(PilToBitmap(self.pil))
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, hwnds):
wx.ListCtrl.__init__(self, parent, style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
listmix.ListCtrlAutoWidthMixin.__init__(self)
imageList = wx.ImageList(16, 16)
imageList.Add(GetInternalBitmap("cwindow"))
self.AssignImageList(imageList, wx.IMAGE_LIST_SMALL)
self.InsertColumn(0, "Program")
self.InsertColumn(1, "Name")
self.InsertColumn(2, "Class")
self.InsertColumn(3, "Handle", wx.LIST_FORMAT_RIGHT)
for hwnd in hwnds:
imageIdx = 0
icon = GetHwndIcon(hwnd)
if icon:
imageIdx = imageList.AddIcon(icon)
idx = self.InsertImageStringItem(
sys.maxint,
GetWindowProcessName(hwnd),
imageIdx
)
self.SetStringItem(idx, 1, GetWindowText(hwnd))
self.SetStringItem(idx, 2, GetClassName(hwnd))
self.SetStringItem(idx, 3, str(hwnd))
for i in range(4):
self.SetColumnWidth(i, -2)
headerSize = self.GetColumnWidth(i)
self.SetColumnWidth(i, -1)
labelSize = self.GetColumnWidth(i)
if headerSize > labelSize:
self.SetColumnWidth(i, headerSize)
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, includeInvisible=False):
self.includeInvisible = includeInvisible
self.pids = {}
wx.TreeCtrl.__init__(
self,
parent,
-1,
style=(
wx.TR_DEFAULT_STYLE |
wx.TR_HIDE_ROOT |
wx.TR_FULL_ROW_HIGHLIGHT
),
size=(-1, 150)
)
self.imageList = imageList = wx.ImageList(16, 16)
imageList.Add(GetInternalBitmap("cwindow"))
imageList.Add(GetInternalBitmap("cedit"))
imageList.Add(GetInternalBitmap("cstatic"))
imageList.Add(GetInternalBitmap("cbutton"))
self.SetImageList(imageList)
self.root = self.AddRoot("")
# tree context menu
def OnCmdHighlight(dummyEvent=None):
hwnd = self.GetPyData(self.GetSelection())
for _ in range(10):
HighlightWindow(hwnd)
sleep(0.1)
menu = wx.Menu()
menuId = wx.NewId()
menu.Append(menuId, "Highlight")
self.Bind(wx.EVT_MENU, OnCmdHighlight, id=menuId)
self.contextMenu = menu
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnItemRightClick)
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding)
self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed)
self.AppendPrograms()
示例10: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, window):
wx.Panel.__init__(self, id=ID_SEARCHRESULTPANEL,
name='SearchResultPanel', parent=parent,
pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
self.ParentWindow = window
self._init_ctrls(parent)
# Define Tree item icon list
self.TreeImageList = wx.ImageList(16, 16)
self.TreeImageDict = {}
# Icons for other items
for imgname, itemtype in [
# editables
("PROJECT", ITEM_PROJECT),
("TRANSITION", ITEM_TRANSITION),
("ACTION", ITEM_ACTION),
("CONFIGURATION", ITEM_CONFIGURATION),
("RESOURCE", ITEM_RESOURCE),
("DATATYPE", ITEM_DATATYPE),
("ACTION", "action_block"),
("IL", "IL"),
("ST", "ST"),
("FILE", ITEM_CONFNODE)]:
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))
for itemtype in ["function", "functionBlock", "program",
"comment", "block", "io_variable",
"connector", "contact", "coil",
"step", "transition", "jump",
"var_local", "var_input",
"var_inout", "var_output"]:
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(itemtype.upper()))
# Assign icon list to TreeCtrl
self.SearchResultsTree.SetImageList(self.TreeImageList)
self.ResetSearchResults()
示例11: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, imageList=None, imageSize=16):
"""
"""
self.imageList = imageList or wx.ImageList(imageSize, imageSize)
self.imageSize = imageSize
self.nameToImageIndexMap = {}
示例12: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, torrent):
self.torrent = torrent
TreeListCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_MULTIPLE|wx.WS_EX_PROCESS_IDLE)
size = (16,16)
il = wx.ImageList(*size)
self.folder_index = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, size))
self.folder_open_index = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, size))
self.file_index = il.Add(wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, size))
self.SetImageList(il)
self.il = il
self.path_items = {}
self.AddColumn(_("Name" ))
self.AddColumn(_("Size" ))
self.AddColumn(_("%" ))
self.AddColumn(_("Download"))
self.SetMainColumn(0)
metainfo = self.torrent.metainfo
self.root = self.AddRoot(metainfo.name)
self.SetItemImage(self.root, self.folder_index , which=wx.TreeItemIcon_Normal )
self.SetItemImage(self.root, self.folder_open_index, which=wx.TreeItemIcon_Expanded)
dc = wx.ClientDC(self)
for c, t in enumerate(self.sample_row):
w, h = dc.GetTextExtent(t)
self.SetColumnWidth(c, w+2)
if metainfo.is_batch:
files = metainfo.orig_files
else:
files = [ ]
for i, f in enumerate(files):
path, filename = os.path.split(f)
parent = self.find_path(path, self.root)
child = self.AppendItem(parent, filename)
self.Expand(parent)
self.path_items[f] = child
self.SetItemText(child, unicode(Size(metainfo.sizes[i])), 1)
self.SetItemText(child, '?', 2)
self.SetItemData(child, wx.TreeItemData(f))
self.SetItemImage(child, self.file_index, which=wx.TreeItemIcon_Normal)
self.EnsureVisible(self.root)
self.Refresh()
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnPopupMenu)
示例13: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, id, log):
wx.Notebook.__init__(self, parent, id, size=(21,21), style=
wx.BK_DEFAULT
#wx.BK_TOP
#wx.BK_BOTTOM
#wx.BK_LEFT
#wx.BK_RIGHT
# | wx.NB_MULTILINE
)
self.log = log
win = self.makeColorPanel(wx.BLUE)
self.AddPage(win, "Blue")
st = wx.StaticText(win.win, -1,
"You can put nearly any type of window here,\n"
"and if the platform supports it then the\n"
"tabs can be on any side of the notebook.",
(10, 10))
st.SetForegroundColour(wx.WHITE)
st.SetBackgroundColour(wx.BLUE)
# Show how to put an image on one of the notebook tabs,
# first make the image list:
il = wx.ImageList(16, 16)
idx1 = il.Add(images.getSmilesBitmap())
self.AssignImageList(il)
# now put an image on the first tab we just created:
self.SetPageImage(0, idx1)
win = self.makeColorPanel(wx.RED)
self.AddPage(win, "Red")
win = ScrolledWindow.MyCanvas(self)
self.AddPage(win, 'ScrolledWindow')
win = self.makeColorPanel(wx.GREEN)
self.AddPage(win, "Green")
win = GridSimple.SimpleGrid(self, log)
self.AddPage(win, "Grid")
win = ListCtrl.TestListCtrlPanel(self, log)
self.AddPage(win, 'List')
win = self.makeColorPanel(wx.CYAN)
self.AddPage(win, "Cyan")
win = self.makeColorPanel(wx.NamedColour('Midnight Blue'))
self.AddPage(win, "Midnight Blue")
win = self.makeColorPanel(wx.NamedColour('Indian Red'))
self.AddPage(win, "Indian Red")
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
示例14: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(
self,
parent,
id=-1,
key = _winreg.HKEY_CURRENT_USER,
subkey = "Software",
valueName = None,
pos = wx.DefaultPosition,
size = wx.DefaultSize,
style = wx.TR_HAS_BUTTONS,
validator = wx.DefaultValidator,
name="RegistryLazyTree",
text = None
):
self.text = text
wx.TreeCtrl.__init__(
self, parent, id, pos, size, style, validator, name
)
self.imageList = imageList = wx.ImageList(16, 16)
rootIcon = imageList.Add(eg.Icons.GetInternalBitmap("root"))
self.folderIcon = imageList.Add(eg.Icons.GetInternalBitmap("folder"))
self.valueIcon = imageList.Add(eg.Icons.GetInternalBitmap("action"))
self.SetImageList(imageList)
self.SetMinSize((-1, 200))
self.treeRoot = self.AddRoot(
"Registry",
image = rootIcon,
data = wx.TreeItemData((True, None, None, None))
)
#Adding keys
for item in regKeys:
#a tupel of 4 values is assigned to every item
#1) stores if the key has yet to be queried for subkey, when
# selected
#2) _winreg.hkey constant
#3) name of the key
#4) value name, None if just a key, empty string for default value
tmp = self.AppendItem(
self.treeRoot,
item[1],
image = self.folderIcon,
data =wx.TreeItemData((False, item[0], "", None))
)
self.SetItemHasChildren(tmp, True)
if item[0] == key:
self.SelectItem(tmp)
#select old value in tree
self.OnTreeChange(wx.CommandEvent(), key, subkey, valueName)
self.EnsureVisible(self.GetSelection())
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeChange)
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnExpandNode)
示例15: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ImageList [as 别名]
def __init__(self, parent, folder, filter=None, editable=True):
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.Tree = wx.TreeCtrl(self,
style=(wx.TR_HAS_BUTTONS |
wx.TR_SINGLE |
wx.SUNKEN_BORDER |
wx.TR_HIDE_ROOT |
wx.TR_LINES_AT_ROOT |
wx.TR_EDIT_LABELS))
if wx.Platform == '__WXMSW__':
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnTreeItemExpanded, self.Tree)
self.Tree.Bind(wx.EVT_LEFT_DOWN, self.OnTreeLeftDown)
else:
self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnTreeItemExpanded, self.Tree)
self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnTreeItemCollapsed, self.Tree)
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnTreeBeginLabelEdit, self.Tree)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnTreeEndLabelEdit, self.Tree)
main_sizer.AddWindow(self.Tree, 1, flag=wx.GROW)
if filter is not None:
self.Filter = wx.ComboBox(self, style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnFilterChanged, self.Filter)
main_sizer.AddWindow(self.Filter, flag=wx.GROW)
else:
self.Filter = None
self.SetSizer(main_sizer)
self.Folder = folder
self.Editable = editable
self.TreeImageList = wx.ImageList(16, 16)
self.TreeImageDict = {}
for item_type, bitmap in [(DRIVE, "tree_drive"),
(FOLDER, "tree_folder"),
(FILE, "tree_file")]:
self.TreeImageDict[item_type] = self.TreeImageList.Add(GetBitmap(bitmap))
self.Tree.SetImageList(self.TreeImageList)
self.Filters = {}
if self.Filter is not None:
filter_parts = filter.split("|")
for idx in xrange(0, len(filter_parts), 2):
if filter_parts[idx + 1] == "*.*":
self.Filters[filter_parts[idx]] = ""
else:
self.Filters[filter_parts[idx]] = filter_parts[idx + 1].replace("*", "")
self.Filter.Append(filter_parts[idx])
if idx == 0:
self.Filter.SetStringSelection(filter_parts[idx])
self.CurrentFilter = self.Filters[self.Filter.GetStringSelection()]
else:
self.CurrentFilter = ""