Search Results

Search found 9 results on 1 pages for 'listctrl'.

Page 1/1 | 1 

  • Cannot format first column in WxPython's ListCtrl

    - by Matt Clarke
    If I set the format of the first column in a ListCtrl to align centre (or align right) nothing happens. It works for the other columns. This only happens on Windows - I have tested it on Linux and it works fine. Does anyone know if there is a work-round or other solution? Here is an example based on code found at http://zetcode.com/wxpython/ import wx import sys packages = [('jessica alba', 'pomona', '1981'), ('sigourney weaver', 'new york', '1949'), ('angelina jolie', 'los angeles', '1975'), ('natalie portman', 'jerusalem', '1981'), ('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new york', '1984' )] class Actresses(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(380, 230)) hbox = wx.BoxSizer(wx.HORIZONTAL) panel = wx.Panel(self, -1) self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT) self.list.InsertColumn(0, 'name', wx.LIST_FORMAT_CENTRE,width=140) self.list.InsertColumn(1, 'place', wx.LIST_FORMAT_CENTRE,width=130) self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_CENTRE, 90) for i in packages: index = self.list.InsertStringItem(sys.maxint, i[0]) self.list.SetStringItem(index, 1, i[1]) self.list.SetStringItem(index, 2, i[2]) hbox.Add(self.list, 1, wx.EXPAND) panel.SetSizer(hbox) self.Centre() self.Show(True) app = wx.App() Actresses(None, -1, 'actresses') app.MainLoop()

    Read the article

  • wxPython ListCtrl Column Ignores Specific Fields

    - by g.d.d.c
    I'm rewriting this post to clarify some things and provide a full class definition for the Virtual List I'm having trouble with. The class is defined like so: from wx import ListCtrl, LC_REPORT, LC_VIRTUAL, LC_HRULES, LC_VRULES, \ EVT_LIST_COL_CLICK, EVT_LIST_CACHE_HINT, EVT_LIST_COL_RIGHT_CLICK, \ ImageList, IMAGE_LIST_SMALL, Menu, MenuItem, NewId, ITEM_CHECK, Frame, \ EVT_MENU class VirtualList(ListCtrl): def __init__(self, parent, datasource = None, style = LC_REPORT | LC_VIRTUAL | LC_HRULES | LC_VRULES): ListCtrl.__init__(self, parent, style = style) self.columns = [] self.il = ImageList(16, 16) self.Bind(EVT_LIST_CACHE_HINT, self.CheckCache) self.Bind(EVT_LIST_COL_CLICK, self.OnSort) if datasource is not None: self.datasource = datasource self.Bind(EVT_LIST_COL_RIGHT_CLICK, self.ShowAvailableColumns) self.datasource.list = self self.Populate() def SetDatasource(self, datasource): self.datasource = datasource def CheckCache(self, event): self.datasource.UpdateCache(event.GetCacheFrom(), event.GetCacheTo()) def OnGetItemText(self, item, col): return self.datasource.GetItem(item, self.columns[col]) def OnGetItemImage(self, item): return self.datasource.GetImg(item) def OnSort(self, event): self.datasource.SortByColumn(self.columns[event.Column]) self.Refresh() def UpdateCount(self): self.SetItemCount(self.datasource.GetCount()) def Populate(self): self.UpdateCount() self.datasource.MakeImgList(self.il) self.SetImageList(self.il, IMAGE_LIST_SMALL) self.ShowColumns() def ShowColumns(self): for col, (text, visible) in enumerate(self.datasource.GetColumnHeaders()): if visible: self.columns.append(text) self.InsertColumn(col, text, width = -2) def Filter(self, filter): self.datasource.Filter(filter) self.UpdateCount() self.Refresh() def ShowAvailableColumns(self, evt): colMenu = Menu() self.id2item = {} for idx, (text, visible) in enumerate(self.datasource.columns): id = NewId() self.id2item[id] = (idx, visible, text) item = MenuItem(colMenu, id, text, kind = ITEM_CHECK) colMenu.AppendItem(item) EVT_MENU(colMenu, id, self.ColumnToggle) item.Check(visible) Frame(self, -1).PopupMenu(colMenu) colMenu.Destroy() def ColumnToggle(self, evt): toggled = self.id2item[evt.GetId()] if toggled[1]: idx = self.columns.index(toggled[2]) self.datasource.columns[toggled[0]] = (self.datasource.columns[toggled[0]][0], False) self.DeleteColumn(idx) self.columns.pop(idx) else: self.datasource.columns[toggled[0]] = (self.datasource.columns[toggled[0]][0], True) idx = self.datasource.GetColumnHeaders().index((toggled[2], True)) self.columns.insert(idx, toggled[2]) self.InsertColumn(idx, toggled[2], width = -2) self.datasource.SaveColumns() I've added functions that allow for Column Toggling which facilitate my description of the issue I'm encountering. On the 3rd instance of this class in my application the Column at Index 1 will not display String values. Integer values are displayed properly. If I add print statements to my OnGetItemText method the values show up in my console properly. This behavior is not present in the first two instances of this class, and my class does not contain any type checking code with respect to value display. It was suggested by someone on the wxPython users' group that I create a standalone sample that demonstrates this issue if I can. I'm working on that, but have not yet had time to create a sample that does not rely on database access. Any suggestions or advice would be most appreciated. I'm tearing my hair out on this one.

    Read the article

  • wxPython - Save Items in ListCtrl

    - by dpswt
    Hello everyone. My question is if we can save the items on ListCtrl so everytime someone opens the application, the items are there and if the user removes it, it also removes from the configuration. I know that I can use wx.Config and I'm trying to accomplish using that but I don't know how to read it in a way to accomplish what I want. So what I would like to know is a proper way to write/read the wx.Config in a way that everytime someone opens the application, the items from ListCtrl are there. Thanks in advance.

    Read the article

  • ListCtrl - wxPython / Python

    - by Francisco Aleixo
    Hello everyone. My question is if we can assign/bind some value to a certain item and hide that value(or if we can do the same thing in another way). Example: Lets say the columns on ListCtrl are "Name" and "Description": self.lc = wx.ListCtrl(self, -1, style=wx.LC_REPORT) self.lc.InsertColumn(0, 'Name') self.lc.InsertColumn(1, 'Description') And when I add a item I want them to show the Name parameter and the description: num_items = self.lc.GetItemCount() self.lc.InsertStringItem(num_items, "Randomname") self.lc.SetStringItem(num_items, 1, "Some description here") Now what I want to do is basically assign something to that item that is not shown so I can access later on the app. So I would like to add something that is not shown on the app but is on the item value like: hiddendescription = "Somerandomthing" Still didn't undestand? Well lets say I add a button to add a item with some other TextCtrls to set the parameters and the TextCtrls parameters are: "Name" "Description" "Hiddendescription" So then the user fills this textctrls out and clicks the button to create the item, and I basically want only to show the Name and Description and hide the "HiddenDescription" but to do it so I can use it later. Sorry for explaining more than 1 time on this post but I want to make sure you understand what I pretend to do.

    Read the article

  • how to use listctrl in notebook wxPython

    - by ???
    I have one question.. wxPython listctrl in notebook I created 2 tab use notebook. I added button in first tab and added Listctrl in second tab. If i click the button, Add value in Listctrl to second tab. how to solve this problem? import wx class PageOne(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.query_find_btn = wx.Button(self, 4, "BTN", (40,40)) self.Bind(wx.EVT_BUTTON, self.AddList, id = 4) def AddList(self, evt): self.list1.InsertStringItem(0,'Hello') class PageTwo(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.list1 = wx.ListCtrl(self,-1,wx.Point(0,0),wx.Size(400,400),style=wx.LC_REPORT | wx.SUNKEN_BORDER) self.list1.InsertColumn(0,'values') class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self,parent,id,title,size=(400,400),pos=wx.Point(100,100), style=wx.SYSTEM_MENU |wx.CAPTION ) p = wx.Panel(self) nb = wx.Notebook(p) MainFrame = PageOne(nb) SecondFrame = PageTwo(nb) nb.AddPage(MainFrame, "One") nb.AddPage(SecondFrame, "Two") sizer = wx.BoxSizer() sizer.Add(nb, 1, wx.EXPAND) p.SetSizer(sizer) class MyApp(wx.App): def OnInit(self): self.frame=MyFrame(None,-1,'Unknown.py') self.frame.Centre() self.frame.Show() return True if __name__ == '__main__': app = MyApp(False) app.MainLoop()

    Read the article

  • MFC/WIN32: mouse hover highlight in listctrl

    - by Mordachai
    The ListView control of Windows Explorer gives a highlight to whatever item is under the mouse, without affecting the current selection. This helps enormously with relating what item a given tooltip applies to within a listview - especially in report mode. However, I am currently unable to find any APIs that would give my MFC application's CListCtrl that same behavior. Extended styles only have LVS_EX_TRACKSELECT, which actually alters the current selection (yuck!). Does anyone know how to provide a standard CListCtrl (or whatever that actually sits on top of) the mouse-hot-tracking capability? I found some articles on how to provide per cell and per row tooltip text, but its hard to tell what the tooltips relate to without something highlighting...

    Read the article

  • wxpython Prevent Ctrl+Enter from changing the focus

    - by RSabet
    I have two wxListCtrl and want to process the Ctrl+Enter keyboard event without letting wx change the focus to the other ListCtrl. I have event handlers for wx.EVT_KEY_DOWN, wx.EVT_KEY_UP, wx.EVT_CHAR and KillFocus, but KillFocus is always called first, then the focus changes and the the keyboard handlers are called for the wrong ListCtrl. Is there a way to prevent wx from changing the focus, when Ctrl+Enter is pressed ?

    Read the article

  • wxPython - ListCrtl and SQLite3

    - by Dunwitch
    I'm trying to get a SQLite3 DB to populate a wx.ListCrtl. I can get it to print to stdout/stderr without any problem. I just can't seem to figure out how to display the data in the DataWindow/DataList? I'm sure I've made some code mistakes, so any help is appreciated. Main.py import wx import wx.lib.mixins.listctrl as listmix from database import * import sys class DataWindow(wx.Frame): def __init__(self, parent = None): wx.Frame.__init__(self, parent, -1, 'DataList', size=(640,480)) self.win = DataList(self) self.Center() self.Show(True) class DataList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): def __init__(self, parent = DataWindow): wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES) #building the columns self.InsertColumn(0, "Location") self.InsertColumn(1, "Address") self.InsertColumn(2, "Subnet") self.InsertColumn(3, "Gateway") self.SetColumnWidth(0, 100) self.SetColumnWidth(1, 150) self.SetColumnWidth(2, 150) self.SetColumnWidth(3, 150) class MainWindow(wx.Frame): def __init__(self, parent = None, id = -1, title = "MainWindow"): wx.Frame.__init__(self, parent, id, title, size = (800,600), style = wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER)) # StatusBar self.CreateStatusBar() # Filemenu filemenu = wx.Menu() # Filemenu - About menuitem = filemenu.Append(-1, "&About", "Information about this application") self.Bind(wx.EVT_MENU, self.onAbout, menuitem) #Filemenu - Data menuitem = filemenu.Append(-1, "&Data", "Get data") self.Bind(wx.EVT_MENU, self.onData, menuitem) # Filemenu - Seperator filemenu.AppendSeparator() #Filemenu - Exit menuitem = filemenu.Append(-1, "&Exit", "Exit the application") self.Bind(wx.EVT_MENU, self.onExit, menuitem) # Menubar menubar = wx.MenuBar() menubar.Append(filemenu, "&File") self.SetMenuBar(menubar) # Show self.Show(True) self.Center() def onAbout(self, event): pass def onData(self, event): DataWindow(self) callDb = Database() sql = "SELECT rowid, address, subnet, gateway FROM pod1" records = callDb.select(sql) for v in records: print "How do I get the records on the DataList?" #print "%s%s%s" % (v[1],v[2],v[3]) #for v in records: #DataList.InsertStringItem("%s") % (v[0], v[1], v[2]) def onExit(self, event): self.Close() self.Destroy() def onSave(self, event): pass if __name__ == '__main__': app = wx.App() frame = MainWindow(None, -1) frame.Show() app.MainLoop() database.py import os import sqlite3 class Database(object): def __init__(self, db_file="data/data.sqlite"): database_allready_exists = os.path.exists(db_file) self.db = sqlite3.connect(db_file) if not database_allready_exists: self.setupDefaultData() def select(self,sql): cursor = self.db.cursor() cursor.execute(sql) records = cursor.fetchall() cursor.close return records def insert(self,sql): newID = 0 cursor = self.db.cursor() cursor.execute(sql) newID = cursor.lastrowid self.db.commit() cursor.close() return newID def save(self,sql): cursor = self.db.cursor() cursor.execute(sql) self.db.commit() cursor.close() def setupDefaultData(self): pass

    Read the article

  • capture delete key in CListCtrl and do soem processing

    - by user333422
    Hi, I have a class which inherits from CListCtrl class, say class list. I have another class dlg, which inherits from CDialog. Class dlg contains an instance of class list. I have got a delete button in class dlg, on which I delete the selected item in listCtrl and do lots of other processing. I want the same functionality on delete key. I added OnKeyDown() fn is my class list, where I can capture VK_DELETE key. But my problem is that, how do I do otehr processing that I need to do in dialog class. All that processing is dlg class based not list class based. I have many such dlg classes with different data and in every dlg class processing is different. I tried capturing VK_DELETE in dialog class, but it doesn't capture it if focus is on list class. I am totally stuck and have no idea, how to do this. Please give me some idea how i can do this. Thanks, SG

    Read the article

1