Code: Alles auswählen
import wx
import os
def GetFileList_p(Ext_spl):
DList_o = []
for FileName_s in os.listdir("."):
(root, ext) = os.path.splitext(FileName_s)
if (os.path.isfile(FileName_s)) and (ext == '.txt'):
DList_o.append(FileName_s)
for DictoName_d in os.listdir(""):
(root, ext) = os.path.splitext(DictoName_d)
if (os.path.isdir(DictoName_d)):
DList_o.append(DictoName_d)
return DList_o
class ListBoxFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'List Box Example', size=(250, 200))
panel = wx.Panel(self, -1)
self.ContentLabel = wx.TextCtrl(panel, -1, size=(100,120), pos=(110, 20), style=wx.TE_MULTILINE)
sampleList = GetFileList_p('.txt')
self.listBox = wx.ListBox(panel, -1, (20, 20), (80, 120), sampleList, wx.LB_SINGLE)
if len(sampleList) > 0:
self.listBox.SetSelection(0)
self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnDClick_file, self.listBox)
def OnDClick_file(self, event):
#wie kann ich hier als event-handling
#einen verzeichniswechsel implementieren?
self.ContentLabel.Clear()
FILE = open(self.listBox.GetStringSelection(), "r") # opening file (reading)
self.ContentLabel.write(FILE.read())
FILE.close()
