سؤال

ولدي ListCtrl يعرض قائمة من البنود للمستخدم لاختيار. هذا يعمل بشكل جيد إلا إذا كانت السيطرة ليست كبيرة بما يكفي لإظهار كل العناصر، أريد أن توسيع أسفل مع شريط scoll الرأسي بدلا من استخدام شريط التمرير الأفقي مع توسعها إلى اليمين.

وخلق وListCtrl ل:

self.subjectList = wx.ListCtrl(self, self.ID_SUBJECT, style = wx.LC_LIST | wx.LC_SINGLE_SEL | wx.LC_VRULES)
يتم إدراج

والسلع باستخدام wx.ListItem:

item = wx.ListItem()
item.SetText(subject)
item.SetData(id)
item.SetWidth(200)
self.subjectList.InsertItem(item)
هل كانت مفيدة؟

المحلول

واستخدم wxLC_REPORT النمط.

import wx

class Test(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.test = wx.ListCtrl(self, style = wx.LC_REPORT | wx.LC_NO_HEADER)

        for i in range(5):
            self.test.InsertColumn(i, 'Col %d' % (i + 1))
            self.test.SetColumnWidth(i, 200)


        for i in range(0, 100, 5):
            index = self.test.InsertStringItem(self.test.GetItemCount(), "")
            for j in range(5):
                self.test.SetStringItem(index, j, str(i+j)*30)

        self.Show()

app = wx.PySimpleApp()
app.TopWindow = Test()
app.MainLoop()

نصائح أخرى

وجرب هذا:

import wx

class Test(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.test = wx.ListCtrl(self, style = wx.LC_ICON | wx.LC_AUTOARRANGE)

        for i in range(100):
            self.test.InsertStringItem(self.test.GetItemCount(), str(i))

        self.Show()

app = wx.PySimpleApp()
app.TopWindow = Test()
app.MainLoop()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top